Skip to content

#166 - Fail at compile time when Doctrine ORM 2 is used without lazy ghost objects - #167

Merged
njoubert-cleverage merged 1 commit into
mainfrom
166
Oct 15, 2026
Merged

njoubert-cleverage merged 1 commit into
mainfrom
166

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #166 (option 1: keep the Doctrine ORM 2 support). The entities have readonly properties since v3.2 (ProcessExecution::$code, $startDate, $logFilename, LogRecord::$channel…), which the legacy proxies of Doctrine ORM 2 cannot handle: loading an entity proxy fails with Cannot unset readonly property ... from scope Proxies\__CG__\....

Changes

  • New internal CheckDoctrineLazyGhostObjectsPass (registered by CleverAgeUiProcessBundle::build()): with ORM 2 (detected as the DoctrineBundle does, ProxyFactory::resetUninitializedProxy()), the container compilation fails when the doctrine.orm.enable_lazy_ghost_objects parameter (DoctrineBundle 2) is not true:

    The entities of the CleverAge UiProcessBundle have readonly properties, which are not supported by the legacy proxies of Doctrine ORM 2: set "doctrine.orm.enable_lazy_ghost_objects" to true (as the Symfony recipe of the DoctrineBundle does), or upgrade to Doctrine ORM 3.

    Nothing is checked with ORM 3 (always lazy ghost or native lazy objects), nor without the DoctrineBundle parameter.

  • Docs: the database setup (docs/index.md) documents enable_lazy_ghost_objects: true for ORM 2; new troubleshooting entry for the PHP error.

  • Tests: CheckDoctrineLazyGhostObjectsPassTest (failure on ORM 2 without lazy ghost objects, valid configurations, default detection of the installed ORM), the registration of the pass by the bundle; the tests booting the kernel declare the pass as used (#[UsesClass], else risky under coverage). The test kernel comment refers to the pass (it already enables the lazy ghost objects on ORM 2 since Use the PHP 8.3 to 8.5 functions through the Symfony polyfills, and configure Rector accordingly #164).

  • CHANGELOG (Latest).

Checks

  • PHP 8.5, highest dependencies (ORM 3): 410 tests OK, also with code coverage (no risky test). PHPStan, PHP-CS-Fixer, Rector OK.
  • PHP 8.2, lowest dependencies (ORM 2.20.0, DoctrineBundle 2.18.0): 410 tests OK (2 deprecations of masterminds/html5, as on main).
  • Same lowest setup with the test kernel workaround disabled: the kernel fails to compile with the message above, instead of the readonly error at runtime.

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

None for working setups. An application on Doctrine ORM 2 without lazy ghost objects (already failing when an entity proxy of the bundle is loaded) now fails at compile time with the message above, and must set doctrine.orm.enable_lazy_ghost_objects: true.

🤖 Generated with Claude Code

…ghost objects

The entities have readonly properties (since v3.2), which the legacy proxies
of Doctrine ORM 2 cannot handle ("Cannot unset readonly property ... from
scope Proxies\__CG__\..." when an entity proxy is loaded).

- New internal CheckDoctrineLazyGhostObjectsPass: with ORM 2, the container
  compilation fails with an explicit message when
  doctrine.orm.enable_lazy_ghost_objects is not true. Nothing changes with
  ORM 3 (always lazy ghost or native lazy objects).
- Documentation: requirement in the database setup, troubleshooting entry.
- Tests: the pass, its registration by the bundle; the kernel tests declare
  it as used.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage
njoubert-cleverage merged commit e0935ab into main Oct 15, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doctrine ORM 2: readonly entity properties fail with the legacy proxies

1 participant