Opened 13 months ago
Closed 12 months ago
#59756 closed defect (bug) (duplicate)
function wp_is_stream() is causing a deprecated error when $path is null.
Reported by: | garymarkfuller | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.3.2 |
Component: | General | Keywords: | php81 reporter-feedback |
Focuses: | Cc: |
Description (last modified by )
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)
#2
@
12 months ago
- Description modified (diff)
- Keywords reporter-feedback added
Is this a duplicate of #57580?
#4
@
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.)
@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 passingnull
towp_is_stream()
. This needs to be fixed at the source of the problem, not in thewp_is_stream()
function.