How to access __PHP_Incomplete_Class object ?
If you unserialize an object of a class that hasn’t been included yet then you will get a __PHP_Incomplete_Class object. A PHPIncompleteClass object can’t be accessed directly, but we can do some conversation to visit it like an object. The following will tell you how to access __php_incomplete_class
In WordPress when you call add_option/updae_option to save data into the database, the data will be serialized d first. When you get data by get_option when all data will be unserialized first. So if you read some plugins’ data it may cause trouble.
The following function will help you convert the __PHP_Incomplete_Class to a stdClass object. After this, you may use it like a normal object.
function convert2stdClass($object) | |
{
| |
$serializedObj = serialize($object); | |
$stdClassObj = preg_replace('/^O:\d+:"[^"]++"/', 'O:' . strlen('stdClass') . ':"stdClass"', $serializedObj); | |
return unserialize( $stdClassObj ); | |
}
|

Post a Comment