Skip to content

dev:template-hints:enable/disable commands ignore locked configuration #40523

@lbajsarowicz

Description

@lbajsarowicz

Preconditions and environment

  • Magento version: 2.4.x (confirmed on 2.4.7)
  • The config path dev/debug/template_hints_storefront is locked in app/etc/env.php or app/etc/config.php

Example app/etc/env.php:

'system' => [
    'default' => [
        'dev' => [
            'debug' => [
                'template_hints_storefront' => '0'
            ]
        ]
    ]
]

Steps to reproduce

  1. Lock the dev/debug/template_hints_storefront value in app/etc/env.php (as shown above)
  2. Run bin/magento dev:template-hints:enable
  3. Observe the output
  4. Run bin/magento dev:template-hints:disable
  5. Observe the output

Expected result

Both commands should detect that the configuration path is locked and report an error, consistent with how bin/magento config:set handles locked values:

The value you set has already been locked. To change the value, use the --lock-env option.

The commands should return a failure exit code without modifying the database.

Actual result

Both commands display a misleading success message regardless of the lock status:

$ bin/magento dev:template-hints:enable
Template hints enabled.

$ bin/magento dev:template-hints:disable
Template hints disabled. Refresh cache types

The commands write the value to the core_config_data database table, but the locked value in env.php / config.php takes precedence at runtime, so the change has no actual effect. The user receives false confirmation.

Additional information

Root cause:

Both TemplateHintsEnableCommand and TemplateHintsDisableCommand (vendor/magento/module-developer/Console/Command/) use ConfigInterface::saveConfig() directly without checking deployment config for locked values:

// TemplateHintsEnableCommand.php:56
$this->resourceConfig->saveConfig('dev/debug/template_hints_storefront', 1, 'default', 0);
$output->writeln("<info>". self::SUCCESS_MESSAGE . "</info>");

The config:set command already handles this correctly in Magento\Config\Console\Command\ConfigSet\DefaultProcessor::process() by calling isLocked() which checks DeploymentConfig::get() before attempting to save:

if ($this->isLocked($path, $scope, $scopeCode)) {
    throw new CouldNotSaveException(__(
        'The value you set has already been locked. To change the value, use the --%1 option.',
        ConfigSetCommand::OPTION_LOCK_ENV
    ));
}

The template hints commands should implement the same check using DeploymentConfig and ConfigPathResolver, or be refactored to use the existing ConfigSet\DefaultProcessor.

Release note

The dev:template-hints:enable and dev:template-hints:disable CLI commands now correctly detect when the configuration value is locked in app/etc/env.php or app/etc/config.php and report an error instead of displaying a false success message.

Triage and priority

  • S3 - Affects non-critical data or functionality and does not force users to employ a workaround.

⭐ Support my work

Do you like my work? Remember to react with "👍🏻" to get it fixed faster,
Then Sponsor me on Github so I can spend more time on fixing issues like this one.

Learn more at https://github.com/sponsors/lbajsarowicz

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: FrameworkComponent: Framework/ConfigIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Reported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions