|
Posted by Fabian Hore on 02/23/06 18:44
When an object is unserialized and its class definition doesn't exist
it becomes an instance of "__PHP_Incomplete_Class".
no problem... however, what is annoying me is that you cannot treat it
like a vanilla flavoured "stdClass" object and set its member variables.
get_object_vars() will allow you to get a property, but you cannot set any!
try my example:
<?php
// force a __PHP_Incomplete_Class object
$sleepstring = 'O:12:"missingclass":1:{s:5:"myvar";s:11:"hello world";}';
$Obj = unserialize($sleepstring);
// test that its broke!
$isbroken = is_a($Obj, '__PHP_Incomplete_Class');
var_dump($isbroken); // bool(true)
// test properties
var_dump( $Obj->myvar ); // NULL, and raises E_NOTICE
$vars = get_object_vars($Obj);
var_dump( $vars['myvar'] ); // string(11) "hello world", hooray!
?>
Anyone know a hack/workaround to set a value in the object?
*one idea*
You could construct a stdClass instance, copy the proprties into it,
and then hack the resulting string when the object is serialized again.
like: <? str_replace('O:8:"stdclass"', 'O:12:"missingclass"', $sleepstring)
?>
however: this wouldn't work on session sleep!
Navigation:
[Reply to this message]
|