Make WordPress Core

Changeset 22109


Ignore:
Timestamp:
10/04/2012 01:16:47 PM (14 years ago)
Author:
ryan
Message:

An empty taxonomy query should return no results rather than all posts. Props wonderboymusic. fixes #20604

File:
1 edited

Legend:

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

    r21996 r22109  
    661661                $where = array();
    662662                $i = 0;
    663 
    664                 foreach ( $this->queries as $query ) {
     663                $count = count( $this->queries );
     664
     665                foreach ( $this->queries as $index => $query ) {
    665666                        $this->clean_query( $query );
    666667
    667                         if ( is_wp_error( $query ) ) {
     668                        if ( is_wp_error( $query ) )
    668669                                return self::$no_results;
    669                         }
    670670
    671671                        extract( $query );
    … …  
    674674
    675675                                if ( empty( $terms ) ) {
    676                                         if ( 'OR' == $this->relation )
     676                                        if ( 'OR' == $this->relation ) {
     677                                                if ( ( $index + 1 === $count ) && empty( $where ) )
     678                                                        return self::$no_results;
    677679                                                continue;
    678                                         else
     680                                        } else {
    679681                                                return self::$no_results;
     682                                        }
    680683                                }
    681684
    … …  
    721724                }
    722725
    723                 if ( !empty( $where ) )
     726                if ( ! empty( $where ) )
    724727                        $where = ' AND ( ' . implode( " $this->relation ", $where ) . ' )';
    725728                else
Note: See TracChangeset for help on using the changeset viewer.