REST API: Normalize WP_REST_Server::dispatch() to return a response object.
Previously, the `rest_pre_dispatch` filter could be used to return a `WP_Error` instance. This would cause a fatal error for `rest_post_dispath` filters that were rightly expecting a `WP_REST_Response` object to be passed instead. Props DaveFX, felipeelia. Fixes #56566. Built from https://develop.svn.wordpress.org/trunk@55361 git-svn-id: http://core.svn.wordpress.org/trunk@54894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
db71029a47
commit
42b25d58ea
|
@ -984,6 +984,15 @@ class WP_REST_Server {
|
|||
$result = apply_filters( 'rest_pre_dispatch', null, $this, $request );
|
||||
|
||||
if ( ! empty( $result ) ) {
|
||||
|
||||
// Normalize to either WP_Error or WP_REST_Response...
|
||||
$result = rest_ensure_response( $result );
|
||||
|
||||
// ...then convert WP_Error across.
|
||||
if ( is_wp_error( $result ) ) {
|
||||
$result = $this->error_to_response( $result );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.2-beta2-55360';
|
||||
$wp_version = '6.2-beta2-55361';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue