#55967 closed defect (bug) (fixed)
Scripts: Ensure path for JavaScript translations is always a string
Reported by: | ocean90 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Script Loader | Keywords: | has-patch php81 |
Focuses: | Cc: |
Description
With PHP 8.1 a few rtrim(): Passing null to parameter #1 ($string) of type string is deprecated
notices are visible. These have been previously reported in #55411 and #55119 but a separate ticket for this seems to be better so it doesn't get lost again.
The notice is triggered by passing null
as the path value for load_script_textdomain()
which passes the value to untrailingslashit()
which then calls rtrim()
on null.
A patch was already submitted by @Chouby in #53635, see 53635-09-script-translations.patch:ticket:53635.
Related: #55656
Change History (19)
This ticket was mentioned in PR #2801 on WordPress/wordpress-develop by ocean90.
2 years ago
#1
- Keywords has-patch added
2 years ago
#5
Thanks for pointing out this ticket.
Please be aware that for PHP 8.1 (which "continues on error", so issues often go unnoticed), two calls to expectDeprecation()
will need to be removed.
I'd also like to suggest adding tests to cover this change.
For both, see PR #3186. You could probably cherrypick the test changes from that PR (and then add some more tests yourself for the other affected functions 😇 )
#6
@
2 years ago
@ocean90 How can we move this forward ? Either your patch or mine (or a combination of the two) needs to be committed soonish, as it is a prerequisite for getting the PHP 8.1 build to pass.
SergeyBiryukov commented on PR #2801:
2 years ago
#9
Thanks for the PR! Merged in r54349.
2 years ago
#10
@SergeyBiryukov Is it just me or are some of the changes from this PR missing from the commit ?
SergeyBiryukov commented on PR #2801:
2 years ago
#12
Is it just me or are some of the changes from this PR missing from the commit ?
Ah yes, you're right. I went back and forth on whether to make two separate commits or combine them, chose the latter option, but then forgot to include these files. Will do a follow-up commit shortly. Thanks for flagging this!
2 years ago
#13
Appreciated @SergeyBiryukov !
When the other changes from this PR will be committed, then the change from my PR to the `src/wp-includes/l10n.php` file can be removed.
SergeyBiryukov commented on PR #2801:
2 years ago
#14
When the other changes from this PR will be committed, then the change from my PR to the `src/wp-includes/l10n.php` file can be removed.
I thought that's still a good change to include just in case a non-string $path
is passed to the function, but happy to remove if that's preferred 🙂
2 years ago
#15
When the other changes from this PR will be committed, then the change from my PR to the `src/wp-includes/l10n.php` file can be removed.
I thought that's still a good change to include just in case a non-string
$path
is passed to the function, but happy to remove if that's preferred 🙂
The problem is that it would _hide_ an error which should be _fixed_ (at the source of the problem) instead.
SergeyBiryukov commented on PR #2801:
2 years ago
#17
Merged the remaining changes in r54351. Thanks again!
Based on https://core.trac.wordpress.org/attachment/ticket/53635/53635-09-script-translations.patch.
Trac ticket: https://core.trac.wordpress.org/ticket/55967