Make WordPress Core

Opened 23 months ago

Closed 23 months ago

Last modified 23 months ago

#56472 closed defect (bug) (fixed)

rest_get_route_for_post missing usages in Posts Controller prepare_links method

Reported by: get_dave's profile get_dave Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 6.1 Priority: normal
Severity: minor Version: 5.5
Component: REST API Keywords: has-patch
Focuses: Cc:


Whilst working on we discovered that the function [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.

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:

Change History (11)

#1 @TimothyBlynJacobs
23 months ago

  • Milestone changed from Awaiting Review to 6.1
  • Owner set to TimothyBlynJacobs
  • Status changed from new to assigned
  • Version set to 5.5

This ticket was mentioned in PR #3179 on WordPress/wordpress-develop by spacedmonkey.

23 months ago

  • Keywords has-patch added

spacedmonkey commented on PR #3179:

23 months ago

@getdave Can you take a look

#4 @get_dave
23 months ago

  • Resolution set to worksforme
  • Status changed from assigned to closed

I tested this by checking out which modifies the route for wp_navigation. I then made a REST for a single Navigation post by slug.

I received the following which indicates that these changes are 👍

spacedmonkey commented on PR #3179:

23 months ago

@getdave Do you want this in 6.0.x?

getdave commented on PR #3179:

23 months ago

@getdave Do you want this in 6.0.x?

I think it would be fine for 6.1.

spacedmonkey commented on PR #3179:

23 months ago

@TimothyBJacobs Can you take a look a this please. Happy to commit.

TimothyBJacobs commented on PR #3179:

23 months ago

I'm also seing usages in WP_REST_Posts_Controller::create_item for the Location header. We can also use rest_get_route_for_post_type_items in WP_REST_Posts_Controller::get_items when preparing the pagination links.

#9 @SergeyBiryukov
23 months ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Hi there, thanks for the ticket!

Reopening, as it looks like the PR has not been committed yet, so the closing in comment:4 appears to be unintentional.

See The Bug Tracker (Trac) for ticket resolution descriptions:

worksforme: The bug reported in the ticket cannot be reproduced. Sometimes, an existing plugin, hook, or feature may render the ticket moot, so the ticket can be closed without further action.

#10 @TimothyBlynJacobs
23 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 54121:

REST API: Use helper functions for building routes in more places.

Props get_dave, spacedmonkey.
Fixes #56472.

TimothyBJacobs commented on PR #3179:

23 months ago

Merged in da03cf1c6b3ab71ea7e56f4a050d87c41150726e.

Note: See TracTickets for help on using tickets.