Skip to content

[Config] Array to string conversion error when saving row system config with defaults #30314

Closed
@stollr

Description

@stollr

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 (*)

  1. We followed these instructions to create a dynamic row system config.

  2. 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

2020-10-20_16-42

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

Component: ConfigFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P3May be fixed according to the position in the backlog.Progress: doneReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions