doctrine/orm · error · LogicException
The lazy ghost object feature cannot be disabled anymore. Pl
Error message
The lazy ghost object feature cannot be disabled anymore. Please remove the call to setLazyGhostObjectEnabled(false).
What it means
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.
Source
Thrown at src/Configuration.php:689
$this->attributes['nativeLazyObjects'] = $nativeLazyObjects;
}
/**
* @deprecated lazy ghost objects are always enabled
*
* @return true
*/
public function isLazyGhostObjectEnabled(): bool
{
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);
}
}
/**View on GitHub (pinned to d9b9ff7301)
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.
Example fix
// before (ORM 2.x-era bootstrap) $config = new Configuration(); $config->setLazyGhostObjectEnabled(false); // LogicException in ORM 3 // after $config = new Configuration(); // ghost objects are always enabled in ORM 3 — call removed
Defensive patterns
Strategy: validation
Validate before calling
// Simply never call it; if wrapping third-party bootstrap:
if (method_exists($config, 'setLazyGhostObjectEnabled')) {
try {
$config->setLazyGhostObjectEnabled(true); // no-op accepted; false throws
} catch (\LogicException) {
// ORM 3: feature always on — nothing to do
}
} Try / catch
try {
$legacyBootstrap->configure($config); // may call setLazyGhostObjectEnabled(false)
} catch (\LogicException $e) {
// drop the legacy toggle and continue; ghost objects are always enabled in ORM 3
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Rejecting ID collisions in the identity map cannot be disabl
- 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/fc00020e78fed500.
Report an issue: GitHub.