From c4e4fde2a76a314f9daf6aeb31d707b81ee20189 Mon Sep 17 00:00:00 2001 From: SH Sajal Chowdhury Date: Sun, 3 May 2026 21:58:14 +0200 Subject: [PATCH] Sitemaps: wrap column names in backticks to prevent SQL errors with reserved words When a wp_posts column name matches a MySQL reserved word (e.g. 'order'), the generated SQL query fails. Wrapping column names in backticks ensures compatibility regardless of column names. Fixes #48202 --- .../jetpack/changelog/fix-sitemap-backtick-column-names | 4 ++++ .../plugins/jetpack/modules/sitemaps/sitemap-librarian.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/fix-sitemap-backtick-column-names diff --git a/projects/plugins/jetpack/changelog/fix-sitemap-backtick-column-names b/projects/plugins/jetpack/changelog/fix-sitemap-backtick-column-names new file mode 100644 index 000000000000..278ba9842697 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-sitemap-backtick-column-names @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Sitemaps: wrap column names in backticks to prevent SQL errors when a column name matches a MySQL reserved word. diff --git a/projects/plugins/jetpack/modules/sitemaps/sitemap-librarian.php b/projects/plugins/jetpack/modules/sitemaps/sitemap-librarian.php index a3544d81ea4f..da2900c99d0b 100644 --- a/projects/plugins/jetpack/modules/sitemaps/sitemap-librarian.php +++ b/projects/plugins/jetpack/modules/sitemaps/sitemap-librarian.php @@ -480,6 +480,6 @@ function ( $column ) { } ); - return implode( ',', array_map( 'esc_sql', $columns ) ); + return '`' . implode( '`,`', array_map( 'esc_sql', $columns ) ) . '`'; } }