-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
- Magento version: 2.4.x (confirmed on 2.4.7)
- The config path
dev/debug/template_hints_storefrontis locked inapp/etc/env.phporapp/etc/config.php
Example app/etc/env.php:
'system' => [
'default' => [
'dev' => [
'debug' => [
'template_hints_storefront' => '0'
]
]
]
]Steps to reproduce
- Lock the
dev/debug/template_hints_storefrontvalue inapp/etc/env.php(as shown above) - Run
bin/magento dev:template-hints:enable - Observe the output
- Run
bin/magento dev:template-hints:disable - 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
Labels
Type
Projects
Status