Problem/Motivation

When a site builder wants to disable CSS aggregation, they might enter preprocess: 'false' in the css section of system.performance.yml. On import, Drupal stores TRUE, leaving aggregation enabled.

The default boolean config schema type uses BooleanData::getCastedValue(), which applies PHP's (bool) cast. Every string except '' and '0' becomes TRUE, whether it came from YAML or the Configuration API. While the original string 'false' would fail schema validation, casting it first produces a valid boolean with the opposite meaning.

Implications

  • A project sets css.preprocess to 'false' in its sync directory to disable CSS aggregation. Importing it leaves aggregation enabled, and the next comparison still lists system.performance as changed. If the admin then exports the active configuration, the export writes preprocess: true to the file. Deploying that export enables aggregation on the target site as well.
  • A site builder imports a custom menu with locked: 'false'. Drupal stores locked as TRUE. When an admin later tries to delete the menu through the UI, MenuAccessControlHandler::checkAccess() denies deletion.
  • Suppose a module ships send_notifications: 'false' for a boolean setting in its config/install defaults. Installing the module enables notifications. If a later update corrects the default, it cannot tell from active configuration alone which sites deliberately enabled notifications and which inherited the miscast value.

Context: Use of 0 and 1 in Drupal and Drush

Drush:
Particularly in Drush, devs have long used 0 and 1 to turn settings off and on, as illustrated in #2904502: Settings config cannot be set using drush command. A user reported on Drupal Answers that drush config-set advagg.settings enabled false stored true, while 0 stored false. It's only since the November 2026 fix that config:set parses true and false as booleans while still passing the digits as strings by default.
Form API checkboxes:
For an unchecked checkbox, including the one in the "Performance" form, Checkbox::valueCallback() returns integer 0. For a checked checkbox, it returns the configured #return_value, which defaults to integer 1.
Boolean field defaults:
In config schema, Core assigns the type integer to the value property of a boolean field default. For example, the Umami demo profile sets value: 1 as the default for the promote field on articles and recipes.
Schema validation:
For boolean settings, Core's PrimitiveTypeConstraint already accepts 0, 1, '0' and '1'.

Steps to reproduce

  1. Start with "Aggregate CSS files" enabled at /admin/config/development/performance and export the configuration.
  2. To disable aggregation, enter preprocess: 'false' in system.performance.yml's css section and import the configuration.
  3. Return to the "Performance" page. "Aggregate CSS files" is still checked. The import should disable aggregation and report a deprecation for the quoted value.

Proposed resolution

Deprecate non-boolean input that reaches the cast for the default boolean config schema type, with four exceptions for now.

During the deprecation period, correct the cast so that 'false' disables the setting. The deprecation tells the caller to correct the input as well. If the sync file still contains the string, the next comparison will still report a change.

  • Accept native booleans and the exact values 0, 1, '0' and '1' without a deprecation. Existing Drush commands and scripts use the string forms, and standard checkboxes return the integers.
  • For other strings recognized by FILTER_VALIDATE_BOOL, trigger a deprecation and use the parsed value. This maps 'false', 'off', 'no' and an empty string to FALSE, and 'true', 'on' and 'yes' to TRUE, case-insensitively.
  • For any remaining input that reaches the cast, trigger a deprecation and retain the existing (bool) cast.

Implementation

  1. Use an internal ConfigBoolean subclass of BooleanData for the boolean config schema type.
  2. Have ConfigBoolean::getCastedValue() delegate input recognition and deprecation reporting to a shared internal BooleanInput helper.
  3. Apply #[JsonSchema(['type' => 'boolean'])] to the overriding method so that it retains its boolean JSON Schema type.
  4. When saving configuration, include the configuration name and property path in the deprecation message, for example system.performance:css.preprocess.
  5. Use FILTER_NULL_ON_FAILURE so that BooleanInput::parse() returns NULL for unrecognized input. ConfigBoolean::getCastedValue() then calls parent::getCastedValue(). A follow-up can reuse BooleanInput::parse() for the translatable schema flag while preserving each reader's fallback.
  6. Update Core code that supplies strings for boolean configuration settings to pass native booleans. This includes field formatter defaults, node revision settings, hidden fields in Layout Builder and Views handler options.
  7. Preserve native booleans in RecipeRunner::replaceInputValues() when a placeholder is the entire config action argument or array value. A placeholder embedded in text still uses string interpolation.

Tests

  1. Test that importing preprocess: 'false' stores FALSE and triggers a deprecation that identifies system.performance:css.preprocess.
  2. Test that '1' and '01' both yield TRUE, but only '01' triggers a deprecation. PrimitiveTypeConstraintValidator::validate() currently accepts both. Also test that ' 0 ' yields FALSE and triggers a deprecation because the original string is not exactly '0'.

Remaining tasks

Review.

User interface changes

None.

API changes

Config
The default boolean config schema type now uses ConfigBoolean. If an element of this type contains the string 'false', 'off' or 'no', calling ConfigBoolean::getCastedValue() directly triggers a deprecation and returns FALSE instead of TRUE.

Passing non-boolean input other than the four numeric forms listed below is deprecated to be removed in the next major.

The integers 0 and 1 and the strings '0' and '1' remain accepted without deprecation.

Recipe
When a Recipe uses a standalone placeholder for a boolean input, the config action now receives FALSE or TRUE instead of '' or '1', respectively.

Data model changes

None.

Release notes snippet

Saving or importing 'false', 'off' or 'no' for a boolean configuration setting now stores FALSE instead of TRUE and triggers a deprecation.

Issue fork drupal-3644386

Command icon 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

pancho created an issue. See original summary.

pancho’s picture

Issue summary: View changes
Status: Active » Needs review