Make WordPress Core

#63102 closed defect (bug) (fixed)

Remove extra slashes when concatenating ABSPATH with a path, take 2

Reported by: SergeyBiryukov Owned by: SergeyBiryukov
Priority: low Milestone: 6.8
Component: General Version:
Severity: minor Keywords: good-first-bug has-patch
Cc: Focuses: coding-standards

Description

Previously: [54872] / #57074.

There are a few of these lines in core:

require_once ABSPATH . '/wp-admin/includes/file.php';
...
require_once ABSPATH . '/wp-admin/includes/plugin.php';

For consistency with the rest of core, the slash before wp-admin can be removed:

require_once ABSPATH . 'wp-admin/includes/file.php';
...
require_once ABSPATH . 'wp-admin/includes/plugin.php';

as ABSPATH already includes a trailing slash.

Change History (2)

This ticket was mentioned in PR #8518 on WordPress/wordpress-develop by @dhruvik18.


18 months ago
#1

  • Keywords has-patch added; needs-patch removed

This PR removes the leading slash from paths that are concatenated with ABSPATH. Since ABSPATH already includes a trailing slash, adding another slash creates unnecessary double slashes and is inconsistent with most of the WordPress core.

Trac ticket: https://core.trac.wordpress.org/ticket/63102

#2 @SergeyBiryukov
18 months ago

  • Owner set to SergeyBiryukov
  • Resolutionfixed
  • Status newclosed

In 60034:

Coding Standards: Remove extra slashes when concatenating ABSPATH with a path.

Since ABSPATH is defined and documented to end with a forward slash /, this changeset removes the first / from strings appended to ABSPATH in various files, leading to // in the resulting path.

Follow-up to [54872], [55720], [57545].

Props dhruvik18, SergeyBiryukov.
Fixes #63102.

Note: See TracTickets for help on using tickets.