-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.2.8
-
Component/s: None
-
None
The following segfaults for BSON encoding:
class MyIndirectlyRecursiveWrapper implements MongoDB\BSON\Serializable { public $x => 1; public function bsonSerialize() { return ['x' => $this]; } }
The more direct example, where bsonSerialize() returns $this, is caught due to an earlier check that the return value is an array or stdClass.
On a related note, bson-fromPHP-004.phpt currently has tests for circular references in PHP arrays and generic objects, which result in the circular reference being ignored with no error. We should be throwing an exception instead of silently ignoring recursion.