WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 15 months ago

#42452 closed defect (bug) (fixed)

filter_rest_url_for_leading_slash assertion is broken

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

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 Frank Klein 2 years ago.

Download all attachments as: .zip

Change History (6)

@Frank Klein
2 years ago

#1 @Frank Klein
2 years ago

  • Keywords has-patch added; needs-patch removed

#2 @rmccue
2 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 5.0
  • Owner set to rmccue
  • Status changed from new to reviewing
  • Version set to 4.4

#3 @rmccue
2 years ago

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

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
15 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

[42250] should be backported to the 5.0 branch.

#5 @danielbachhuber
15 months ago

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

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.