[wp-trac] [WordPress Trac] #59757: Function wp_normalize_path() is causing a deprecated error when $path is null.
WordPress Trac
noreply at wordpress.org
Fri Oct 27 12:53:29 UTC 2023
#59757: Function wp_normalize_path() is causing a deprecated error when $path is
null.
-------------------------------+-----------------------------
Reporter: garymarkfuller | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 6.3.2
Severity: normal | Keywords:
Focuses: php-compatibility |
-------------------------------+-----------------------------
The function wp_normalize_path() is causing the error below on my test
environment:
PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of
type array|string is deprecated in /home/gary/bailey-head/wordpress/wp-
includes/functions.php on line 2182
Locally I altered the function to resolve the error as per the code below:
{{{
function wp_normalize_path( $path ) {
$wrapper = '';
if(!empty($path)) {
if ( wp_is_stream( $path ) ) {
list( $wrapper, $path ) = explode( '://', $path, 2
);
$wrapper .= '://';
}
// Standardize all paths to use '/'.
$path = str_replace( '\\', '/', $path );
// Replace multiple slashes down to a singular, allowing
for network shares having two slashes.
$path = preg_replace( '|(?<=.)/+|', '/', $path );
// Windows paths should uppercase the drive letter.
if ( ':' === substr( $path, 1, 1 ) ) {
$path = ucfirst( $path );
}
}
return $wrapper . $path;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59757>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list