-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Description
Bug Report
| Q | A |
|---|---|
| Version | 3.5.x |
| Previous Version if the bug is a regression | N/A (new feature bug) |
Summary
When isNativeLazyObjectsEnabled() is true, calling EntityManager::initializeObject() or UnitOfWork::initializeObject() with a non-managed object throws an exception instead of performing a no-op as specified by the ObjectManager interface contract.
Current behavior
Calling initializeObject() on objects that are not Doctrine entities results in an exception:
The class 'App\Dto\TestDto' was not found in the chain configured namespaces App\Entity
This breaks the documented interface contract which states the method should be "a no-op for other objects."
Expected behavior
According to the ObjectManager interface documentation:
The method should silently do nothing when called with non-Doctrine entities, not throw an exception.
How to reproduce
<?php
use Doctrine\ORM\ORMSetup;
use Doctrine\ORM\EntityManager;
$config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/src'], true);
$config->enableNativeLazyObjects(true);
$entityManager = EntityManager::create($connectionParams, $config);
$nonEntity = new stdClass();
$nonEntity->someProperty = 'test';
$entityManager->initializeObject($nonEntity);
// Exception: The class 'stdClass' was not found in the chain configured namespacesMetadata
Metadata
Assignees
Labels
No labels