{"record":{"id":"fc00020e78fed500","repo":"doctrine/orm","slug":"the-lazy-ghost-object-feature-cannot-be-disabled-a","errorCode":null,"errorMessage":"The lazy ghost object feature cannot be disabled anymore.\nPlease remove the call to setLazyGhostObjectEnabled(false).","messagePattern":"The lazy ghost object feature cannot be disabled anymore\\.\nPlease remove the call to setLazyGhostObjectEnabled\\(false\\)\\.","errorType":"exception","errorClass":"LogicException","httpStatus":null,"severity":"error","filePath":"src/Configuration.php","lineNumber":689,"sourceCode":"\n        $this->attributes['nativeLazyObjects'] = $nativeLazyObjects;\n    }\n\n    /**\n     * @deprecated lazy ghost objects are always enabled\n     *\n     * @return true\n     */\n    public function isLazyGhostObjectEnabled(): bool\n    {\n        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    /**","sourceCodeStart":671,"sourceCodeEnd":707,"githubUrl":"https://github.com/doctrine/orm/blob/d9b9ff73016bf598ae07515f97289ce8074e97a5/src/Configuration.php#L671-L707","documentation":"LogicException from Configuration::setLazyGhostObjectEnabled() (src/Configuration.php:689). The method is kept only for backwards compatibility, but lazy ghost objects are unconditionally enabled since doctrine/orm 3 — passing false means asking to re-enable the removed proxy-based behavior, which the library refuses.","triggerScenarios":"Any call $configuration->setLazyGhostObjectEnabled(false) — typically left-over upgrade-shim code or old framework/bundle config (Symfony < 6.3-era doctrine config, internal packages) that toggled the flag in ORM 2.13-2.x where both proxy mechanisms existed.","commonSituations":"Upgrading doctrine/orm from 2.x to 3.x while bootstrap still calls the setter; bundles built against ORM 2 that 'disable' ghost objects for legacy proxies; copy-pasted performance-tuning snippets from pre-3.0 blog posts.","solutions":["Delete the setLazyGhostObjectEnabled(false) call — ghost objects are always on in ORM 3 and the call does nothing useful with true either.","Update the framework/package that emits the call (Symfony doctrine-bundle and similar shims learned to drop it; composer update the bridge).","If third-party code you cannot patch calls it, wrap bootstrap in try/catch (LogicException) to degrade gracefully, and file an issue upstream.","Migrate code that depended on old Proxy behavior (Proxy::initialize checks, __clang__ hooks) to ghost-object semantics."],"exampleFix":"// before (ORM 2.x-era bootstrap)\n$config = new Configuration();\n$config->setLazyGhostObjectEnabled(false); // LogicException in ORM 3\n\n// after\n$config = new Configuration();\n// ghost objects are always enabled in ORM 3 — call removed","handlingStrategy":"validation","validationCode":"// Simply never call it; if wrapping third-party bootstrap:\nif (method_exists($config, 'setLazyGhostObjectEnabled')) {\n    try {\n        $config->setLazyGhostObjectEnabled(true); // no-op accepted; false throws\n    } catch (\\LogicException) {\n        // ORM 3: feature always on — nothing to do\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    $legacyBootstrap->configure($config); // may call setLazyGhostObjectEnabled(false)\n} catch (\\LogicException $e) {\n    // drop the legacy toggle and continue; ghost objects are always enabled in ORM 3\n}","preventionTips":["Delete ORM 2.x performance toggles during 3.x upgrade code reviews.","Grep the codebase and bundles for setLazyGhostObjectEnabled after upgrading doctrine/orm.","Keep framework bridges (doctrine-bundle etc.) updated so they stop emitting removed toggles."],"tags":["doctrine-orm","upgrade","deprecated-api","configuration"],"backgroundTag":"removed-api-call","analyzedSha":"d9b9ff73016bf598ae07515f97289ce8074e97a5","analyzedAt":"2026-08-21T06:13:15.863Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}