[wp-trac] [WordPress Trac] #53738: Broken loop in WP_Theme_JSON_Resolver
WordPress Trac
noreply at wordpress.org
Thu Jul 22 12:47:59 UTC 2021
#53738: Broken loop in WP_Theme_JSON_Resolver
----------------------------+-------------------------
Reporter: SergeyBiryukov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.8.1
Component: Themes | Version:
Severity: normal | Keywords: fixed-major
Focuses: |
----------------------------+-------------------------
Originally reported at
https://github.com/WordPress/gutenberg/issues/33552.
The loop in `WP_Theme_JSON_Resolver` to extract translatable paths is
broken, as it contains an immediate and unconditional `return`. This
causes the loop to immediately exit again after the first iteration, thus
never actually looping.
{{{
foreach ( $partial_child as $key => $context ) {
return array(
array(
'path' => $current_path,
'key' => $key,
'context' => $context,
),
);
}
}}}
This means that the extraction only works where there's only a single item
in the array of translatable strings per section (i.e. the `'name'`
field).
The suggested code would be:
{{{
foreach ( $partial_child as $key => $context ) {
$result[] = array(
'path' => $current_path,
'key' => $key,
'context' => $context,
);
}
return $result;
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53738>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list