-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 1.5.0
-
Component/s: None
-
None
-
Environment:Debian Buster
Hello, first I apologize if this issue has already been addressed.
I am using Doctrine ODM on Debian Buster (so it's php-mongodb 1.5.3-2 ). And I had a problem when executing some findAndUpdate request :
$qb = $this->createQueryBuilder() ->findAndUpdate() ->returnNew() ->field('expires') ->lte(new DateTimeImmutable()) ->field('status') ->set(Status::LOCKED()) // other stuff ->getQuery() ->execute();
After that request, any other request to database ended up with this exception :
MongoDB\\Driver\\Exception\\InvalidArgumentException(code: 0): Class \u0001 does not exist
After digging I realize the property typeMap of MongoDB\Client class changes everytime the {{apply_type_map_to_document()}} function is called. To fix this problem I had to modify this function in order to pass a $typeMap array that is not used anywhere to \MongoDB\BSON\toPHP():
function apply_type_map_to_document($document, array $typeMap) { if ( ! is_array($document) && ! is_object($document)) { throw InvalidArgumentException::invalidType('$document', $document, 'array or object'); } $tm=[]; foreach($typeMap as $k=>$v){ $tm[$k]=$v; } return \MongoDB\BSON\toPHP(\MongoDB\BSON\fromPHP($document), $tm); }
Thank you for your time.
PS : I already describe the problem in this Stack overflow question/answer
- related to
-
PHPC-2456 Dereference array zvals when reading "fieldPaths" type map option
- Closed