WordPress.org

Make WordPress Core

Changeset 24563


Ignore:
Timestamp:
07/05/13 16:40:46 (10 months ago)
Author:
markjaquith
Message:

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

fixes #22096. props wonderboymusic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/meta.php

    r24490 r24563  
    679679 
    680680        // WP_Query sets 'meta_value' = '' by default 
    681         if ( isset( $qv[ 'meta_value' ] ) && '' !== $qv[ 'meta_value' ] ) 
     681        if ( isset( $qv[ 'meta_value' ] ) && '' !== $qv[ 'meta_value' ] && ( ! is_array( $qv[ 'meta_value' ] ) || $qv[ 'meta_value' ] ) ) 
    682682            $meta_query[0]['value'] = $qv[ 'meta_value' ]; 
    683683 
     
    715715        $queries = array(); 
    716716 
     717        // Split out the queries with empty arrays as value 
     718        foreach ( $this->queries as $k => $q ) { 
     719            if ( is_array( $q['value'] ) && empty( $q['value'] ) ) { 
     720                $key_only_queries[$k] = $q; 
     721                unset( $this->queries[$k] ); 
     722            } 
     723        }        
     724         
    717725        // Split out the meta_key only queries (we can only do this for OR) 
    718726        if ( 'OR' == $this->relation ) { 
Note: See TracChangeset for help on using the changeset viewer.