I have this string in database. I need to unserialize it with php. The problem is that it returns some "__PHP_Incomplete_Class_Name" Objects.
I know that this string was serialized with old MongoDB PHP extension and I try to unserialized with newer MongoDB extension.
So MongoId and MongoDate are obsolete.
This is the string:
$string = 'a:2:{i:0;a:3:{s:4:"name";s:52:"----------------------------------------------------";s:6:"amount";s:5:"53.09";s:10:"service_id";s:24:"------------------------";}i:1;a:6:{s:2:"id";C:7:"MongoId":24:{5b2276372a4ef288038b45ba}s:4:"name";s:21:"---------------------";s:4:"type";s:8:"one time";s:10:"service_id";s:20:"thisrhietingcfffffff";s:6:"amount";s:6:"139.29";s:10:"added_date";O:9:"MongoDate":2:{s:3:"sec";i:1528985143;s:4:"usec";i:917000;}}}';
When I do:
$result = @unserialize($string);
var_dump($result);
The result is:
array(2) {
[0]=>
array(3) {
["name"]=>
string(52) "----------------------------------------------------"
["amount"]=>
string(5) "53.09"
["service_id"]=>
string(24) "------------------------"
}
[1]=>
array(6) {
["id"]=>
object(__PHP_Incomplete_Class)#1 (1) {
["__PHP_Incomplete_Class_Name"]=>
string(7) "MongoId"
}
["name"]=>
string(21) "---------------------"
["type"]=>
string(8) "one time"
["service_id"]=>
string(20) "thisrhietingcfffffff"
["amount"]=>
string(6) "139.29"
["added_date"]=>
object(__PHP_Incomplete_Class)#2 (3) {
["__PHP_Incomplete_Class_Name"]=>
string(9) "MongoDate"
["sec"]=>
int(1528985143)
["usec"]=>
int(917000)
}
}
}
I have tried to class_alias MongoId to ObjectId. No working. I Have tried to create new class MongoId to extend ObjectId. I am not allowed because ObjectId is a final class.
I have tried to replace C:7:"MongoId" with C:8:"ObjectID".
Still same result: __PHP_Incomplete_Class_Name
Maybe a posibility is to return result like an array not an object?