Skip to content

Commit b70ed09

Browse files
authored
Merge branch 'WordPress:trunk' into trunk
2 parents afde4dd + 97b5a75 commit b70ed09

3 files changed

Lines changed: 25 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'] ) );

src/wp-includes/rest-api.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ function rest_api_loaded() {
450450
return;
451451
}
452452

453+
// Short-circuit before define()/die() if a REST dispatch is already in flight.
454+
// serve_request() enforces this too; guarding here avoids the trailing die().
455+
if ( isset( $GLOBALS['wp_rest_server'] )
456+
&& $GLOBALS['wp_rest_server'] instanceof WP_REST_Server
457+
&& $GLOBALS['wp_rest_server']->is_dispatching()
458+
) {
459+
return;
460+
}
461+
453462
// Return an error message if query_var is not a string.
454463
if ( ! is_string( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
455464
$rest_type_error = new WP_Error(

src/wp-includes/rest-api/class-wp-rest-server.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,12 @@ protected function get_json_encode_options( WP_REST_Request $request ) {
283283
* @return null|false Null if not served and a HEAD request, false otherwise.
284284
*/
285285
public function serve_request( $path = null ) {
286+
// Refuse to start a fresh top-level REST cycle while another dispatch
287+
// is already in flight. Internal sub-requests must use dispatch().
288+
if ( $this->is_dispatching() ) {
289+
return false;
290+
}
291+
286292
/* @var WP_User|null $current_user */
287293
global $current_user;
288294

@@ -1756,6 +1762,7 @@ public function serve_batch_request_v1( WP_REST_Request $batch_request ) {
17561762
foreach ( $requests as $single_request ) {
17571763
if ( is_wp_error( $single_request ) ) {
17581764
$has_error = true;
1765+
$matches[] = $single_request;
17591766
$validation[] = $single_request;
17601767
continue;
17611768
}

0 commit comments

Comments
 (0)