[wp-trac] [WordPress Trac] #56472: rest_get_route_for_post missing usages in Posts Controller prepare_links method
WordPress Trac
noreply at wordpress.org
Wed Aug 31 08:19:44 UTC 2022
#56472: rest_get_route_for_post missing usages in Posts Controller prepare_links
method
--------------------------+-----------------------------
Reporter: get_dave | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: minor | Keywords:
Focuses: |
--------------------------+-----------------------------
Whilst working on
https://github.com/WordPress/gutenberg/pull/42809#issuecomment-1231875463
we discovered that the function
[`rest_get_route_for_post`](https://developer.wordpress.org/reference/functions/rest_get_route_for_post/)
isn't fully implemented within the `WP_REST_Posts_Controller`.
As this function is filterable this can lead to inconsistencies.
https://developer.wordpress.org/reference/hooks/rest_route_for_post/
To quote:
The rest_get_route_for_post function is filterable. So it can be
modified to use the slug instead of the id. But it looks like we missed
some spots when implementing rest_get_route_for_post, like in
prepare_links, so that will need to be addressed in a Core ticket.
Examples include:
- https://github.com/WordPress/wordpress-
develop/blob/97218bbfd336035edc9293274fea0f7bd3da85d7/src/wp-includes
/rest-api/endpoints/class-wp-rest-posts-controller.php#L1991
- https://github.com/WordPress/wordpress-
develop/blob/97218bbfd336035edc9293274fea0f7bd3da85d7/src/wp-includes
/rest-api/endpoints/class-wp-rest-posts-controller.php#L2024
- https://github.com/WordPress/wordpress-
develop/blob/97218bbfd336035edc9293274fea0f7bd3da85d7/src/wp-includes
/rest-api/endpoints/class-wp-rest-posts-controller.php#L2032
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56472>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list