WordPress.org

Make WordPress Core

Opened 8 days ago

Last modified 7 days ago

#48242 new enhancement

Deprecate wp_parse_url() in favour of native parse_url()

Reported by: johnbillion Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.2
Component: General Keywords: needs-patch needs-unit-tests
Focuses: coding-standards Cc:
PR Number:

Description

The wp_parse_url() function exists to handle inconsistencies in the return value of PHP's native parse_url() function across different versions of PHP.

According to its inline docs:

PHP 5.4.7 expanded parse_url()'s ability to handle non-absolute url's, including schemeless and relative url's with :// in the path. This function works around those limitations providing a standard output on PHP 5.2~5.4+.

Error suppression is used as prior to PHP 5.3.3, an E_WARNING would be generated when URL parsing failed.

Now that core only supports PHP 5.6+, it should be possible to deprecate this function and replace usage of it with the native parse_url() function. However, to ensure that nothing breaks we'll need tests which determines that parse_url() functions identically to wp_parse_url() on PHP 5.6 and above.

Change History (3)

#1 @afragen
7 days ago

Yes, please.

#2 @ayeshrajans
7 days ago

A couple weeks ago, I did try to short-circuit wp_parse_url() by immediately passing it to parse_url(). (https://github.com/Ayesh/wordpress-develop/commit/7cf2ad95c260).

One test fails in PHP 5.6 and 5.6 alone: https://travis-ci.org/Ayesh/wordpress-develop/jobs/587819504#L2697

I suppose we need the same tests passed (which would be a BC otherwise), plus some extra tests to make sure the error suppression has gone away. I will work on patches in coming days.

#3 @ayeshrajans
7 days ago

The PHP 5.6 test failure is because until PHP 7.0.22, PHP detected a colon in the query string as a port number. See https://bugs.php.net/bug.php?id=74780.

Note: See TracTickets for help on using tickets.