Description
Preconditions (*)
I am using Magento 2.4.0 in development mode with PHP 7.4.10 on Linux, Debian Buster.
Also verified and confirmed on 2.4-develop
open source edition
Steps to reproduce (*)
-
We followed these instructions to create a dynamic row system config.
-
We have added default values to my
etc/config.xml
in this form:
<default>
<general>
<quantity_ranges>
<ranges>
<item1>
<from_qty>1</from_qty>
<to_qty>5</to_qty>
<price>10.00</price>
<tax>1</tax>
</item1>
<item2>
<from_qty>6</from_qty>
<to_qty>10</to_qty>
<price>20.00</price>
<tax>1</tax>
</item2>
<item3>
<from_qty>11</from_qty>
<to_qty>15</to_qty>
<price>30.00</price>
<tax>0</tax>
</item3>
</ranges>
</quantity_ranges>
</general>
</default>
3. Go to Admin -> System -> Configuration -> Quantity Ranges
and click on the Save Config button
Expected result (*)
Save the configs.
Actual result (*)
I get the following error:
Notice: Array to string conversion in /path/to/magento/vendor/magento/framework/App/Config/Value.php on line 100
When I remove the defaults from the config.xml and clear the cache, the saving works correctly.
Notice
I have tried to debug the issue. What I found out so long is that Magento serializes the data in the config value to json in Magento\Config\Model\Config\Backend\Serialized::beforeSave
and saves it in the data array.
In Magento\Framework\App\Config\Value::afterSave
it calls $this->isValueChanged()
where it compares $this->getValue() != $this->getOldValue()
. Now in getOldValue
it uses the default value coming from the XML config which is stored as array and is not serialized. At the point where the array is tried to be casted to a string, the error occures.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status