[wp-trac] [WordPress Trac] #65015: Connectors: Several strings are not translated

WordPress Trac noreply at wordpress.org
Thu Apr 30 19:27:14 UTC 2026


#65015: Connectors: Several strings are not translated
-------------------------------------------------+-------------------------
 Reporter:  369work                              |       Owner:
                                                 |  westonruter
     Type:  defect (bug)                         |      Status:  closed
 Priority:  high                                 |   Milestone:  7.0
Component:  I18N                                 |     Version:
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests connectors  |     Focuses:
  commit needs-dev-note fixed-major dev-         |
  reviewed                                       |
-------------------------------------------------+-------------------------

Comment (by westonruter):

 I found a minor issue with [62278]. Once it landed, it started causing
 test failures in the Performance Lab plugin
 ([https://github.com/WordPress/performance/pull/2463 PR]):

 {{{
 1) Test_Audit_Enqueued_Assets::test_perflab_aea_audit_enqueued_scripts
 Undefined array key "path"

 …/wp-includes/l10n.php:1242
 …/wp-includes/l10n.php:1185
 …/wp-includes/class-wp-script-modules.php:399
 …/wp-includes/class-wp-hook.php:341
 …/wp-includes/class-wp-hook.php:365
 …/wp-includes/plugin.php:522
 …/wp-includes/general-template.php:3224
 …/wordpress-phpunit/includes/utils.php:437
 …/wp-content/plugins/performance/plugins/performance-lab/tests/data/class-
 audit-assets-mock-assets.php:94
 …/wp-content/plugins/performance/plugins/performance-lab/tests/data/class-
 audit-assets-mock-assets.php:142
 …/wp-content/plugins/performance/plugins/performance-lab/tests/includes
 /site-health/audit-enqueued-assets/test-audit-enqueued-assets.php:107
 }}}

 At issue is that the unit test in the plugin
 [https://github.com/WordPress/performance/blob/5e1903cc771cff9e6af85b14938ce6639e49ba39/plugins
 /performance-lab/tests/includes/site-health/audit-enqueued-assets/test-
 audit-enqueued-assets.php#L61 was doing] this:

 {{{#!php
 <?php
 wp_enqueue_script_module( 'module1', 'https://module1.example.com',
 array(), null );
 }}}

 Note the lack of a path on the URL. This is causing the usage on
 [https://github.com/WordPress/wordpress-
 develop/blob/75b41314907d43bb111e22e305ba048bd4b90ec2/src/wp-
 includes/l10n.php#L1242 two] [https://github.com/WordPress/wordpress-
 develop/blob/75b41314907d43bb111e22e305ba048bd4b90ec2/src/wp-
 includes/l10n.php#L1268 lines] of `_load_script_textdomain_from_src()` to
 fail when it accesses `$src_url['path']`.

 Now, it is extremely unlikely for URLs to be provided to a registered
 script module that lack a path. So this is why it is minor. Nevertheless,
 this is an opportunity for hardening.

 Here's an easy way to reproduce this issue. Put the following code into a
 PHP file like `try-script-module-index-undefined-issue.php`:

 {{{#!php
 <?php
 wp_enqueue_script_module( 'module1', 'https://module1.example.com',
 array(), null );
 wp_script_modules()->print_script_module_translations();
 }}}


 The result is:

 {{{
 npm run env:cli -- eval-file try-script-module-index-undefined-issue.php

 > WordPress at 7.1.0 env:cli
 > node ./tools/local-env/scripts/docker.js exec --user wp_php cli wp eval-
 file try-script-module-index-undefined-issue.php

 Warning: Undefined array key "path" in /var/www/src/wp-includes/l10n.php
 on line 1242
 Deprecated: str_starts_with(): Passing null to parameter #1 ($haystack) of
 type string is deprecated in /var/www/src/wp-includes/l10n.php on line
 1242
 Warning: Undefined array key "path" in /var/www/src/wp-includes/l10n.php
 on line 1268
 Deprecated: str_starts_with(): Passing null to parameter #1 ($haystack) of
 type string is deprecated in /var/www/src/wp-includes/l10n.php on line
 1268
 }}}

 There are quite a lot of PHPStan issues being reported with
 `_load_script_textdomain_from_src()` which pre-exist 7.0 when the logic
 was originally located in `load_script_textdomain()`:

 ||= Line =||= Error =||
 || 1214 || Cannot call method `get()` on `mixed`. ||
 || 1217 || Parameter !#1 `$value` of function `untrailingslashit` expects
 `string`, `mixed` given. ||
 || 1242 || Cannot access offset `'path'` on `mixed`. (×2) ||
 || 1242 || Parameter !#1 `$haystack` of `str_starts_with` expects
 `string`, `mixed` given. ||
 || 1242 || Parameter !#2 `$needle` of `str_starts_with` expects `string`,
 `mixed` given. ||
 || 1243 || Cannot access offset `'host'` on `mixed`. (×2) ||
 || 1246 || Cannot access offset `'path'` on `mixed`. ||
 || 1247 || Cannot access offset `'path'` on `mixed`. ||
 || 1247 || Parameter !#1 `$string` of `strlen` expects `string`, `mixed`
 given. ||
 || 1247 || Parameter !#1 `$string` of `substr` expects `string`, `mixed`
 given. ||
 || 1249 || Cannot access offset `'path'` on `mixed`. ||
 || 1251 || Parameter !#1 `$str` of `trim` expects `string`, `mixed` given.
 ||
 || 1268 || Cannot access offset `'path'` on `mixed`. (×2) ||
 || 1268 || Parameter !#1 `$haystack` of `str_starts_with` expects
 `string`, `mixed` given. ||
 || 1268 || Parameter !#2 `$needle` of `str_starts_with` expects `string`,
 `mixed` given. ||
 || 1269 || Cannot access offset `'host'` on `mixed`. (×2) ||
 || 1272 || Cannot access offset `'path'` on `mixed`. ||
 || 1273 || Cannot access offset `'path'` on `mixed`. ||
 || 1273 || Parameter !#1 `$string` of `strlen` expects `string`, `mixed`
 given. ||
 || 1273 || Parameter !#1 `$string` of `substr` expects `string`, `mixed`
 given. ||
 || 1275 || Cannot access offset `'path'` on `mixed`. ||
 || 1277 || Parameter !#1 `$str` of `trim` expects `string`, `mixed` given.
 ||
 || 1284 || Cannot access offset `'host'` on `mixed`. (×2) ||
 || 1285 || Cannot access offset `'path'` on `mixed`. ||
 || 1286 || Cannot access offset `'path'` on `mixed`. ||
 || 1286 || Parameter !#1 `$str` of `trim` expects `string`, `mixed` given.
 ||
 || 1287 || Cannot access offset `'path'` on `mixed`. ||
 || 1287 || Parameter !#1 `$haystack` of `str_starts_with` expects
 `string`, `mixed` given. ||
 || 1287 || Parameter !#1 `$value` of `trailingslashit` expects `string`,
 `mixed` given. ||
 || 1289 || Cannot access offset `'path'` on `mixed`. ||
 || 1289 || Parameter !#1 `$string` of `strlen` expects `string`, `mixed`
 given. ||
 || 1289 || Parameter !#1 `$string` of `substr` expects `string`, `mixed`
 given. ||
 || 1312 || Parameter !#1 `$haystack` of `str_ends_with` expects `string`,
 `mixed` given. ||
 || 1313 || Parameter !#1 `$string` of `substr` expects `string`, `mixed`
 given. ||
 || 1316 || Parameter !#1 `$str` of `md5` expects `string`, `mixed` given.
 ||

 I've opened a [https://github.com/WordPress/wordpress-develop/pull/11690
 pull request] to fix the undefined index error, as well as to fix the
 remaining PHPStan at level 10, which primarily involves a few fixes to
 `_load_script_textdomain_from_src()` but primarily it involves adding a
 conditional return type for `wp_parse_url()`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/65015#comment:47>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list