#1 closed defect (bug) (fixed)
Handle https:// when manipulating 'home'
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | minor | Version: | |
| Component: | General | Keywords: | has-patch |
| Focuses: | Cc: |
Description (last modified by )
This:
preg_replace('|https?://[^/]+|i', '', get_settings('home') . '/' )
Instead of this:
preg_replace('|http://[^/]+|i', '', get_settings('home') . '/' )
Change History (11)
This ticket was mentioned in PR #8764 on WordPress/wordpress-develop by @shanemac10.
7 months ago
#9
- Keywords has-patch added
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.
Incoming updated version:
function untrailingslashit( $value ) {
return rtrim( strval( $value ), '/\\' ); // <-- Cast $value to String with strval()
}
Previous unvalidated version:
function untrailingslashit( $value ) {
return rtrim( $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
Trac ticket: 63379 Fix for deprecated rtrim passing null to parameter
This ticket was mentioned in PR #8765 on WordPress/wordpress-develop by @shanemac10.
7 months ago
#10
Fixes errors like the following:
Deprecated: rtrim(): Passing null to parameter 1 ($string) of type string is deprecated in /wp-includes/formatting.php on line 2819
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.
Incoming updated version:
function untrailingslashit( $value ) {
return rtrim( strval( $value ), '/\\' ); // <-- Cast $value to String with strval()
}
Previous unvalidated version:
function untrailingslashit( $value ) {
return rtrim( $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
Trac ticket: 63379 Fix for deprecated rtrim passing null to parameter
#11
@
6 weeks ago
preg_replace('|https?:[/]+|i', , get_settings('home') . '/');
✅ Explanation of the Fix
https?: → matches both http:// and https://

[/]+ → matches the domain name portion (anything up to the next /)
The rest of the function logic remains the same, ensuring compatibility with both secure and non-secure WordPress installations.
http://wordpress.org/pipermail/cvs_wordpress.org/2004-June/000092.html