[wp-trac] [WordPress Trac] #63379: Fix for deprecated rtrim passing null to parameter
WordPress Trac
noreply at wordpress.org
Thu May 1 15:30:49 UTC 2025
#63379: Fix for deprecated rtrim passing null to parameter
-------------------------------+-----------------------------
Reporter: shanemac10 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Formatting | Version: 6.8
Severity: normal | Keywords:
Focuses: php-compatibility |
-------------------------------+-----------------------------
The **untrailingslashit** function in **formatting.php** passes the
**$value** param directly into the PHP **rtrim** function, which only
takes **Strings**. Anything else trows a "Deprecated" warning (example
below).
In my personal case, Yoast SEO was the culprit in the stacktrace, but this
**untrailingslashit** should at least validate and/or cast the **$value**
param to String with **strval** before calling **rtrim**.
{{{#!php
<?php
function untrailingslashit( $value ) {
return rtrim( strval( $value ), '/\\' );
}
}}}
Fixes these types of errors:
**Deprecated: rtrim(): Passing null to parameter #1 ($string) of type
string is deprecated in /wp-includes/formatting.php on line 2819**
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63379>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list