WordPress.org

Make WordPress Core

Opened 8 weeks ago

Last modified 4 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.5 Priority: normal
Severity: normal Version: 5.3.2
Component: I18N Keywords: has-patch needs-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)

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

Download all attachments as: .zip

Change History (11)

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

  • Component changed from I18N to General

#46387 seems similar.

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

#3 @archon810
7 weeks ago

  • Component changed from General to I18N

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

@SergeyBiryukov
7 weeks ago

#5 @SergeyBiryukov
7 weeks ago

  • Keywords has-patch added

#6 @SeBsZ
7 weeks 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 days ago

#8 @SergeyBiryukov
5 days ago

  • Keywords commit added

#9 @ocean90
5 days ago

  • Keywords needs-unit-tests added; commit removed

#10 @SergeyBiryukov
4 days ago

  • Milestone changed from 5.4 to 5.5
Note: See TracTickets for help on using tickets.