Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#42452 closed defect (bug) (fixed)

filter_rest_url_for_leading_slash assertion is broken

Reported by: rmccue Owned by: rmccue
Priority: normal Milestone: 5.0
Component: REST API Version: 4.4
Severity: normal Keywords: has-patch commit
Cc: Focuses:

Description

This is originally from https://github.com/WP-API/WP-API/issues/2424

The test checks if rest_url() was called with a leading slash and fails if it wasn't. This is broken because WordPress core itself calls rest_url() with no leading slashes in a few places (notably, WP_REST_Posts_Controller::prepare_links).

This is never surfaced in core, because the test only fails if permalink_structure is set, which it isn't in the tests. Third-party tests which use this base class and which set a permalink structure will fail (unless they're on multisite, in which case the test is bypassed anyway).

Attachments (1)

42452.patch (2.2 KB ) - added by anonymized_8769252 9 years ago.

Download all attachments as: .zip

Change History (6)

#1 @anonymized_8769252
9 years ago

  • Keywords has-patch added; needs-patch removed

#2 @rmccue
9 years ago

  • Keywords commit added
  • Milestone Awaiting Review5.0
  • Owner set to rmccue
  • Status newreviewing
  • Version4.4

#3 @rmccue
9 years ago

  • Resolutionfixed
  • Status reviewingclosed

In 42250:

REST API: Ensure rest_url() consistently has leading slash.

rest_url() inconsistent addes slashes to the passed path depending on whether the site has pretty permalinks enabled. Apart from being inconsistent, this also caused the unit tests to fail when pretty permalinks are enabled.

Props frank-klein.
Fixes #42452. See #41451.

#4 @SergeyBiryukov
8 years ago

  • Resolution fixed
  • Status closedreopened

[42250] should be backported to the 5.0 branch.

#5 @danielbachhuber
8 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 43766:

REST API: Ensure rest_url() consistently has leading slash.

rest_url() inconsistent addes slashes to the passed path depending on whether the site has pretty permalinks enabled. Apart from being inconsistent, this also caused the unit tests to fail when pretty permalinks are enabled.

Props frank-klein.
Merges [42250] to the 5.0 branch.
Partially reverts [43720].
Fixes #42452. See #41451, #45017.

Note: See TracTickets for help on using tickets.