REST API: Ensure rest_controller instantiates the post type's declared REST controller class.
Ensures that the ::get_rest_controller() method will always return an instanceof the expected controller class, or null. Removes unused private static property $post_type_controllers. Props dlh, TimothyBlynJacobs. Fixes #45677. Built from https://develop.svn.wordpress.org/trunk@46435 git-svn-id: http://core.svn.wordpress.org/trunk@46233 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5815551dfe
commit
ed11103f39
|
@ -343,7 +343,7 @@ final class WP_Post_Type {
|
|||
* @since 5.3.0
|
||||
* @var WP_REST_Controller $rest_controller
|
||||
*/
|
||||
private $rest_controller;
|
||||
public $rest_controller;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -722,6 +722,10 @@ final class WP_Post_Type {
|
|||
$this->rest_controller = new $class( $this->name );
|
||||
}
|
||||
|
||||
if ( ! ( $this->rest_controller instanceof $class ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->rest_controller;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,15 +15,6 @@
|
|||
* @see WP_REST_Controller
|
||||
*/
|
||||
class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
|
||||
/**
|
||||
* Instances of post type controllers keyed by post type.
|
||||
*
|
||||
* @since 5.3.0
|
||||
* @var WP_REST_Controller[]
|
||||
*/
|
||||
private static $post_type_controllers = array();
|
||||
|
||||
/**
|
||||
* Post type.
|
||||
*
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.3-beta2-46434';
|
||||
$wp_version = '5.3-beta2-46435';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue