[PR #12297] test persist an uninitialized lazy ghost #13665

Open
opened 2026-01-22 16:18:00 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/12297
Author: @soyuka
Created: 11/29/2025
Status: 🔄 Open

Base: 3.6.xHead: test


📝 Commits (1)

  • fa61d56 test persist an uninitialized lazy ghost

📊 Changes

1 file changed (+24 additions, -0 deletions)

View changed files

📝 tests/Tests/ORM/Functional/StandardEntityPersisterTest.php (+24 -0)

📄 Description

We've the use case inside API Platform where the JsonStreamer deserializes a JSON into a Lazy Ghost as while its not consumed (streaming) we don't need to initialize this object. Therefore at some point we try to persist an uninitialized lazy ghost and it'll likely throw "column title must not be null".

    public function testPersistLazyGhost(): void 
    {
        if (PHP_VERSION_ID < 80400) {
            $this->markTestSkipped('Lazy objects are only available in PHP 8.4+.');
        }

        $initialized = false;
        $reflector = new \ReflectionClass(PersistentEntity::class);
        $lazyGhost = $reflector->newLazyGhost(function (PersistentEntity $object) use (&$initialized) {
            $initialized = true;
            $object->setName('LazyGhostInitialized');
        });

        self::assertFalse($initialized, 'Lazy ghost should not be initialized before persist.');
        $this->_em->persist($lazyGhost);
        $this->_em->flush();
        self::assertTrue($initialized, 'Lazy ghost should be initialized during flush.');
        $this->_em->clear();
        $retrievedEntity = $this->_em->find(PersistentEntity::class, $lazyGhost->getId());
        self::assertNotNull($retrievedEntity);
        self::assertEquals('LazyGhostInitialized', $retrievedEntity->name);
    }

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/12297 **Author:** [@soyuka](https://github.com/soyuka) **Created:** 11/29/2025 **Status:** 🔄 Open **Base:** `3.6.x` ← **Head:** `test` --- ### 📝 Commits (1) - [`fa61d56`](https://github.com/doctrine/orm/commit/fa61d5688a0178325cb16b8affc38e6b8d53c2b4) test persist an uninitialized lazy ghost ### 📊 Changes **1 file changed** (+24 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tests/Tests/ORM/Functional/StandardEntityPersisterTest.php` (+24 -0) </details> ### 📄 Description We've the use case inside API Platform where the JsonStreamer deserializes a JSON into a Lazy Ghost as while its not consumed (streaming) we don't need to initialize this object. Therefore at some point we try to persist an uninitialized lazy ghost and it'll likely throw "column title must not be null". ```php public function testPersistLazyGhost(): void { if (PHP_VERSION_ID < 80400) { $this->markTestSkipped('Lazy objects are only available in PHP 8.4+.'); } $initialized = false; $reflector = new \ReflectionClass(PersistentEntity::class); $lazyGhost = $reflector->newLazyGhost(function (PersistentEntity $object) use (&$initialized) { $initialized = true; $object->setName('LazyGhostInitialized'); }); self::assertFalse($initialized, 'Lazy ghost should not be initialized before persist.'); $this->_em->persist($lazyGhost); $this->_em->flush(); self::assertTrue($initialized, 'Lazy ghost should be initialized during flush.'); $this->_em->clear(); $retrievedEntity = $this->_em->find(PersistentEntity::class, $lazyGhost->getId()); self::assertNotNull($retrievedEntity); self::assertEquals('LazyGhostInitialized', $retrievedEntity->name); } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 16:18:00 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#13665