#63269 closed defect (bug) (fixed)
Duplicate array key `Code` in `_WP_Editors::get_translation()`
Reported by: | Owned by: | ||
---|---|---|---|
Milestone: | 6.8.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has- dev-reviewed commit |
Focuses: | Cc: |
Description
This is a bug introduced in #38061, where the new Code
key added to _WP_Editors::get_translation()
on Line 1399 overwrites the existing Code
registered on Line 1168.
Line wp-includes/class-wp-editor.php ------- ---------------------------------------------------------------- :1168 Array has 2 duplicate keys with value 'Code' ('Code', 'Code'). ๐ชช array.duplicateKey
---
Caught as part of #61175 (โPHPStan baseline)
Attachments (4)
Change History (24)
#1
@
4 weeks ago
- Milestone changed from Awaiting Review to 6.8
- Owner set to joedolson
- Status changed from new to accepted
#4
@
4 weeks ago
I think we should follow the same model used elsewhere in the array for distinguishing between common keys, e.g. Edit
vs. Edit|button
. Perhaps Code|editor
?
#6
@
4 weeks ago
I think the alternate looks good to me, but I'm wondering wether we should fix this in 6.8 or in 6.8.1. What is the potential issue for end users: user facing strings conflicts?

This ticket was mentioned in โSlack in #core-i18n by justlevine. โView the logs.
4 weeks ago
#8
@
4 weeks ago
From what I can see, most if not all locales translate the two strings the same anyway, so it doesn't really matter in that regard. This can be fixed in 6.8.1 or even 6.9
#10 follow-up: โ 11
@
4 weeks ago
I found the first 'Code' string in the TinyMCE Code button. Core does not activate that in a Classic block or with Classic Editor, but it can be added with a plugin such as Advanced Editor Tools.
- If the newer string is not translated in the user's language, the tooltip shows "Code" (in English).
- Now the tooltip does not give the keyboard shortcut in any language.
โ5 out of 38 translations do not match the previous "Code" string perfectly, but the differences seem minor (to someone who cannot read them).
The "Text" could have one small advantage: if someone replaced the old string using the wp_mce_translation
filter, the replacement would continue to work. However, I did not find any โdirectory plugins that edited the "Text" tab, and most plugins in the search results just add strings for their own elements (very few replace a string).
#11 in reply to: โ 10
@
4 weeks ago
The "Text" could have one small advantage...
If a site replaced "Text" with the wp_mce_translation
filter, updating to 6.8 would already change the key and string. That decreases any value that restoring "Text" might have had.

This ticket was mentioned in โSlack in #core by jorbin. โView the logs.
4 weeks ago
#13
@
4 weeks ago
- Keywords commit added
https://core.trac.wordpress.org/attachment/ticket/63269/63269.2.diff looks good to me for 6.8.1

This ticket was mentioned in โSlack in #core by jorbin. โView the logs.
3 weeks ago
#16
@
3 weeks ago
- Keywords dev-feedback fixed-major added; commit removed
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for 2nd committer review and backport consideration
@
3 weeks ago
in trunk, the two different Vietnamese strings display correctly: "Mรฃ" for the Code tab, and "Mรฃ code" plus the keyboard shortcut for the TinyMCE Code button tooltip
The simplest fix might be to restore 'Text' as the array key (but leaving the translation).
text( window.tinymce.translate( 'Text' ) )
'Text' => _x( 'Code', 'Name for the Code editor tab (formerly Text)' ),
One way to test the script is with a Text widget (using the Classic Widgets plugin).