Make WordPress Core

Changeset 57015


Ignore:
Timestamp:
10/26/2023 11:15:31 PM (6 months ago)
Author:
jorbin
Message:

REST API: Move rest_pre_serve_request filter to after no cache headers are sent.

Merges [57012] to 6.3 branch.

[56834] adjusted the order of activity inside the rest server responses. This lead to the rest_pre_serve_request filter potentially blocking the sending of the no cache headers. This moves that action back to being after the sending of no cache headers has finished to restore the pre 6.3.2 order of these two actions.

Props perrelet, SergeyBiryukov, peterwilsoncc, hellofromTonya.
Fixes #59722.

Location:
branches/6.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.3

  • branches/6.3/src/wp-includes/rest-api/class-wp-rest-server.php

    r56841 r57015  
    468468
    469469        /**
    470          * Filters whether the REST API request has already been served.
    471          *
    472          * Allow sending the request manually - by returning true, the API result
    473          * will not be sent to the client.
    474          *
    475          * @since 4.4.0
    476          *
    477          * @param bool             $served  Whether the request has already been served.
    478          *                                           Default false.
    479          * @param WP_HTTP_Response $result  Result to send to the client. Usually a `WP_REST_Response`.
    480          * @param WP_REST_Request  $request Request used to generate the response.
    481          * @param WP_REST_Server   $server  Server instance.
    482          */
    483         $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
    484 
    485         /**
    486470         * Filters whether to send nocache headers on a REST API request.
    487471         *
     
    504488            }
    505489        }
     490
     491        /**
     492         * Filters whether the REST API request has already been served.
     493         *
     494         * Allow sending the request manually - by returning true, the API result
     495         * will not be sent to the client.
     496         *
     497         * @since 4.4.0
     498         *
     499         * @param bool             $served  Whether the request has already been served.
     500         *                                           Default false.
     501         * @param WP_HTTP_Response $result  Result to send to the client. Usually a `WP_REST_Response`.
     502         * @param WP_REST_Request  $request Request used to generate the response.
     503         * @param WP_REST_Server   $server  Server instance.
     504         */
     505        $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
    506506
    507507        if ( ! $served ) {
Note: See TracChangeset for help on using the changeset viewer.