Issue Feature Under Review

#111412Restrict queries to a page tree without a list of page ids

Benni Mack 11/11/26, 15:07 updated 11/19/26, 08:45

Description

Several backend modules restrict their queries to the pages below a page: they first collect the uids of all these pages and then add them to the query as “pid IN (…)”:

  • the record list with search levels (DatabaseRecordList::getSearchableWebmounts())
  • the log module with a depth (LogEntryRepository)
  • the recycler (DeletedRecords, which even splits the list into chunks and caches it per request)

With large page trees, the uid list makes these queries slow, and it exceeds the number of placeholders a database accepts in one statement (“Prepared statement contains too many placeholders”, see #95812, #86859, #92493).

The PageDescendantsRepository (#111406) fetches the descendants of pages with one recursive common table expression (CTE). It gets a method that adds this CTE as a subquery to the constraint of another query, so the database resolves the page tree within the query itself, and no uid list is built anymore. The same workspace handling and access constraints (e.g. the page permissions of a backend user) apply as for fetching the descendants. If the queried table lives on another database connection than the pages table, the constraint falls back to a list of uids without placeholders.

The record list, the log module and the recycler use the new constraint. The record list then also searches pages that only exist in the workspace of the user.

The live search (#93937, Gerrit 96668) can make use of the same constraint.

Reviews 1

History 03