WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

#45256 closed defect (bug) (fixed)

Undefined index: path in load_script_textdomain function

Reported by: tmatsuur Owned by: herregroen
Milestone: 5.0 Priority: normal
Severity: normal Version: 5.0
Component: I18N Keywords: has-patch fixed-5.0
Focuses: Cc:

Description

I will report an error message when using the wp_set_scrianslations function in the development environment.

Notice:  Undefined index: path in <b>.../htdocs/wp-includes/l10n.php on line 928

This error occurrence point is as follows.

	( strpos( $site_url['path'], $src_url['path'] ) === 0 ) &&

This is because the 'path' key does not exist in variable $site_url if site_url is 'http: localhost'.

I think it is necessary to determine whether the 'path' key exists in the variable $site_url before the strpos function.

Change History (7)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to I18N
  • Milestone changed from Awaiting Review to 5.0
  • Version set to 5.0

#3 @herregroen
3 years ago

  • Owner set to herregroen
  • Resolution set to fixed
  • Status changed from new to closed

In 43898:

I18N: Fix warnings in JavaScript translations.

Fixes an undefined index PHP warning in the load_script_textdomain function and a non-interrupting JS error when registering a domain which has no translations.

Props omarreiss, ocean90, georgestephanis.
Fixes #45256.

#4 @herregroen
3 years ago

  • Keywords has-patch fixed-5.0 added
  • Resolution fixed deleted
  • Status changed from closed to reopened

#5 @herregroen
3 years ago

Sign off for the patch was given here:
https://core.trac.wordpress.org/ticket/45103#comment:40

Last edited 3 years ago by herregroen (previous) (diff)

#7 @pento
2 years ago

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

In 44169:

I18N: Add JavaScript translation support.

Adds the wp_set_script_translations() function which registers translations for a JavaScript file. This function takes a handle, domain and optionally a path and ensures JavaScript translation files are loaded if they exist.

Merges [43825,43828,43859,43898] from the 5.0 branch to trunk.

Props herregroen, atimmer, omarreiss, nerrad, swissspidy, ocean90, georgestephanis.
Fixes #45103, #45256.

Note: See TracTickets for help on using tickets.