Make WordPress Core

Changeset 57012

Timestamp:
10/26/2023 10:34:41 PM (9 months ago)
Author:
jorbin
Message:

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

[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.
Fixes #59722.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-server.php

    r56834 r57012  
    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
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
     504
     505
    506506
    507507        if ( ! $served ) {
Note: See TracChangeset for help on using the changeset viewer.