In `WP_Meta_Query`, interpret 'value' correctly when used with EXISTS/NOT EXISTS.

As in earlier versions, EXISTS with a value is equivalent to '=', while NOT
EXISTS should always ignore 'value'.

Props barrykooij.
Fixes #30681 for trunk.
Built from https://develop.svn.wordpress.org/trunk@30846


git-svn-id: http://core.svn.wordpress.org/trunk@30836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2014-12-14 19:01:26 +00:00
parent 9416431655
commit 5eeea164ef
1 changed files with 11 additions and 0 deletions

View File

@ -1419,6 +1419,17 @@ class WP_Meta_Query {
$where = $wpdb->prepare( '%s', $meta_value ); $where = $wpdb->prepare( '%s', $meta_value );
break; break;
// EXISTS with a value is interpreted as '='.
case 'EXISTS' :
$meta_compare = '=';
$where = $wpdb->prepare( '%s', $meta_value );
break;
// 'value' is ignored for NOT EXISTS.
case 'NOT EXISTS' :
$where = '';
break;
default : default :
$where = $wpdb->prepare( '%s', $meta_value ); $where = $wpdb->prepare( '%s', $meta_value );
break; break;