Make WordPress Core

Changeset 62774


Ignore:
Timestamp:
07/17/2026 04:28:32 PM (3 weeks ago)
Author:
desrosj
Message:

Query: Force author__not_in values to be integers

Merges [62771] to the 7.0 branch.

Props peterwilsoncc, westonruter, xknown, joehoyle, sergeybiryukov, jorbin, johnbillion, desrosj.

Location:
branches/7.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/7.0

  • branches/7.0/src/wp-includes/class-wp-query.php

    r62047 r62774  
    23982398
    23992399                if ( ! empty( $query_vars['author__not_in'] ) ) {
    2400                         if ( is_array( $query_vars['author__not_in'] ) ) {
    2401                                 $query_vars['author__not_in'] = array_unique( array_map( 'absint', $query_vars['author__not_in'] ) );
    2402                                 sort( $query_vars['author__not_in'] );
    2403                         }
    2404                         $author__not_in = implode( ',', (array) $query_vars['author__not_in'] );
    2405                         $where         .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
     2400                        $author__not_in_id_list = wp_parse_id_list( $query_vars['author__not_in'] );
     2401                        if ( count( $author__not_in_id_list ) > 0 ) {
     2402                                sort( $author__not_in_id_list );
     2403                                $where .= sprintf(
     2404                                        " AND {$wpdb->posts}.post_author NOT IN (%s) ",
     2405                                        implode( ',', $author__not_in_id_list )
     2406                                );
     2407                                /** Update the query var for stable cache key generation in {@see self::generate_cache_key()}. */
     2408                                $query_vars['author__not_in'] = $author__not_in_id_list;
     2409                        }
    24062410                } elseif ( ! empty( $query_vars['author__in'] ) ) {
    24072411                        if ( is_array( $query_vars['author__in'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.