Serialized Array Settings Ignored – Magento 1.9 Configuration Bug

bugconfigurationcore-config-datamagento-1.9magento1.9.3.1

I have an extension which adds panel to System > Configuration, but suddenly in 1.9.3 it ignores default values for settings with <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>. So after installing the module settings are empty instead of having default data configured.

I have setting defined in system.xml file like:

<setting_name>
    <label>My label</label>
    <frontend_model>my/frontend_model</frontend_model>
    <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
    <sort_order>10</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    <comment><![CDATA[...]]></comment>
</setting_name>

And in config.xml file I have defined default values:

<correct_group_name>
    <setting_name>a:1:{s:18:"_1450089283397_397";a:3:{s:4:"name";s:5:"pages";s:5:"label";s:5:"Pages";s:11:"hitsPerPage";s:1:"2";}}</setting_name>
</correct_group_name>

It works in all versions >= 1.6.2 and <=1.9.2.1. Did something changed in 1.9.3? I'm not able to find anything in relase notes.

Version 1.9.2.1:
enter image description here

Version 1.9.3.1:
enter image description here

Thanks for any help or suggestions.

P.S. All other settings' default values (like text inputs, select boxes, …) work correctly.

Best Answer

After some tests I can confirm this is a bug introduced by Magento 1.9.3.0 (see here: https://github.com/OpenMage/magento-mirror/commit/d48bebc211cc216aaf78bdf25d7f0b0143d6333b#diff-139e884940505308d9c796f5e3a78865 )

Side note: this also affects SUPEE-8788

As a temporary fix, here is what I suggest: copy app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Serialized.php to app/code/local/Mage/Adminhtml/Model/System/Config/Backend/Serialized.php and modify the _afterLoad() method like this:

protected function _afterLoad()
{
    if (!is_array($this->getValue())) {
        $serializedValue = $this->getValue();
        $unserializedValue = false;
        if (!empty($serializedValue)) {
            try {
                $unserializedValue = Mage::helper('core/unserializeArray')
                    ->unserialize((string)$serializedValue);
            } catch (Exception $e) {
                Mage::logException($e);
            }
        }
        $this->setValue($unserializedValue);
    }
}