Review main Abandoned

96031[BUGFIX] Prevent cyclic page recursion in genTree()

Stefan Froemken CR 0 V 0 Normal +204 −39 updated 11/11/26, 09:41

Commit message

Circular page references, such as parent-child PID cycles or self-
referencing t3ver_oid values, cause DatabaseIntegrityCheck::genTree()
to enter an infinite recursion loop. This exhausts prepared statements
on database servers and triggers an unrecoverable exception.
Furthermore, the previous recursive query approach causes N+1 query
overhead on large page trees.

All page records are now fetched upfront in a single database query
and organized into an in-memory adjacency list. Visited page UIDs
are tracked during traversal to detect cyclic references and store
them in the cyclic pages collection. This stops recursion loops,
eliminates prepared statement exhaustion, and reduces query overhead.

Review

  • Code review CR 0
  • Verified V 0
    • core-ci +1 CI

Issues 1

Files 4

Review log 57

  1. Stefan Froemken uploaded patch set 1 09/24/26, 10:58

  2. core-ci voted on patch set 1 V -1 09/24/26, 11:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109147

  3. Stefan Froemken uploaded patch set 2 V -1 09/24/26, 12:12

  4. core-ci voted on patch set 2 V +1 09/24/26, 12:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109153

  5. Benni Mack commented on patch set 2 09/24/26, 12:23

    looking at the issue, I feel you should try a tool like dbdoctor first, and see what's wrong with your recursion. We have much larger setups with 100.000+ pages, and db integrity is no issue.
  6. Stefan Froemken commented on patch set 2 09/26/26, 10:56

    Reply Unresolved

    Hi Benni. For testing I have created over 20.000 pages records and yes, I can still open the statistics module. Then I have changed pid and t3ver_oid columns of some pages manually to itself and can reproduce the issue here. You recommend me to execute dbdoctor (Slack). I have just executed: "ddev typo3 dbdoctor:health --mode=execute --file=/var/www/html/queries.log -vvv" All checks results into "[OK] No affected records found" and there is no created log file in container. After a reload and 8 minutes of waiting in DB Check the error message still appears: "Can't create more than max_prepared_stmt_count statements".
  7. Benni Mack abandoned the change 11/11/26, 09:41

    wont do it like this