[wp-trac] [WordPress Trac] #61268: PHP Deprecated: ltrim() in formatting esc_url.

WordPress Trac noreply at wordpress.org
Wed May 22 13:10:24 UTC 2024


#61268: PHP Deprecated:  ltrim() in formatting esc_url.
--------------------------+-----------------------------
 Reporter:  neo2k23       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I am getting constant these warnings in my error log file.

 [22-May-2024 13:00:43 UTC] PHP Deprecated:  ltrim(): Passing null to
 parameter #1 ($string) of type string is deprecated in /home//public_html
 /wp-includes/formatting.php on line 4482

 it is caused by this code


 {{{#!php
 <?php
         $original_url = $url;

         if ( '' === $url ) {
                 return $url;
         }

         $url = str_replace( ' ', '%20', ltrim( $url ) );

 }}}

 The last line is line 4482

 If i change line 4478 to this  it does not happen anymore.


 {{{#!php
 <?php
         $original_url = $url;

         if ( '' === $url  || empty ($url)) {
                 return $url;
         }

         $url = str_replace( ' ', '%20', ltrim( $url ) );
 }}}


 Since any information is missing on the location which is calling esc_url
 it is hard to debug which theme code or plugin code is responsible for
 this.

 Can someone please explain to mewhat is going on here?

 Thank you

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


More information about the wp-trac mailing list