From 5129b9d0ffdd9e304dabb12ce570857efe26a937 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 8 Nov 2013 22:52:08 +0000 Subject: [PATCH] Respect the `compare` operator value in `meta_query` when `value` evaluates to `null`. Adds Unit Test. Props bradyvercher, gradyetc. Fixes #22967. Built from https://develop.svn.wordpress.org/trunk@26053 git-svn-id: http://core.svn.wordpress.org/trunk@25978 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/meta.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 4066781af0..357c12c112 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -753,7 +753,7 @@ class WP_Meta_Query { // Split out the meta_key only queries (we can only do this for OR) if ( 'OR' == $this->relation ) { foreach ( $this->queries as $k => $q ) { - if ( ! isset( $q['value'] ) && ! empty( $q['key'] ) ) + if ( ! array_key_exists( 'value', $q ) && ! empty( $q['key'] ) ) $key_only_queries[$k] = $q; else $queries[$k] = $q; @@ -774,6 +774,9 @@ class WP_Meta_Query { $meta_key = isset( $q['key'] ) ? trim( $q['key'] ) : ''; $meta_type = $this->get_cast_for_type( isset( $q['type'] ) ? $q['type'] : '' ); + if ( array_key_exists( 'value', $q ) && is_null( $q['value'] ) ) + $q['value'] = ''; + $meta_value = isset( $q['value'] ) ? $q['value'] : null; if ( isset( $q['compare'] ) )