From fc1d2c99c9d17e3ed7f09ffdea4d578ff34e1f74 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 30 May 2016 04:36:27 +0000 Subject: [PATCH] In `WP_Meta_Query`, don't cast `meta_value` to `CHAR`. `CHAR` is redundant, since the `meta_value` column is `LONGTEXT`. Meanwhile, use of `CAST()` causes MySQL to ignore any index that the administrator may have added to the column. A number of automated tests were doing searches for `CAST` in the SQL strings generated by `WP_Meta_Query` (for reasons unrelated to the `CAST()` behavior). These tests have been updated to expect the new query format. Props ericlewis. Fixes #36625. Built from https://develop.svn.wordpress.org/trunk@37594 git-svn-id: http://core.svn.wordpress.org/trunk@37562 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-meta-query.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-meta-query.php b/wp-includes/class-wp-meta-query.php index b1369a067d..ddafc6181b 100644 --- a/wp-includes/class-wp-meta-query.php +++ b/wp-includes/class-wp-meta-query.php @@ -632,7 +632,11 @@ class WP_Meta_Query { } if ( $where ) { - $sql_chunks['where'][] = "CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$where}"; + if ( 'CHAR' === $meta_type ) { + $sql_chunks['where'][] = "$alias.meta_value {$meta_compare} {$where}"; + } else { + $sql_chunks['where'][] = "CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$where}"; + } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index a1d152035d..e5085e504b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.6-alpha-37593'; +$wp_version = '4.6-alpha-37594'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.