From 908d05487bc557efef6959e7c1721b16391d4d14 Mon Sep 17 00:00:00 2001 From: Giovanni Cascione <43221199+spleen1981@users.noreply.github.com> Date: Sun, 1 May 2022 15:19:54 +0200 Subject: [PATCH 1/3] QTS: fix to handle esc_sql() 4.8.3 breaking change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 4.8.3, ‘%’ characters will be replaced with a placeholder string with esc_sql(). This fix replaces back the placeholder to ‘%’ after esc_sql() call to retain the original behaviour. --- modules/slugs/includes/class-qtranslate-slug.php | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/slugs/includes/class-qtranslate-slug.php b/modules/slugs/includes/class-qtranslate-slug.php index 55043151..54ef7972 100644 --- a/modules/slugs/includes/class-qtranslate-slug.php +++ b/modules/slugs/includes/class-qtranslate-slug.php @@ -957,6 +957,7 @@ private function get_page_id_by_path( $page_path, $output = OBJECT, $post_type = $page_path = str_replace( '%20', ' ', $page_path ); $parts = explode( '/', trim( $page_path, '/' ) ); $parts = array_map( 'esc_sql', $parts ); + $parts = array_map(array($wpdb,'remove_placeholder_escape'), $parts); $parts = array_map( 'sanitize_title_for_query', $parts ); $in_string = "'" . implode( "','", $parts ) . "'"; $meta_key = QTS_META_PREFIX . $this->get_temp_lang(); From bfe63b039906e70427e7fd3885df9263924b128e Mon Sep 17 00:00:00 2001 From: Herr Vigg Date: Sun, 1 May 2022 15:44:02 +0200 Subject: [PATCH 2/3] PHP format --- modules/slugs/includes/class-qtranslate-slug.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/slugs/includes/class-qtranslate-slug.php b/modules/slugs/includes/class-qtranslate-slug.php index 54ef7972..03c3dd8c 100644 --- a/modules/slugs/includes/class-qtranslate-slug.php +++ b/modules/slugs/includes/class-qtranslate-slug.php @@ -957,7 +957,7 @@ private function get_page_id_by_path( $page_path, $output = OBJECT, $post_type = $page_path = str_replace( '%20', ' ', $page_path ); $parts = explode( '/', trim( $page_path, '/' ) ); $parts = array_map( 'esc_sql', $parts ); - $parts = array_map(array($wpdb,'remove_placeholder_escape'), $parts); + $parts = array_map( array( $wpdb, 'remove_placeholder_escape' ), $parts ); $parts = array_map( 'sanitize_title_for_query', $parts ); $in_string = "'" . implode( "','", $parts ) . "'"; $meta_key = QTS_META_PREFIX . $this->get_temp_lang(); From 5ca8b04995b336a292be9aa2a8b50d4f8e440dc5 Mon Sep 17 00:00:00 2001 From: Giovanni Cascione <43221199+spleen1981@users.noreply.github.com> Date: Sun, 1 May 2022 16:13:49 +0200 Subject: [PATCH 3/3] group array_map calls --- modules/slugs/includes/class-qtranslate-slug.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/slugs/includes/class-qtranslate-slug.php b/modules/slugs/includes/class-qtranslate-slug.php index 03c3dd8c..6da40b34 100644 --- a/modules/slugs/includes/class-qtranslate-slug.php +++ b/modules/slugs/includes/class-qtranslate-slug.php @@ -956,9 +956,16 @@ private function get_page_id_by_path( $page_path, $output = OBJECT, $post_type = $page_path = str_replace( '%2F', '/', $page_path ); $page_path = str_replace( '%20', ' ', $page_path ); $parts = explode( '/', trim( $page_path, '/' ) ); - $parts = array_map( 'esc_sql', $parts ); - $parts = array_map( array( $wpdb, 'remove_placeholder_escape' ), $parts ); - $parts = array_map( 'sanitize_title_for_query', $parts ); + $parts = array_map( + function ( $a ) { + global $wpdb; + return sanitize_title_for_query( + $wpdb->remove_placeholder_escape( + esc_sql( $a ) + ) + ); + }, + $parts ); $in_string = "'" . implode( "','", $parts ) . "'"; $meta_key = QTS_META_PREFIX . $this->get_temp_lang(); $post_type_sql = $post_type;