Make WordPress Core

Changeset 62776


Ignore:
Timestamp:
07/17/2026 04:36:47 PM (8 weeks ago)
Author:
desrosj
Message:

Grouped backports to the 6.8 branch.

  • REST API: sub-requests must always use dispatch.
  • REST API: Ensure errors in batch requests propogate.
  • Query: Force authornot_in values to be integers.

Merges [62769], [62770], [62771] to the 6.8 branch.

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

Location:
branches/6.8/src/wp-includes
Files:
3 edited

Legend:

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

    r60048 r62776  
    24022402
    24032403                if ( ! empty( $q['author__not_in'] ) ) {
    2404                         if ( is_array( $q['author__not_in'] ) ) {
    2405                                 $q['author__not_in'] = array_unique( array_map( 'absint', $q['author__not_in'] ) );
    2406                                 sort( $q['author__not_in'] );
    2407                         }
    2408                         $author__not_in = implode( ',', (array) $q['author__not_in'] );
    2409                         $where         .= " AND {$wpdb->posts}.post_author NOT IN ($author__not_in) ";
     2404                        $author__not_in_id_list = wp_parse_id_list( $q['author__not_in'] );
     2405                        if ( count( $author__not_in_id_list ) > 0 ) {
     2406                                sort( $author__not_in_id_list );
     2407                                $where .= sprintf(
     2408                                        " AND {$wpdb->posts}.post_author NOT IN (%s) ",
     2409                                        implode( ',', $author__not_in_id_list )
     2410                                );
     2411                                /** Update the query var for stable cache key generation in {@see self::generate_cache_key()}. */
     2412                                $q['author__not_in'] = $author__not_in_id_list;
     2413                        }
    24102414                } elseif ( ! empty( $q['author__in'] ) ) {
    24112415                        if ( is_array( $q['author__in'] ) ) {
  • branches/6.8/src/wp-includes/rest-api.php

    r60105 r62776  
    431431        }
    432432
     433        // Short-circuit before define()/die() if a REST dispatch is already in flight.
     434        // serve_request() enforces this too; guarding here avoids the trailing die().
     435        if ( isset( $GLOBALS['wp_rest_server'] )
     436                && $GLOBALS['wp_rest_server'] instanceof WP_REST_Server
     437                && $GLOBALS['wp_rest_server']->is_dispatching()
     438        ) {
     439                return;
     440        }
     441
    433442        // Return an error message if query_var is not a string.
    434443        if ( ! is_string( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
  • branches/6.8/src/wp-includes/rest-api/class-wp-rest-server.php

    r59880 r62776  
    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;
     
    17541760
    17551761                foreach ( $requests as $single_request ) {
     1762                        if ( is_wp_error( $single_request ) ) {
     1763                                $has_error    = true;
     1764                                $matches[]    = $single_request;
     1765                                $validation[] = $single_request;
     1766                                continue;
     1767                        }
     1768
    17561769                        $match     = $this->match_request_to_handler( $single_request );
    17571770                        $matches[] = $match;
Note: See TracChangeset for help on using the changeset viewer.