diff --git a/lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php b/lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php index 780232820a..7283586a76 100644 --- a/lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php +++ b/lib/Doctrine/ODM/MongoDB/Proxy/Factory/StaticProxyFactory.php @@ -77,7 +77,9 @@ public function generateProxyClasses(array $classes) : int static function () { // empty closure, serves its purpose, for now }, - $this->skippedFieldsFqns($metadata) + [ + 'skippedProperties' => $this->skippedFieldsFqns($metadata), + ] ); } diff --git a/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1990Test.php b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1990Test.php new file mode 100644 index 0000000000..6eac928e84 --- /dev/null +++ b/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket/GH1990Test.php @@ -0,0 +1,51 @@ +dm->getClassMetadata(GH1990Document::class); + $this->dm->getProxyFactory()->generateProxyClasses([$metadata]); + + $parent = new GH1990Document(null); + $child = new GH1990Document($parent); + $this->dm->persist($parent); + $this->dm->persist($child); + + $this->dm->flush(); + $this->dm->clear(); + + $this->dm->find(GH1990Document::class, $child->getId()); + + self::assertInstanceOf(GH1990Document::class, $child); + } +} + +/** @ODM\Document */ +class GH1990Document +{ + /** @ODM\Id */ + private $id; + + /** @ODM\ReferenceOne(targetDocument=GH1990Document::class) */ + private $parent; + + public function __construct(?GH1990Document $parent) + { + $this->parent = $parent; + } + + public function getId() : ?string + { + return $this->id; + } +}