Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#38842 closed defect (bug) (fixed)

Current user route redirects without context param in REST API

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

Description

In the REST API, the context param is ignored when trying to reach to current user through wp/v2/users/me. Turns out the route it redirects to wp/v2/users/[id] but misses any given param.

Attachments (1)

38842.1.diff (640 bytes) - added by danielbachhuber 8 years ago.
Assert context=view by default for GET /wp/v2/users/me

Download all attachments as: .zip

Change History (10)

#1 @ocean90
8 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.7
  • Version set to trunk

Hello @edygardelima, welcome to the WordPress Trac!

Thanks for your report, @dd32 had the same question on Slack today.

#2 @rachelbaker
8 years ago

  • Keywords needs-unit-tests added

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


8 years ago

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


8 years ago

#5 @jnylen0
8 years ago

Quoting from the Slack link above - the actual issue here is a bit different now that we're not doing this redirect any more:

Any specific reason /users/1 is context=view while /users/me is context=embed? Causes it to skip at least registered meta fields from the /me response

/me was only a recently addition (used to 301) so it might have been an oversight from then

#6 @danielbachhuber
8 years ago

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

GET /wp/v2/users/me defaults to context=view in trunk.

Attaching a patch that asserts this in the tests. The original report isn't valid.

@danielbachhuber
8 years ago

Assert context=view by default for GET /wp/v2/users/me

#7 @rachelbaker
8 years ago

Looks like the context param was recently fixed as a part of #38792

#8 @rachelbaker
8 years ago

In 39293:

REST API: Add test case for users/me endpoint that the context param defaults to view.

Props danielbachhuber.
See #38842.

#9 @rachelbaker
8 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.