Skip to content

backtick column names #48202

@nebbens

Description

@nebbens

Impacted plugin

Jetpack

Quick summary

I would like to request a code change. I would like to request that backticks be added to the column names in the method: Jetpack_Sitemap_Librarian::get_sanitized_post_columns($wpdb). I’m sure it can be done different ways, but I solved it temporarily by changing line 483 to:

return '`' . implode( '`,`', array_map( 'esc_sql', $columns ) ) . '`';

I was getting a sql error due to having a column name that is a keyword (order) in my wp_posts table. I’m not sure what plugin added that column in the past (nor whether it is even used still), but surrounding the column names with backticks takes care of the problem.

This problem was discovered when it conflicted with Solid Backups Legacy plugin causing the backup to fail.

Thank you for considering this change.

Steps to reproduce

Add a column to the wp_posts table which is a reserved word.

Site owner impact

Fewer than 20% of the total website/platform users

Severity

Major

What other impact(s) does this issue have?

No response

If a workaround is available, please outline it here.

In Jetpack_Sitemap_Librarian::get_sanitized_post_columns($wpdb),
change line 483 to:

return '`' . implode( '`,`', array_map( 'esc_sql', $columns ) ) . '`';

Platform (Simple and/or Atomic)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugWhen a feature is broken and / or not performing as intendedNeeds triageTicket needs to be triaged

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions