WordPress.org

Make WordPress Core

Opened 8 months ago

Closed 8 months ago

#38842 closed defect (bug) (fixed)

Current user route redirects without context param in REST API

Reported by: 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 months ago.
Assert context=view by default for GET /wp/v2/users/me

Download all attachments as: .zip

Change History (10)

#1 @ocean90
8 months 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 months ago

  • Keywords needs-unit-tests added

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


8 months ago

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


8 months ago

#5 @jnylen0
8 months 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 months 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 months ago

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

#7 @rachelbaker
8 months ago

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

#8 @rachelbaker
8 months 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 months ago

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