{"record":{"id":"aa9e5137420cd2df","repo":"doctrine/orm","slug":"rejecting-id-collisions-in-the-identity-map-cannot","errorCode":null,"errorMessage":"Rejecting ID collisions in the identity map cannot be disabled anymore.\nPlease remove the call to setRejectIdCollisionInIdentityMap(false).","messagePattern":"Rejecting ID collisions in the identity map cannot be disabled anymore\\.\nPlease remove the call to setRejectIdCollisionInIdentityMap\\(false\\)\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Configuration.php","lineNumber":700,"sourceCode":"        return true;\n    }\n\n    /** @deprecated lazy ghost objects cannot be disabled */\n    public function setLazyGhostObjectEnabled(bool $flag): void\n    {\n        if (! $flag) {\n            throw new LogicException(<<<'EXCEPTION'\n            The lazy ghost object feature cannot be disabled anymore.\n            Please remove the call to setLazyGhostObjectEnabled(false).\n            EXCEPTION);\n        }\n    }\n\n    /** @deprecated rejecting ID collisions in the identity map cannot be disabled */\n    public function setRejectIdCollisionInIdentityMap(bool $flag): void\n    {\n        if (! $flag) {\n            throw new LogicException(<<<'EXCEPTION'\n                Rejecting ID collisions in the identity map cannot be disabled anymore.\n                Please remove the call to setRejectIdCollisionInIdentityMap(false).\n                EXCEPTION);\n        }\n    }\n\n    /**\n     * @deprecated rejecting ID collisions in the identity map is always enabled\n     *\n     * @return true\n     */\n    public function isRejectIdCollisionInIdentityMapEnabled(): bool\n    {\n        return true;\n    }\n\n    public function setEagerFetchBatchSize(int $batchSize = 100): void\n    {","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Configuration.php#L682-L718","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n$config = new Configuration();\n$config->setRejectIdCollisionInIdentityMap(false); // tolerated in ORM 2, throws in ORM 3\n\n// after\n$config = new Configuration();\n// rejection is always enabled; fix the duplicate-ID usage instead\n$entity = $em->find(User::class, $id); // instead of re-persisting a detached copy","handlingStrategy":"validation","validationCode":"// Do not call the setter. If you must accept arbitrary legacy config:\n$legacyDisableFlag = false; // from old config\n// ignore it: rejection is always enabled in ORM 3","typeGuard":null,"tryCatchPattern":"try {\n    include $legacyBootstrap; // may call setRejectIdCollisionInIdentityMap(false)\n} catch (\\LogicException $e) {\n    // remove the call upstream instead of suppressing long-term\n}","preventionTips":["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."],"tags":["doctrine-orm","upgrade","identity-map","configuration"],"backgroundTag":"removed-api-call","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}