You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
config:set --lock-env twofactorauth/general/force_providers writes an array to env.php and breaks bin/magento and the Admin #441
Mage-OS 4.0.0 with Magento_TwoFactorAuth enabled (the default)
Steps to reproduce
bin/magento config:set --lock-env twofactorauth/general/force_providers google
Run any other command, for example bin/magento security:tfa:google:set-secret admin <secret> or bin/magento cache:flush, and open the Admin.
Expected result
app/etc/env.php contains 'force_providers' => 'google', the same string that config:set without --lock-env stores in core_config_data, and admin users log in with Google Authenticator.
Actual result
app/etc/env.php contains 'force_providers' => ['google']. After that, every bin/magento command fails with:
Type Error occurred when creating object: Magento\TwoFactorAuth\Model\Provider\Engine\DuoSecurity, explode(): Argument #2 ($string) must be of type string, array given
and the Admin returns HTTP 500. Removing the entry from env.php isn't enough: the array is still in the config cache, and bin/magento cache:flush can't run, so the cache storage (Valkey here) has to be flushed directly.
Cause: Magento\TwoFactorAuth\Model\Config\Backend\ForceProviders::beforeSave() turns the value into an array of provider codes. When the value is saved to the database, Magento\Config\Model\ResourceModel\Config\Data::_beforeSave() joins arrays into a string again, but --lock-env (and --lock-config) writes the backend model's value to the file unchanged.
Additional information
Workaround: run the command without --lock-env. That stores google in the database, and the login with Google Authenticator works.
Suggested fix: have ForceProviders::beforeSave() keep a comma-separated string, or join array values before the lock processor writes them.
Activity