[wp-trac] [WordPress Trac] #60046: Passing null to parameter #1 ($haystack) of type string is deprecated in\wp-includes\functions.php on line 7244

WordPress Trac noreply at wordpress.org
Mon Dec 11 10:03:28 UTC 2023


#60046: Passing null to parameter #1 ($haystack) of type string is deprecated in
\wp-includes\functions.php on line 7244
---------------------------+-----------------------------
 Reporter:  Sander Falise  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Media          |    Version:  6.4.2
 Severity:  minor          |   Keywords:  has-patch
  Focuses:                 |
---------------------------+-----------------------------
 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 );
 }
 }}}

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


More information about the wp-trac mailing list