[wp-trac] [WordPress Trac] #59756: function wp_is_stream() is causing a deprecated error when $path is null.

WordPress Trac noreply at wordpress.org
Fri Oct 27 12:45:35 UTC 2023


#59756: function wp_is_stream() 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  |
-------------------------------+-----------------------------
 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 /home/gary/bailey-head/wordpress/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 );
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59756>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list