Make WordPress Core

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#60046 closed defect (bug) (duplicate)

Passing null to parameter #1 ($haystack) of type string is deprecated in\wp-includes\functions.php on line 7244

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

Description

When null is passed to wp_is_stream() it causes a deprecated warning, this is easily fixed with some type checking like so:

function wp_is_stream( $path = '' ) {

  if ( !$path || !is_string( $path ) )
  {
    // $path cannot be a stream if it's not a string
    return false;
  }

  $scheme_separator = strpos( $path, '://' );

  if ( false === $scheme_separator ) {
	// $path isn't a stream.
	return false;
  }

  $stream = substr( $path, 0, $scheme_separator );

  return in_array( $stream, stream_get_wrappers(), true );
}

Change History (2)

#1 @sabernhardt
15 months ago

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

Hi and welcome to WordPress Core Trac!

The deprecation warnings for wp_is_stream() and wp_normalize_path() were already reported on #57580 and #57581 (plus #58104 and #59756). Both functions have required a string since they were created, so plugin authors need some message to know when and how their plugin is doing it wrong. The decision on #57580 and #57581 was to keep those deprecated warnings.

#2 @sabernhardt
15 months ago

I would like to know which function is used incorrectly, especially if the mistake is within Core or if all similar reports consistently point to plugins using a wrong type in the same add_submenu_page() function.

If you could determine which function or which plugin causes the error, please share the information on #57580. (I am not yet sure about reopening that ticket, but you can comment while it is still closed.)

Note: See TracTickets for help on using tickets.