Make WordPress Core

Opened 8 years ago

Closed 5 years ago

#41411 closed defect (bug) (fixed)

REST API: Terms endpoint responses for PUT & POST requests don't set context to edit

Reported by: westonruter's profile westonruter Owned by: kadamwhite's profile kadamwhite
Milestone: 5.3 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description

The endpoints for posts, users, and comments all set the context to edit when returning the resource in the response for POST and PUT requests. The terms endpoint, however, unexpectedly returns the resource with the view context. In practice this won't cause a problem since all of the fields (in core) have both the view and edit contexts, but if a plugin adds additional fields that should only appear in the edit context then this could cause a problem where the unexpected fields would be returned in the response.

Attachments (3)

41411.0.diff (935 bytes) - added by westonruter 8 years ago.
41411.1.diff (2.8 KB) - added by dlh 5 years ago.
41411.2.diff (2.8 KB) - added by dlh 5 years ago.

Download all attachments as: .zip

Change History (14)

@westonruter
8 years ago

#1 @westonruter
8 years ago

  • Keywords has-patch added

#2 @rmccue
7 years ago

  • Keywords needs-unit-tests added

lgtm, we should add unit tests to check this though.

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


5 years ago

#4 @kadamwhite
5 years ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to kadamwhite
  • Status changed from new to assigned

Accepting for 5.3 as a quick win. I'll look into writing up a test.

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


5 years ago

@dlh
5 years ago

#6 @dlh
5 years ago

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

41411.1.diff adds a test.

#7 @TimothyBlynJacobs
5 years ago

This looks good to me. The test needs to use traditional array syntax though. I'd also use assertArrayHasKey and assertArrayNotHasKey instead of assertTrue( isset ).

@dlh
5 years ago

#8 @dlh
5 years ago

Great catch and great suggestions. Updated in 41411.2.diff.

#9 @TimothyBlynJacobs
5 years ago

  • Keywords commit added

Looks good!

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


5 years ago

#11 @kadamwhite
5 years ago

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

In 46098:

REST API: Return term resources in "edit" context after PUT or POST request.

Props westonruter, dlh.
Fixes #41411.

Note: See TracTickets for help on using tickets.