Make WordPress Core


Ignore:
Timestamp:
06/04/2014 05:49:26 PM (12 years ago)
Author:
wonderboymusic
Message:

After [28613], also kill queries that explicityly pass empty arrays to category__in, tag__in, tag_slug__in, and author__in to WP_Query.

Adds unit tests.
Fixes #28099.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r28623 r28664  
    18311831                                'include_children' => false
    18321832                        );
     1833                } elseif ( isset( $this->query['category__in'] ) ) {
     1834                        $q['category__in'] = false;
    18331835                }
    18341836
     
    18881890                                'terms' => $q['tag__in']
    18891891                        );
     1892                } elseif ( isset( $this->query['tag__in'] ) ) {
     1893                        $q['tag__in'] = false;
    18901894                }
    18911895
     
    19151919                                'field' => 'slug'
    19161920                        );
     1921                } elseif ( isset( $this->query['tag_slug__in'] ) ) {
     1922                        $q['tag_slug__in'] = false;
    19171923                }
    19181924
     
    25012507                }
    25022508
     2509                // If *__in is passed to WP_Query as an empty array, don't return results
     2510                foreach ( array( 'category', 'tag', 'tag_slug' ) as $in ) {
     2511                        if ( isset( $q["{$in}__in"] ) && false === $q["{$in}__in"] ) {
     2512                                $where = " AND 1=0 $where";
     2513                        }
     2514                }
     2515
    25032516                if ( $this->is_tax ) {
    25042517                        if ( empty($post_type) ) {
     
    25922605                        $author__in = implode( ',', array_map( 'absint', array_unique( (array) $q['author__in'] ) ) );
    25932606                        $where .= " AND {$wpdb->posts}.post_author IN ($author__in) ";
     2607                } elseif ( isset( $this->query['author__in'] ) ) {
     2608                        $author__in = 0;
     2609                        $where .= ' AND 1=0 ';
    25942610                }
    25952611
Note: See TracChangeset for help on using the changeset viewer.