WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 4 months ago

#46387 closed defect (bug) (fixed)

Undefined index notice in wp-includes/l10n.php on line 950

Reported by: tditlu Owned by: ocean90
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.0
Component: I18N Keywords: has-patch
Focuses: Cc:
PR Number:

Description

If WP_CONTENT_URL is set to a root path e.g. http://example.com not http://example.com/wp-content (Which boilerplate frameworks like Bedrock & WordPlate do), the return object from wp_parse_url doesn't include a path value.

Adding a check if path is set in load_script_textdomain after wp_parse_url would solve this issue:

// Added to wp-includes/l10n.php, line 947
if ( empty( $content_url['path'] ) ) {
    $content_url['path'] = '/';
}

Related to these issues:
https://github.com/WordPress/gutenberg/issues/12670
https://github.com/wordplate/wordplate/issues/221

Attachments (3)

46387.diff (0 bytes) - added by odminstudios 6 months ago.
46387.2.diff (0 bytes) - added by odminstudios 6 months ago.
46387.3.diff (508 bytes) - added by odminstudios 6 months ago.

Download all attachments as: .zip

Change History (12)

#1 @swissspidy
9 months ago

  • Component changed from Cron API to I18N

#2 @SergeyBiryukov
8 months ago

#46672 was marked as a duplicate.

#3 @tditlu
6 months ago

Is there anything I could do to speed up implementing this fix?

@odminstudios
6 months ago

#4 @odminstudios
6 months ago

  • Keywords has-patch added
  • Version set to trunk

Added a check if $content_urlpath? exists.
This should solve issues when content_url() returns no paths.

Please use 46387.3.diff, previous 2 are empty

#5 @Shelob9
6 months ago

I had this issue on a local site using localhost url. I applied https://core.trac.wordpress.org/attachment/ticket/46387/46387.3.diff from @odminstudios The notice was no longer present after applying patch.

#6 @SergeyBiryukov
6 months ago

  • Milestone changed from Awaiting Review to 5.3

#7 @SergeyBiryukov
6 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#8 @ocean90
4 months ago

  • Owner changed from SergeyBiryukov to ocean90
  • Status changed from reviewing to accepted
  • Version changed from trunk to 5.0

#46336 includes a fix for this as well.

#9 @ocean90
4 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 45685:

I18N: Add support for custom WP_PLUGIN_URL in load_script_textdomain().

Plugins may not be on the same host/path as the rest of the content. To support loading translations for this setup check if the script source matches plugins_url().
Also fixes an undefined index notice when a custom content URL has no path.

Props odminstudios, ocean90.
Fixes #46336, #46387.

Note: See TracTickets for help on using tickets.