Make WordPress Core

Changeset 62771


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

Query: Force author__not_in values to be integers

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

File:
1 edited

Legend:

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

    r62664 r62771  
    24082408
    24092409                if ( ! empty( $query_vars['author__not_in'] ) ) {
    2410                         if ( is_array( $query_vars['author__not_in'] ) ) {
    2411                                 $query_vars['author__not_in'] = array_unique( array_map( 'absint', $query_vars['author__not_in'] ) );
    2412                                 sort( $query_vars['author__not_in'] );
    2413                         }
    2414                         $author__not_in = implode( ',', (array) $query_vars['author__not_in'] );
    2415                         $where         .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
     2410                        $author__not_in_id_list = wp_parse_id_list( $query_vars['author__not_in'] );
     2411                        if ( count( $author__not_in_id_list ) > 0 ) {
     2412                                sort( $author__not_in_id_list );
     2413                                $where .= sprintf(
     2414                                        " AND {$wpdb->posts}.post_author NOT IN (%s) ",
     2415                                        implode( ',', $author__not_in_id_list )
     2416                                );
     2417                                /** Update the query var for stable cache key generation in {@see self::generate_cache_key()}. */
     2418                                $query_vars['author__not_in'] = $author__not_in_id_list;
     2419                        }
    24162420                } elseif ( ! empty( $query_vars['author__in'] ) ) {
    24172421                        if ( is_array( $query_vars['author__in'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.