[wp-trac] [WordPress Trac] #56922: Template / Template parts revision / autosave REST API are broken
WordPress Trac
noreply at wordpress.org
Wed Sep 13 15:42:56 UTC 2023
#56922: Template / Template parts revision / autosave REST API are broken
--------------------------------------+-----------------------
Reporter: spacedmonkey | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.4
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses: rest-api
--------------------------------------+-----------------------
Comment (by antonvlasenko):
@spacedmonkey
> Why register late?
The root cause of the issue is that the
`WP_REST_Templates_Controller::get_item()` method is incorrectly matched
as the callback method to handle revisions and autosave requests for the
`wp_template` and `wp_template_part` post types.
Do we agree on this?
If so, the solution would be to register the routes defined in both the
WP_REST_Revisions_Controller and WP_REST_Autosaves_Controller controllers
first.
Then, routes defined in WP_REST_Templates_Controller should be registered
afterward.
This ensures that `WP_REST_Server::match_request_to_handler()` matches
correct routes first.
By doing this, when making a request like `wp/v2/template-
parts/1480/revisions`, the correct request handler is called.
I hope this explanation makes sense.
I provided a more detailed explanation in my previous comment.
> Why not register all post type controllers like this?
The ability to arbitrarily specify custom post type controllers for post
types can be useful.
However, it's unclear to me how this would address the route conflict
mentioned earlier.
My PR should resolve the issue, and it seems no additional PRs are
necessary.
I will be looking forward to hearing your feedback.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56922#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list