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.

Built from https://develop.svn.wordpress.org/trunk@57012


git-svn-id: http://core.svn.wordpress.org/trunk@56523 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2023-10-26 22:36:25 +00:00
parent 39ccc3798d
commit a0d7172914
2 changed files with 17 additions and 17 deletions

View File

@ -466,22 +466,6 @@ class WP_REST_Server {
$code = $result->get_status();
$this->set_status( $code );
/**
* Filters whether the REST API request has already been served.
*
* Allow sending the request manually - by returning true, the API result
* will not be sent to the client.
*
* @since 4.4.0
*
* @param bool $served Whether the request has already been served.
* Default false.
* @param WP_HTTP_Response $result Result to send to the client. Usually a `WP_REST_Response`.
* @param WP_REST_Request $request Request used to generate the response.
* @param WP_REST_Server $server Server instance.
*/
$served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
/**
* Filters whether to send nocache headers on a REST API request.
*
@ -504,6 +488,22 @@ class WP_REST_Server {
}
}
/**
* Filters whether the REST API request has already been served.
*
* Allow sending the request manually - by returning true, the API result
* will not be sent to the client.
*
* @since 4.4.0
*
* @param bool $served Whether the request has already been served.
* Default false.
* @param WP_HTTP_Response $result Result to send to the client. Usually a `WP_REST_Response`.
* @param WP_REST_Request $request Request used to generate the response.
* @param WP_REST_Server $server Server instance.
*/
$served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
if ( ! $served ) {
if ( 'HEAD' === $request->get_method() ) {
return null;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.5-alpha-57011';
$wp_version = '6.5-alpha-57012';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.