diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
index 1c73b97824..947ebf08f2 100644
a
|
b
|
function create_initial_rest_routes() { |
210 | 210 | } |
211 | 211 | |
212 | 212 | if ( 'attachment' !== $post_type->name ) { |
213 | | $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name ); |
| 213 | $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name, $controller ); |
214 | 214 | $autosaves_controller->register_routes(); |
215 | 215 | } |
216 | 216 | } |
diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
index bf5b180df8..4562fc5ebd 100644
a
|
b
|
class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { |
52 | 52 | * Constructor. |
53 | 53 | * |
54 | 54 | * @since 5.0.0 |
| 55 | * @since 5.3.0 Added $parent_controller parameter. |
55 | 56 | * |
56 | | * @param string $parent_post_type Post type of the parent. |
57 | | */ |
58 | | public function __construct( $parent_post_type ) { |
| 57 | * @param string $parent_post_type Post type of the parent. |
| 58 | * @param WP_REST_Controller|null $parent_controller Controller for the Posts endpoint. |
| 59 | */ |
| 60 | public function __construct( $parent_post_type, $parent_controller = null ) { |
59 | 61 | $this->parent_post_type = $parent_post_type; |
60 | 62 | $post_type_object = get_post_type_object( $parent_post_type ); |
61 | 63 | |
62 | | // Ensure that post type-specific controller logic is available. |
63 | | $parent_controller_class = ! empty( $post_type_object->rest_controller_class ) ? $post_type_object->rest_controller_class : 'WP_REST_Posts_Controller'; |
| 64 | if ( ! $parent_controller instanceof WP_REST_Controller ) { |
| 65 | // Ensure that post type-specific controller logic is available. |
| 66 | $parent_controller_class = ! empty( $post_type_object->rest_controller_class ) ? $post_type_object->rest_controller_class : 'WP_REST_Posts_Controller'; |
| 67 | $parent_controller = new $parent_controller_class( $post_type_object->name ); |
| 68 | } |
64 | 69 | |
65 | | $this->parent_controller = new $parent_controller_class( $post_type_object->name ); |
| 70 | $this->parent_controller = $parent_controller; |
66 | 71 | $this->revisions_controller = new WP_REST_Revisions_Controller( $parent_post_type ); |
67 | 72 | $this->rest_namespace = 'wp/v2'; |
68 | 73 | $this->rest_base = 'autosaves'; |