Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serialization not allowed in Magento?

When I turn on cache in Magento, I get the following exception:

Serialization of 'Mage_Core_Model_Layout_Element' is not allowed

Exception occurs in app/code/core/Mage/Page/Block/Template/Links.php, on line:

return parent::getCacheKeyInfo() + array(
            'links' => base64_encode(serialize($links)),
            'name' => $this->getNameInLayout()
        )

I am using Magento Enterprise 1.10 and PHP 5.3.

Can anyone tell me what the problem is?

like image 957
Dejan B. Avatar asked Jun 21 '11 09:06

Dejan B.


2 Answers

You shouldn't have an empty after_text or before_text tags in your layout file. If you don't need it, just delete the tag at all.

If it will not help, dump the $links variable before the 150th line in the app/code/core/Mage/Page/Block/Template/Links.php file, and you will see an array with arrays inside it. All of keys and values should be strings or integers, not objects. The key of array value which is an object will tell you which tag to delete from the layout file.

like image 141
vsushkov Avatar answered Oct 21 '22 11:10

vsushkov


Awesome @vsushkov.

I used: try{ serialize($links); } catch(Exception $e){ Mage::log($links); die; } to find out exact layout where we had those empty tags and after removing those empty tags, it fixed the issue and then removed above code :-)

like image 38
Damodar Bashyal Avatar answered Oct 21 '22 11:10

Damodar Bashyal