Make WordPress Core

#59756 closed defect (bug) (duplicate)

function wp_is_stream() is causing a deprecated error when $path is null.

Reported by: garymarkfuller's profile garymarkfuller Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.3.2
Component: General Keywords: php81 reporter-feedback
Focuses: Cc:

Description (last modified by sabernhardt)

Apologies in advance for my first bug report...

The function wp_is_stream() is causing the error below on my test environment:

PHP Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /.../wp-includes/functions.php on line 7127

Locally I altered the function to resolve the error as per the code below:

function wp_is_stream( $path ) {
	if($path === null) {
		$scheme_separator = false;
	} else {
		$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 (4)

#1 @jrf
13 months ago

  • Focuses php-compatibility removed
  • Keywords php81 added

@garymarkfuller Thanks for reporting this. This issue will need a backtrace to figure out where the error is coming from.

The wp_is_stream() function is documented as only accepting a string and the error you are reporting means something somewhere is passing null to wp_is_stream(). This needs to be fixed at the source of the problem, not in the wp_is_stream() function.

#2 @sabernhardt
12 months ago

  • Description modified (diff)
  • Keywords reporter-feedback added

Is this a duplicate of #57580?

#3 @jrf
12 months ago

@sabernhardt I think you're right.

#4 @sabernhardt
12 months ago

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

I'll close this. However, 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.