Make WordPress Core

Opened 3 years ago

Closed 2 years ago

#54015 closed defect (bug) (fixed)

Unable to pass _embed param to enveloped REST API requests

Reported by: spacedmonkey's profile spacedmonkey Owned by: spacedmonkey's profile spacedmonkey
Milestone: 6.0 Priority: normal
Severity: normal Version: 5.4
Component: REST API Keywords: has-patch has-unit-tests
Focuses: rest-api Cc:

Description

Added in #39696, developers can now selectively embed links. However this value is not passed down the enveloped requests.

Change History (17)

#3 @spacedmonkey
3 years ago

  • Summary changed from Unable to pass _embed param to enveloped requested to Unable to pass _embed param to enveloped REST API requests

#4 follow-up: @johnbillion
3 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to Future Release

Can we get a test for this?

#5 @spacedmonkey
3 years ago

  • Owner set to spacedmonkey
  • Status changed from new to assigned

This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.


2 years ago

#7 in reply to: ↑ 4 @spacedmonkey
2 years ago

Replying to johnbillion:

Can we get a test for this?

I had a look into this and is not easy to add a test here. Lots have to be mocked this change is deeply embed in the serve_request method. I was thinking about somehow exacting the logic, to make easier to test. Thoughts @johnbillion ?

#8 @johnbillion
2 years ago

I'm not surprised to be honest, I remember this from another ticket that touched the _embed parameter.

@TimothyBlynJacobs Thoughts?

#9 @TimothyBlynJacobs
2 years ago

I think we should be able to use expectOutputString and call serve_request after setting $_GET['embed'] to the value we want to test.

#10 @spacedmonkey
2 years ago

@TimothyBlynJacobs I am not sure what you mean there. Any chance you could put together a test for this or point in the direction of one.

#11 @TimothyBlynJacobs
2 years ago

Something along the lines of this:

$this->expectOutputString( 'json body that we expect' );

$_GET['embed'] = 'link';
rest_get_server()->serve_request('/endpoint/to/test');

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


2 years ago
#12

  • Keywords has-unit-tests added; needs-unit-tests removed

#13 @spacedmonkey
2 years ago

I have updated the patch at #2544 with unit tests.

This ticket was mentioned in Slack in #core-restapi by spacedmonkey. View the logs.


2 years ago

TimothyBJacobs commented on PR #2544:


2 years ago
#15

LGTM! Just some minor bits of feedback.

#16 @spacedmonkey
2 years ago

  • Milestone changed from Future Release to 6.0

#17 @spacedmonkey
2 years ago

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

In 53110:

REST API: Use rest_parse_embed_param function in WP_REST_Server class.

Ensure that the value get parameter _embed that is passed to the envelope_response method, is run through the rest_parse_embed_param function.

Props Spacedmonkey, johnbillion, TimothyBlynJacobs.
Fixes #54015.

Note: See TracTickets for help on using tickets.