Make WordPress Core

Opened 7 months ago

Last modified 12 days ago

#49145 reviewing defect (bug)

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 needs-unit-tests
Focuses: Cc:


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)

49145.diff (1.6 KB) - added by SergeyBiryukov 7 months ago.

Download all attachments as: .zip

Change History (12)

#1 @SergeyBiryukov
7 months 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

#2 @archon810
7 months ago

  • Component changed from I18N to General

#46387 seems similar.

Last edited 7 months ago by SergeyBiryukov (previous) (diff)

#3 @archon810
7 months ago

  • Component changed from General to I18N

#4 @archon810
7 months 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.

#5 @SergeyBiryukov
7 months ago

  • Keywords has-patch added

#6 @SeBsZ
7 months 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.

6 months ago

#8 @SergeyBiryukov
6 months ago

  • Keywords commit added

#9 @ocean90
6 months ago

  • Keywords needs-unit-tests added; commit removed

#10 @SergeyBiryukov
5 months ago

  • Milestone changed from 5.4 to 5.5

#11 @SergeyBiryukov
12 days 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.

Note: See TracTickets for help on using tickets.