Problem/Motivation
Consider a module that ships display_label: Default in its default configuration and declares translatable: 'false' on display_label in its schema.
On a site whose default language is German, Locale adds langcode: de and, if a German translation of Default already exists in the same context, can overwrite the active setting with Standard.
Correcting the schema to translatable: false later leaves the overwritten value and any existing language overrides in place.
The three methods that read translatable disagree on what 'false' means:
LocaleConfigManager::getTranslatableData()andConfigMapperManager::findTranslatable()both treat the non-empty string'false'as true, so Locale includes the setting in translation updates and Configuration Translation reports it as translatable.ArrayElement::hasTranslatableElements()checks forTRUEstrictly and therefore does not countdisplay_labelas translatable.
Steps to reproduce
- In a test module, ship
display_label: Defaultinconfig/install/example.settings.yml. In the schema forexample.settings, definedisplay_labelas astringwithtranslatable: 'false'. - On a site with German as its default language, enable Locale and Configuration Translation. Ensure that
Defaultalready has the German translationStandardin the same context. - Install the test module. After Locale updates configuration translations, check the active configuration for
example.settings. It containsdisplay_label: Standard. - Call
ConfigMapperManager::hasTranslatable()forexample.settings. It returnsTRUE. CallArrayElement::hasTranslatableElements()on the same typed configuration object. It returnsFALSE. - Change the schema flag to unquoted
false, rebuild caches and run the translation update again. The active value remainsStandard.
Proposed resolution
Use BooleanInput::parse() from #3644386: "false" is interpreted as TRUE in boolean configuration when the resolved schema definition contains a translatable flag, including one inherited from a schema type.
- All three readers should interpret
'false'asFALSEand report a deprecation identifying the schema property. - If the flag is absent, retain the existing default without a deprecation.
- For unrecognized input, report a deprecation and preserve each reader's existing fallback during the deprecation period.
Add kernel coverage for all three readers, including a schema definition altered by a module. Verify that LocaleConfigManager::updateConfigTranslations() leaves the active value intact and creates no language override for a property marked translatable: 'false'.
Remaining tasks
Postponed on #3644386: "false" is interpreted as TRUE in boolean configuration.
User interface changes
None.
Introduced terminology
None.
API changes
The translatable schema flag now follows the boolean input rules from #3644386: "false" is interpreted as TRUE in boolean configuration:
- Use unquoted
trueorfalsein config schema YAML files and native booleans in PHP. - Of the non-boolean values, only
0,1,'0'and'1'are accepted without a deprecation.
ConfigMapperManager::hasTranslatable() and LocaleConfigManager::getTranslatableDefaultConfig() now treat translatable: 'false' as FALSE.
ArrayElement::hasTranslatableElements() now also counts a property marked translatable: 1 or translatable: '1' as translatable.
Data model changes
None.
Release notes snippet
All three readers of the translatable schema flag now interpret recognized boolean strings consistently, including 'false', 'true', '0' and '1'.
Issue fork drupal-3644401
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments