Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#45169 closed defect (bug) (fixed)

Clarify the discrepancy between the default $scheme values in rest_url() and get_rest_url()

Reported by: drewapicture's profile DrewAPicture Owned by: kadamwhite's profile kadamwhite
Milestone: 5.3 Priority: normal
Severity: normal Version: 4.4
Component: REST API Keywords: has-patch
Focuses: docs Cc:

Description

As pointed out by a user on the code reference, rest_url() and get_rest_url() both define different defaults for the $scheme parameters. rest_url() defaults to 'json', and get_rest_url() to 'rest', respectively.

It would be good to provide notices in both DocBlocks explaining the discrepancy.

Attachments (1)

45169.1.diff (705 bytes) - added by kadamwhite 5 years ago.

Download all attachments as: .zip

Change History (9)

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


5 years ago

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


5 years ago

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


5 years ago

#4 @kadamwhite
5 years ago

Update on out-of-band discussion: @rmccue has advocated we standardize on json as rest_url is called in more places. This would make this a functional change in addition to a docs change; while this has a small chance of introducing breaking behavior if somebody is hooking into filters and expecting the other value, our existing inconsistency makes it unlikely this is being used many places. I'll attempt to validate that to make sure we're not ignoring a real potential concern.

@kadamwhite
5 years ago

#5 @kadamwhite
5 years ago

  • Keywords has-patch added; needs-patch removed
  • Owner set to kadamwhite
  • Status changed from new to accepted

Update on the previous update: after further investigation it turns out this occurrence of json was missed in #34300, and rest is the "correct" term. Some digging through the plugin directory did not immediately highlight anywhere this would introduce backwards compatibility issues, so I'm uploading a patch which changes the 'json' string to 'rest'.

This ticket was mentioned in Slack in #docs by kadamwhite. View the logs.


5 years ago

#7 @kadamwhite
5 years ago

  • Milestone changed from Awaiting Review to 5.3

#8 @kadamwhite
5 years ago

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

In 46233:

REST API: Consistently default URL scheme to "rest", not "json".

The "json" scheme is a holdover from the pre-merge plugin version of the REST API, and was corrected elsewhere in core in [34300]. Only "rest" is officially supported in set_url_scheme().

Props DrewAPicture, rmccue.
Fixes #45169.

Note: See TracTickets for help on using tickets.