• function untrailingslashit( $string ) {
    	$string = !empty($string) ? rtrim( $string, '/\\' ) : $string;
    	return $string;	
    }

    instead

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

    to stop the warnings. Please, add that in the next version. Tks! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thanks for your suggestion. The core developers do not (often) read the forum, they process changes to the core in a ticket system. If you have specific change recommendations, you are welcome to mention it as a ticket in the core – but there may already be a ticket for the exact spot, have a look: https://core.trac.www.remarpro.com

    Dion

    (@diondesigns)

    The rtrim() function will only throw a warning if either of the parameters are of a type (object, array, etc) that cannot be converted to a string. So your “fix” is not a fix.

    In amy case, I would argue that there is no need for a “fix”. If an array was passed to untrailingslashit(), that’s a serious mistake in someone’s coding, and the PHP warning will assist that individual in debugging.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘rtrim() php 8.1 warning in wp-includes/formatting.php fixing’ is closed to new replies.