From a0d71729142207a098550ce15d86c40bf8bafe09 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin Date: Thu, 26 Oct 2023 22:36:25 +0000 Subject: [PATCH] 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 --- wp-includes/rest-api/class-wp-rest-server.php | 32 +++++++++---------- wp-includes/version.php | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index fdc3034755..4304881b16 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -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; diff --git a/wp-includes/version.php b/wp-includes/version.php index 3d8f7bdd23..1a585993a7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.