doctrine/orm · error · LogicException
Rejecting ID collisions in the identity map cannot be disabl
Error message
Rejecting ID collisions in the identity map cannot be disabled anymore. Please remove the call to setRejectIdCollisionInIdentityMap(false).
What it means
LogicException from Configuration::setRejectIdCollisionInIdentityMap() (src/Configuration.php:700). Since doctrine/orm 3, the identity map always rejects two entities of the same type holding the same identifier; the setter remains only so old call sites fail loudly instead of silently re-enabling the unsound behavior. Passing false throws.
Source
Thrown at src/Configuration.php:700
return true;
}
/** @deprecated lazy ghost objects cannot be disabled */
public function setLazyGhostObjectEnabled(bool $flag): void
{
if (! $flag) {
throw new LogicException(<<<'EXCEPTION'
The lazy ghost object feature cannot be disabled anymore.
Please remove the call to setLazyGhostObjectEnabled(false).
EXCEPTION);
}
}
/** @deprecated rejecting ID collisions in the identity map cannot be disabled */
public function setRejectIdCollisionInIdentityMap(bool $flag): void
{
if (! $flag) {
throw new LogicException(<<<'EXCEPTION'
Rejecting ID collisions in the identity map cannot be disabled anymore.
Please remove the call to setRejectIdCollisionInIdentityMap(false).
EXCEPTION);
}
}
/**
* @deprecated rejecting ID collisions in the identity map is always enabled
*
* @return true
*/
public function isRejectIdCollisionInIdentityMapEnabled(): bool
{
return true;
}
public function setEagerFetchBatchSize(int $batchSize = 100): void
{View on GitHub (pinned to d9b9ff7301)
Solutions
- Remove the setRejectIdCollisionInIdentityMap(false) call from bootstrap/config.
- Fix the underlying duplicate-identity problem (the reason the flag was disabled): don't mix DETACHED and MANAGED instances with the same ID, use $em->find() or merge consistently, correct entity inheritance/ID generation mappings.
- Update any bundle/package that sets the flag on your behalf.
- If the throw happens in vendor code, catch LogicException temporarily around bootstrap and file an upstream issue/patch.
Example fix
// before $config = new Configuration(); $config->setRejectIdCollisionInIdentityMap(false); // tolerated in ORM 2, throws in ORM 3 // after $config = new Configuration(); // rejection is always enabled; fix the duplicate-ID usage instead $entity = $em->find(User::class, $id); // instead of re-persisting a detached copy
Defensive patterns
Strategy: validation
Validate before calling
// Do not call the setter. If you must accept arbitrary legacy config: $legacyDisableFlag = false; // from old config // ignore it: rejection is always enabled in ORM 3
Try / catch
try {
include $legacyBootstrap; // may call setRejectIdCollisionInIdentityMap(false)
} catch (\LogicException $e) {
// remove the call upstream instead of suppressing long-term
} Prevention
- Search for setRejectIdCollisionInIdentityMap when upgrading to ORM 3 and remove calls.
- Fix duplicate-identity usage (detached entities with same ID) rather than disabling the safety check.
- Cover entity lifecycle flows with tests that flush the same ID once; the check protects data integrity.
When it happens
Trigger: Calling $configuration->setRejectIdCollisionInIdentityMap(false) — an ORM 2.x escape hatch some projects used when a database allowed duplicate IDs per type (e.g. entity hierarchies sharing an ID sequence or DETACHED entities re-persisted). Any such call now aborts configuration.
Common situations: doctrine/orm 2 -> 3 upgrades where the old flag was set to false to silence identity-map warnings; legacy bootstrap copied between projects; packages that exposed a 'safe_identity_map' toggle around this setter.
Related errors
- The lazy ghost object feature cannot be disabled anymore. Pl
- If you want to use a "READ_WRITE" cache an implementation of
- Lazy loading proxies require PHP 8.4 or higher.
- Unknown property {key} on class {class}
- The $reportFieldsWhereDeclared argument is no longer support
AI-assisted analysis of doctrine/orm@d9b9ff7301 (2026-08-21).
Data as JSON: /api/errors/aa9e5137420cd2df.
Report an issue: GitHub.