PHP 5.3 serialize error in CController

I was getting a fatal error exception:

“Serialization of ‘SimpleXMLElement’ is not allowed”

/www/yii/framework-1.1.x/web/CController.php(0)

No source code available.

with the last few lines of the stack trace:

#0 /www/yii/framework/web/CController.php(0): serialize()

#1 /www/yii/framework/web/CController.php(327): CController->savePageStates(Array, ‘<!DOCTYPE html …’)

#2 /www/yii/web/CController.php(743): CController->processOutput(’<!DOCTYPE html …’)

environment: Apache/2.2.14 (Unix) PHP/5.3.2 Yii Framework/1.1.4

(seems the same in Yii 1.1.5-dev)

changing line 1153 in CController.php from:

&#036;data=Yii::app()-&gt;getSecurityManager()-&gt;hashData(serialize(&#036;states));

to

&#036;data=Yii::app()-&gt;getSecurityManager()-&gt;hashData(json_encode(&#036;states));

seems to fix the problem.

Anyone else seen this and/or have a different fix?

From what i see, SimpleXmlElement isn’t used anywhere in the framework. Do you use page states in your project? Or some extension like an alternative view renderer? It looks like some page state contains a SimpleXmlElement which is rather unusual.