Skip to content

Commit 97b5a75

Browse files
committed
Query: Force author__not_in values to be integers
Props peterwilsoncc, westonruter, xknown, joehoyle, sergeybiryukov, jorbin, johnbillion, desrosj. git-svn-id: https://develop.svn.wordpress.org/trunk@62771 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 1000ed1 commit 97b5a75

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/wp-includes/class-wp-query.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,12 +2407,16 @@ public function get_posts() {
24072407
}
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'] );
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;
24132419
}
2414-
$author__not_in = implode( ',', (array) $query_vars['author__not_in'] );
2415-
$where .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
24162420
} elseif ( ! empty( $query_vars['author__in'] ) ) {
24172421
if ( is_array( $query_vars['author__in'] ) ) {
24182422
$query_vars['author__in'] = array_unique( array_map( 'absint', $query_vars['author__in'] ) );

0 commit comments

Comments
 (0)