Make WordPress Core

#60047 closed defect (bug) (duplicate)

Passing null to parameter #3 ($subject) of type array|string is deprecated in wp-includes\functions.php on line 2187

Reported by: sander-falise's profile Sander Falise Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Filesystem API Keywords: has-patch
Focuses: Cc:

Description

Passing non string values to wp_normalize_path() causes a deprecated warning, this can easily be fixed by adding some type checking:

function wp_normalize_path( $path = '' ) {

  if ( !$path || !is_string( $path ))
  {
    $path = '';
  }

  $wrapper = '';

  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 );
  }
}	

Change History (1)

#1 @sabernhardt
12 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #57581.

Note: See TracTickets for help on using tickets.