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

WordPress Trac noreply at wordpress.org
Mon Dec 11 20:24:47 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                   |  Resolution:
 Keywords:  php81 reporter-feedback  |     Focuses:
-------------------------------------+------------------------------
Changes (by sabernhardt):

 * keywords:  php81 => php81 reporter-feedback


Old description:

> 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 );
> }
> }}}

New description:

 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 );
 }
 }}}

--

Comment:

 Is this a duplicate of #57580?

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


More information about the wp-trac mailing list