When using `meta_query` in a `WP_Query`, passing `NOT EXISTS` or `''` to `compare` should not require `value` to be set. The resulting SQL should then produce the appropriate `OR` clause for existence of non-existence after passing the query to the `$key_only_queries` stack internally.
Adds unit tests. Props chrisguitarguy, for the original patch. Fixes #23268. Built from https://develop.svn.wordpress.org/trunk@27689 git-svn-id: http://core.svn.wordpress.org/trunk@27528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b933f954e3
commit
0115ba2f30
|
@ -753,7 +753,7 @@ class WP_Meta_Query {
|
||||||
// Split out the meta_key only queries (we can only do this for OR)
|
// Split out the meta_key only queries (we can only do this for OR)
|
||||||
if ( 'OR' == $this->relation ) {
|
if ( 'OR' == $this->relation ) {
|
||||||
foreach ( $this->queries as $k => $q ) {
|
foreach ( $this->queries as $k => $q ) {
|
||||||
if ( ! array_key_exists( 'value', $q ) && ! empty( $q['key'] ) )
|
if ( ( empty( $q['compare'] ) || 'NOT EXISTS' != $q['compare'] ) && ! array_key_exists( 'value', $q ) && ! empty( $q['key'] ) )
|
||||||
$key_only_queries[$k] = $q;
|
$key_only_queries[$k] = $q;
|
||||||
else
|
else
|
||||||
$queries[$k] = $q;
|
$queries[$k] = $q;
|
||||||
|
|
Loading…
Reference in New Issue