Skip to content

fix #95 Detach the written log entities without detaching the process execution - #96

Merged
njoubert-cleverage merged 1 commit into
mainfrom
95
Oct 5, 2026
Merged

njoubert-cleverage merged 1 commit into
mainfrom
95

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #95.

  • DoctrineProcessHandler::flush(): keeps the LogRecord entities created from the buffered records and detaches them after the flush; the loop detaching the Monolog records (no effect) is removed
  • LogRecord::$processExecution: cascade reduced from all to persist, so that detaching a log entity does not detach the current ProcessExecution (which the next ProcessExecutionManager::save() would insert again, silently). ORM level only: no schema change, no migration (doctrine:schema:update --dump-sql output identical with and without this change)

Tests:

  • DoctrineProcessHandlerEntityManagerTest (new, entity manager of the test application, SQLite): 3 batches of 100 records; after each flush, no LogRecord left in the identity map and the process execution still managed; then save() updates the execution instead of inserting it again (a single finish row, 300 log records attached to it)
  • DoctrineProcessHandlerTest: only the persisted log entities are detached; nothing is detached without a current process execution

Checked:

  • bundle (Symfony 8.1, PHP 8.5, doctrine/orm 3.7): 330 tests OK. Without the fix, the new test fails (log entities still managed); with the detach only (cascade all kept), it fails too (process execution no longer managed). PHPStan, PHP-CS-Fixer, Rector OK
  • process-bundle-demo (Symfony 7.4): demo.logger ends with the finish status and its logs attached

Requirements

  • Documentation updates
    • Reference
    • Changelog
  • Unit tests

Breaking changes

None in practice: only an application removing or refreshing LogRecord entities and relying on the cascade to their process execution would be affected (already a dangerous behaviour: with onDelete: CASCADE, removing one log record removed the execution and all its logs).

🤖 Generated with Claude Code

…out cascading to the process execution

The Monolog records were detached instead of the LogRecord entities: the identity map grew with every log during
long processes. LogRecord::$processExecution cascade reduced from `all` to `persist`: with the `detach` cascade, the
current process execution was detached too, then inserted again by the next ProcessExecutionManager::save().

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage njoubert-cleverage added the bug Something isn't working label Oct 5, 2026
@njoubert-cleverage
njoubert-cleverage merged commit 001843b into main Oct 5, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DoctrineProcessHandler never detaches the log entities: identity map grows during long processes

1 participant