Make WordPress Core

Opened 7 months ago

Last modified 2 months ago

#53553 new defect (bug)

strpos(): Empty needle in /wp-includes/l10n.php on line 1047

Reported by: gwviger Owned by:
Milestone: 6.0 Priority: normal
Severity: normal Version: 5.7.2
Component: I18N Keywords: has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

There was a previous ticket for a similar problem #46387 that was resolved but a similar issue has appeared on line 1047 of /wp-includes/l10n.php. Existed in 5.6.x. Still exists in 5.7.2.

Seems problem shows up when wp-config.php includes:


Issue: $content_url is returned as empty string "". strpos() creates notice on empty value as needle.

Current Code:

if (
                ( ! isset( $content_url['path'] )  || strpos( $src_url['path'], $content_url['path'] ) === 0 ) &&
                ( ! isset( $src_url['host'] ) || ! isset( $content_url['host'] ) || $src_url['host'] === $content_url['host'] )

Fix is to add

||  empty($content_url['path'])

Fixed code:

if (
                ( ! isset( $content_url['path'] ) || empty($content_url['path']) || strpos( $src_url['path'], $content_url['path'] ) === 0 ) &&
                ( ! isset( $src_url['host'] ) || ! isset( $content_url['host'] ) || $src_url['host'] === $content_url['host'] )

Change History (2)

#1 @SergeyBiryukov
7 months ago

  • Component changed from General to I18N
  • Description modified (diff)
  • Milestone changed from Awaiting Review to 5.9

Hi there, welcome to WordPress Trac! Thanks for the report.

This also seems similar to #49145 (fixed in [49639] for 5.6).

Seems problem shows up when wp-config.php includes:


Just noting that this line sets WP_CONTENT_URL to an empty value due to incorrect quotes, these should be straight single quotes instead of ‘curly’ quotes:


It also causes a warning in PHP 7.2+:

Warning: Use of undefined constant ‘HTTP_HOST’ - assumed '‘HTTP_HOST’' (this will throw an Error in a future version of PHP)

And a fatal error on PHP 8:

Fatal error: Uncaught Error: Undefined constant "‘HTTP_HOST’"

Fixing the quotes should remove the notice, though I wonder if an empty WP_CONTENT_URL could cause other issues elsewhere, and whether this notice in load_script_textdomain() is currently the only indicator that something is wrong, in which case it might be helpful for debugging. Moving to 5.9 for investigation.

#2 @desrosj
2 months ago

  • Milestone changed from 5.9 to 6.0

This hasn't received any attention during the 5.9 cycle, so I'm punting to 6.0.

Note: See TracTickets for help on using tickets.