From 4d3ca52c4578e2213338363b317d2f2b9c6c5cf9 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Sat, 27 Jul 2019 13:44:57 +0000 Subject: [PATCH] REST API: Pass current request object to `rest_authentication_errors` filter in `WP_REST_Server::check_authentication()`. Fixes #46907. Built from https://develop.svn.wordpress.org/trunk@45687 git-svn-id: http://core.svn.wordpress.org/trunk@45498 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api/class-wp-rest-server.php | 14 +++++++++----- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/wp-includes/rest-api/class-wp-rest-server.php b/wp-includes/rest-api/class-wp-rest-server.php index f34a6106e3..68be073eef 100644 --- a/wp-includes/rest-api/class-wp-rest-server.php +++ b/wp-includes/rest-api/class-wp-rest-server.php @@ -103,11 +103,13 @@ class WP_REST_Server { * Checks the authentication headers if supplied. * * @since 4.4.0 + * @since 5.3.0 Added the `$request` parameter. * + * @param WP_REST_Request $request Full data about the request. * @return WP_Error|null WP_Error indicates unsuccessful login, null indicates successful * or no authentication provided */ - public function check_authentication() { + public function check_authentication( $request ) { /** * Filters REST authentication errors. * @@ -128,11 +130,13 @@ class WP_REST_Server { * the authentication method was used, and it succeeded. * * @since 4.4.0 + * @since 5.3.0 Added the `$request` argument. * - * @param WP_Error|null|bool WP_Error if authentication error, null if authentication - * method wasn't used, true if authentication succeeded. + * @param WP_Error|null|bool $result WP_Error if authentication error, null if authentication + * method wasn't used, true if authentication succeeded. + * @param WP_REST_Request $request Full data about the request. */ - return apply_filters( 'rest_authentication_errors', null ); + return apply_filters( 'rest_authentication_errors', null, $request ); } /** @@ -323,7 +327,7 @@ class WP_REST_Server { $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); } - $result = $this->check_authentication(); + $result = $this->check_authentication( $request ); if ( ! is_wp_error( $result ) ) { $result = $this->dispatch( $request ); diff --git a/wp-includes/version.php b/wp-includes/version.php index cece492656..61bb079c0f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45686'; +$wp_version = '5.3-alpha-45687'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.