Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#46387 closed defect (bug) (fixed)

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

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

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 4 years ago.
46387.2.diff (0 bytes) - added by odminstudios 4 years ago.
46387.3.diff (508 bytes) - added by odminstudios 4 years ago.

Download all attachments as: .zip

Change History (12)

#1 @swissspidy
4 years ago

  • Component changed from Cron API to I18N

#2 @SergeyBiryukov
4 years ago

#46672 was marked as a duplicate.

#3 @tditlu
4 years ago

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

@odminstudios
4 years ago

@odminstudios
4 years ago

@odminstudios
4 years ago

#4 @odminstudios
4 years 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
4 years 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
4 years ago

  • Milestone changed from Awaiting Review to 5.3

#7 @SergeyBiryukov
4 years ago

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

#8 @ocean90
4 years 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 years 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.