Make WordPress Core

#56808 closed enhancement (duplicate)

adding null coalescing operator for rtrim function to avoid deprecation

Reported by: asifmuztaba's profile asifmuztaba Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

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 ?? '', '/\\' );
}

Attachments (1)

Screenshot_17.png (112.5 KB) - added by asifmuztaba 18 months ago.
Warning Screenshot

Download all attachments as: .zip

Change History (2)

@asifmuztaba
18 months ago

Warning Screenshot

#1 @ocean90
18 months ago

  • Keywords changes-requested needs-testing removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 6.0.2 deleted

Hello @asifmuztaba, welcome to WordPress Trac! Thanks for the report, this has been fixed in [54349] already. Marking as a duplicate of #54997 and #55967.

Note: See TracTickets for help on using tickets.