[wp-trac] [WordPress Trac] #56808: adding null coalescing operator for rtrim function to avoid deprecation

WordPress Trac noreply at wordpress.org
Wed Oct 12 07:00:46 UTC 2022


#56808: adding null coalescing operator for rtrim function to avoid deprecation
-------------------------+---------------------------------------------
 Reporter:  asifmuztaba  |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  6.0.2
 Severity:  normal       |   Keywords:  changes-requested needs-testing
  Focuses:               |
-------------------------+---------------------------------------------
 There was a warning showing
 {{{
 Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string
 is deprecated in /var/www/html/wordpress/wordpress/wp-
 includes/formatting.php on line 2872
 }}}

 The rtrim function 1st parameter value as null is deprecated in php 8.1.
 It can be fixed by adding
 {{{
 null coalescing
 }}}
  operator.

 {{{
 function untrailingslashit( $string ) {
         return rtrim( $string ?? '', '/\\' );
 }
 }}}

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


More information about the wp-trac mailing list