Description
Summary
We're updating our configuration to be more user friendly and this involves creating new categories to move configuration around. While doing this, we want to maintain backwards compatibility and so have set config_paths for most of our settings.
An example would be tax/vertex_settings/trustedId
is now in system.xml as tax/vertex/connection/trusted_id
- but has config_path set to tax/vertex_settings/trustedId
. This field has a backend model to encrypt the data in it.
The problem being experienced is that the data is being entered into the database unencrypted - leading it to be considered encrypted and then the code receiving junk data.
This is occurring because the config:set
command pulls apart the path and sends it as if that were the path being sent by the form.
So when we enter Magento\Config\Model\Config
our $groupPath
is tax/vertex_settings
and our $groupData
is ['fields' => ['trustedId' => ['value' => '<value>']]]
.
It SHOULD be:
groupPath
=tax/vertex/connection
groupData
=['fields' => ['trusted_id' => ['value' => '<value>']]]
One might then try to run config:set tax/vertex/connection/trusted_id <value>
however this returns that the config does not exist
Manual testing scenarios (*)
- Create sample module with system.xml like this
<system>
<section id="sales">
<group id="general">
<field id="keyid" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Key Id</label>
</field>
</group>
</section>
</system>
- Set some value via CLI
bin/magento config:set sales/general/keyid 1
We can see Value was saved. as expected. - Add some
config_path
tosystem.xml
like this
<system>
<section id="sales">
<group id="general">
<field id="keyid" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Key Id</label>
<config_path>custom_path/keyid</config_path>
</field>
</group>
</section>
</system>
- Clear cache
config
- Try to set some value via CLI again
bin/magento config:set sales/general/keyid 777
Actual Result:
The "sales/general/keyid" path doesn't exist. Verify and try again.
Expected Result:
Value was saved.
Proposed Solution
Update Magento\Config\Model\Config\PathValidator
to check if an element exists by the path presented to it, and if it has a config path, use that instead for validation.
Inserting into the top of the validate command:
$element = $this->structure->getElementByConfigPath($path);
if ($element->getConfigPath()) {
$path = $element->getConfigPath();
}
This is my proposed solution over trying to determine the display path via the config path, as more than one display path can have the same config path. This change would then allow config:set tax/vertex/connection/trusted_id
(and other "display paths")
Metadata
Metadata
Assignees
Labels
Type
Projects
Status