#49145 closed defect (bug) (fixed)
Undefined index: host in/wp-includes/l10n.php on line 989, suggested fix
Reported by: | SeBsZ | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.6 | Priority: | normal |
Severity: | normal | Version: | 5.3.2 |
Component: | I18N | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
We're using WordPress 5.3.2 and I'm getting a lot of notices: "Notice: Undefined index: host" in l10n.php on line 989:
} elseif ( ! isset( $src_url['host'] ) || $src_url['host'] === $site_url['host'] ) {
The cause in our case, is that $site_url does not have a 'host' index. I'd like to suggest that instead of only checking whether
$src_url['host']
is set, also check whether $site_url['host']
is set.
We have a filter on site_url() which makes all URLs relative. This is what causes 'host' not to be set. Regardless of the cause though, I don't think l10n.php should generate a notice in this case.
Attachments (1)
Change History (23)
#1
@
5 years ago
- Component changed from General to I18N
- Milestone changed from Awaiting Review to 5.4
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#4
@
5 years ago
@SergeyBiryukov Think you can target 5.4 for this one? It's the #1 issue that keeps pinging our Sentry by a huge margin.
#6
@
5 years ago
I've tested the patch, and can confirm the PHP Notice is gone. I can't vouch for the correctness of the implementation though, as I didn't look into the inner workings. Thanks for the quick response @SergeyBiryukov, looking forward to seeing this released.
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
5 years ago
#11
@
4 years ago
- Milestone changed from 5.5 to 5.6
This still needs tests, and I'm not quite sure the patch is correct as is.
Moving to 5.6 for a closer look.
This ticket was mentioned in Slack in #core by justinahinon. View the logs.
4 years ago
#15
follow-up:
↓ 17
@
4 years ago
The initial patch proposed by Sergey still needs a look.
@nourma proposed to work on it during yesterday's i18n bug scrub.
And I can write the unit tests when ready.
This ticket was mentioned in Slack in #core by nourma. View the logs.
4 years ago
#17
in reply to:
↑ 15
@
4 years ago
Replying to justinahinon:
The initial patch proposed by Sergey still needs a look.
@nourma proposed to work on it during yesterday's i18n bug scrub.
And I can write the unit tests when ready.
I am unable to duplicate the undefined index in l10n.php
. When I use wp_make_link_relative
to filter site_url
to make URLs relative, I get undefined indexes in theme.php
(lines 3479 & 3544), class-wp-customize-manager.php
(line 4598), and http.php
(lines 421 and 422). In each case, a function is trying to access $admin_origin['host']
, which has no host
index. On a side note, I was able to successfully apply the patch 49145.diff (but obviously was unable to test that it actually solved the problem, since I was unable to replicate the error in l10n.php
). I applied the patch on the latest build WordPress 5.6.
This ticket was mentioned in PR #678 on WordPress/wordpress-develop by hellofromtonya.
4 years ago
#18
- Keywords has-unit-tests added; needs-unit-tests removed
Trac ticket: https://core.trac.wordpress.org/ticket/49145
- Applies 49145.diff patch by @SergeyBiryukov
- Refactors tests to use data provider
- Adds test cases for no "host".
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
4 years ago
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
4 years ago
hellofromtonya commented on PR #678:
4 years ago
#22
Merged in changeset https://core.trac.wordpress.org/changeset/49639
#46387 seems similar.