Magento2: Problem with serialized default value in config.xml

Created on 28 Mar 2017  路  9Comments  路  Source: magento/magento2

Preconditions

Magento 2.1.4

Steps to reproduce

  1. Create a configuration with "_Magento\Config\Model\Config\Backend\Serialized\ArraySerialized_" as backend_model in a system.xml config file.
  2. Add a serialized config in config.xml

Expected result

  1. The configuration should be visible as lines of array
    configuration settings stores magento admin - google chrome

Actual result

configuration settings stores magento admin - google chrome_2

The reason is that when a configuration is not saved in DB, backend_model is not called when the config is loaded.

More precisely, the problem is in the class "_Magento\Config\Block\System\Config\Form_" at line 349 :
if (array_key_exists($path, $this->_configData) )

$this->_configData is a collection of configurations in DB.

Fixed in 2.2.x Fixed in 2.3.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.1.x

Most helpful comment

@synolia-bvo, thank you for your report.
We've created internal ticket(s) MAGETWO-82435 to track progress on the issue.

All 9 comments

Possible duplicate of #7741 and #2984.

As a workaround, I think you should be able to use this trick: simply add the backend_model as an attribute to the config.xml node containing your default serialized value.

Thank you for your answer, but i can't use this trick for 2 reasons :

  • There is an exception launched :

Exception #0 (InvalidArgumentException): Magento\Config\Model\Config\Backend\Serialized\ArraySerialized is not instance of \Magento\Framework\App\Config\Data\ProcessorInterface

  • This bug is not the same as i mentioned : adding "backend_model" will not change anything since the "config.xml" is not read at all in admin in the class "_Magento\Config\Block\System\Config\Form_"

I think I'll have to make a setup to insert my config directly in DB until the problem is solved.

Well, alternatively, you could also go deeper into the rabbit hole and try to implement that \Magento\Framework\App\Config\Data\ProcessorInterface but it's hard to say whether something like that is even worth the effort.

I modified my answer and there is another reason why this trick can't work :(
Unfortunately, I think implementing this interface will not solve my problem.

Up ? :/

Up, indeed! I've reported the same issue (which is accepted as bug), but your description is a bit better.

I've made a pull request (#7742) but can't yet get it through all tests, but we'll get there I guess :)

@synolia-bvo, thank you for your report.
We've created internal ticket(s) MAGETWO-82435 to track progress on the issue.

Fixed on 2.3.
We will consider backporting.

Hi @synolia-bvo
This issue should be fixed in latest 2.2 with the commit https://github.com/magento/magento2/commit/86d46ce0bdeca61ade5c1063edcb70367f17b2a5
Closing the issue report for now. Please reopen if issue persists.

Was this page helpful?
0 / 5 - 0 ratings