an object that is in a namespaced class that is serialized and then
deserialized becomes a "__PHP_Incomplete_Class Object (
[__PHP_Incomplete_Class_Name]". It seems serialize/deserialize don't
understand namespaces.
Namespace app {
class berries {
public $name;
public $quantity;
function __construct($name=NULL) {
$this->name = $name;
}
}
$object = new app::berries("aberry");
$objecttext = serialize($object);
$objectnew = unserialize($objecttext);
print_r($objectnew);
Best Regards,
Dmitriy Myshkin
Software Architect
T3Link, Inc.
an object that is in a namespaced class that is serialized and then
deserialized becomes a "__PHP_Incomplete_Class Object (
[__PHP_Incomplete_Class_Name]". It seems serialize/deserialize don't
understand namespaces.
These patches to php_incomplete_class.h and var_unserializer.re, though
not thoroughly tested, fix this.
Test script:
<?php
namespace Foo:Baz {
class Bar { }
}
class Baz { }
$bar= new Foo:Baz::Bar();
var_dump($bar, serialize($bar), unserialize(serialize($bar)));
$baz= new Baz();
var_dump(serialize($baz), unserialize(serialize($baz)));
?>
You will need re2c to compile, see http://www.tildeslash.org/re2c/
- Timm
[...]
These patches to php_incomplete_class.h and var_unserializer.re, though
not thoroughly tested, fix this.
Here's a patch to php_incomplete_class.h with corrected whitespace. Some
lines were indented with spaces instead of tabs...
- Timm
[...]
These patches to php_incomplete_class.h and var_unserializer.re, though
not thoroughly tested, fix this.Here's a patch to php_incomplete_class.h with corrected whitespace. Some
lines were indented with spaces instead of tabs...
While I'm at it: This patch also gets rid of memory leaks that occur
when using the unserialize_callback_func ini directive.
- Timm
[...]
These patches to php_incomplete_class.h and var_unserializer.re, though
not thoroughly tested, fix this.Here's a patch to php_incomplete_class.h with corrected whitespace. Some
lines were indented with spaces instead of tabs...While I'm at it: This patch also gets rid of memory leaks that occur
when using the unserialize_callback_func ini directive.
And this one gets rid of all of them. Sorry for all the spam here:)
Test script used:
<?php
function autoload($fqcn) {
list($namespace, $class)= explode('::', $fqcn);
if ('power' == $namespace) {
eval('namespace '.$namespace.' { class '.$class.' {}}');
}
}
namespace Foo:Baz {
class Bar { }
}
class Baz { }
$bar= new Foo:Baz::Bar();
var_dump($bar, serialize($bar), unserialize(serialize($bar)));
$baz= new Baz();
var_dump(serialize($baz), unserialize(serialize($baz)));
var_dump(unserialize('O:7:"Binford":0:{}'));
ini_set('unserialize_callback_func', 'autoload');
var_dump(unserialize('O:14:"Power::Binford":0:{}'));
var_dump(unserialize('O:14:"Idiot::Binford":0:{}'));
?>
- Timm