Prevent invalid queries in certain empty-array-passing meta_query cases.

fixes #22096. props wonderboymusic.

git-svn-id: https://develop.svn.wordpress.org/trunk@24563 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2013-07-05 16:40:46 +00:00
parent 08c5b3f725
commit 12ff8a31c3
1 changed files with 9 additions and 1 deletions

View File

@ -678,7 +678,7 @@ class WP_Meta_Query {
}
// WP_Query sets 'meta_value' = '' by default
if ( isset( $qv[ 'meta_value' ] ) && '' !== $qv[ 'meta_value' ] )
if ( isset( $qv[ 'meta_value' ] ) && '' !== $qv[ 'meta_value' ] && ( ! is_array( $qv[ 'meta_value' ] ) || $qv[ 'meta_value' ] ) )
$meta_query[0]['value'] = $qv[ 'meta_value' ];
if ( !empty( $qv['meta_query'] ) && is_array( $qv['meta_query'] ) ) {
@ -714,6 +714,14 @@ class WP_Meta_Query {
$key_only_queries = array();
$queries = array();
// Split out the queries with empty arrays as value
foreach ( $this->queries as $k => $q ) {
if ( is_array( $q['value'] ) && empty( $q['value'] ) ) {
$key_only_queries[$k] = $q;
unset( $this->queries[$k] );
}
}
// Split out the meta_key only queries (we can only do this for OR)
if ( 'OR' == $this->relation ) {
foreach ( $this->queries as $k => $q ) {