Issue Task Under Review

#111416Find the subpages of a page with one query when copying and deleting pages

Benni Mack 11/11/26, 16:38 updated 11/19/26, 08:45

Description

The DataHandler and two cleanup commands still walk the page tree with one query per page:

  • DataHandler::int_pageTreeInfo() collects the subpages to copy along with a page (and to fix unique slugs after moving a page), plus a PlainDataResolver run and one getRecord() per page in a workspace
  • DataHandler::getSubPagesOfPage() collects the subpages to delete or discard along with a page, including pages new in any workspace
  • the commands “cleanup:deletedrecords” and “cleanup:versions” walk the whole page tree including deleted pages and the versions of all workspaces, and recurse endlessly if versions reference each other

The DataHandler fetches the subpages with the PageDescendantsRepository (#111406) instead, with one query, keeping the order the pages are copied and deleted in. Pages new in a workspace below the page to delete are found with the page tree constraint of #111412.

The commands fetch all pages with one query and walk the page tree in PHP, visiting each page once.

Measured with 780 pages: copying needs 1 instead of 781 queries to collect the subpages (2185 in a workspace), deleting 2 instead of 781. The cleanup commands save one to three queries per page (18522 to 12671 and 9546 to 5431 queries).

Reviews 1

History 03