From 9ec730822dafbcb3a3f844edb9f0bc43137a70d6 Mon Sep 17 00:00:00 2001 From: Markus Friedrich Date: Wed, 30 Aug 2023 10:57:07 +0200 Subject: [PATCH] [TASK] Ensure recursive page update on page movement If a page is moved, subpages have to be considered, e.g. as rootline and slug might have changed. Also the MountPagesUpdater has to be triggered to ensure mounted pages will be updated too. This commit adds the missing recursive updates, an extension to the RecordMovedEvent and PageMovedEvent is done allowing that recursive updates on move operations will only be done if the parent page of the page has changed. Resolves: #206 --- .../Queue/UpdateHandler/DataUpdateHandler.php | 20 ++++- .../ImmediateProcessingEventListener.php | 4 +- .../Events/AbstractRecordMovedEvent.php | 51 ++++++++++++ .../UpdateHandler/Events/PageMovedEvent.php | 2 +- .../UpdateHandler/Events/RecordMovedEvent.php | 2 +- .../Queue/UpdateHandler/GarbageHandler.php | 27 +++++-- Classes/GarbageCollector.php | 20 +++-- Classes/IndexQueue/RecordMonitor.php | 19 ++++- ..._collect_garbage_if_page_tree_is_moved.csv | 9 +++ Tests/Integration/GarbageCollectorTest.php | 81 ++++++++++++++++++- .../can_handle_mounted_page_tree_movement.csv | 7 ++ .../can_handle_page_tree_movement.csv | 9 +++ .../IndexQueue/RecordMonitorTest.php | 66 +++++++++++++-- .../UpdateHandler/GarbageHandlerTest.php | 5 -- 14 files changed, 288 insertions(+), 34 deletions(-) create mode 100644 Classes/Domain/Index/Queue/UpdateHandler/Events/AbstractRecordMovedEvent.php create mode 100644 Tests/Integration/Fixtures/can_collect_garbage_if_page_tree_is_moved.csv create mode 100644 Tests/Integration/IndexQueue/Fixtures/can_handle_mounted_page_tree_movement.csv create mode 100644 Tests/Integration/IndexQueue/Fixtures/can_handle_page_tree_movement.csv diff --git a/Classes/Domain/Index/Queue/UpdateHandler/DataUpdateHandler.php b/Classes/Domain/Index/Queue/UpdateHandler/DataUpdateHandler.php index d42c7d1878..1bb5528112 100644 --- a/Classes/Domain/Index/Queue/UpdateHandler/DataUpdateHandler.php +++ b/Classes/Domain/Index/Queue/UpdateHandler/DataUpdateHandler.php @@ -231,12 +231,27 @@ public function handleVersionSwap(int $uid, string $table): void /** * Handle page move * + * @param int $uid + * @param int|null $previousParentId * @throws DBALException * @throws UnexpectedTYPO3SiteInitializationException */ - public function handleMovedPage(int $uid): void + public function handleMovedPage(int $uid, ?int $previousParentId = null): void { + $excludedPages = $this->pagesRepository->findAllPagesWithinNoSearchSubEntriesMarkedPages(); + if (in_array($uid, $excludedPages)) { + return; + } + $this->applyPageChangesToQueue($uid); + + if ($previousParentId !== null) { + $pageRecord = BackendUtility::getRecord('pages', $uid); + if ($pageRecord !== null && (int)$pageRecord['pid'] !== $previousParentId) { + $treePageIds = $this->getSubPageIds($uid); + $this->updatePageIdItems($treePageIds); + } + } } /** @@ -483,7 +498,8 @@ protected function getIsTranslationParentRecordEnabled(string $recordTable, int protected function updatePageIdItems(array $treePageIds): void { foreach ($treePageIds as $treePageId) { - $this->indexQueue->updateItem('pages', $treePageId); + $this->indexQueue->updateItem('pages', $treePageId, time()); + $this->mountPageUpdater->update($treePageId); } } diff --git a/Classes/Domain/Index/Queue/UpdateHandler/EventListener/ImmediateProcessingEventListener.php b/Classes/Domain/Index/Queue/UpdateHandler/EventListener/ImmediateProcessingEventListener.php index d19a06258d..e4bdcdee19 100644 --- a/Classes/Domain/Index/Queue/UpdateHandler/EventListener/ImmediateProcessingEventListener.php +++ b/Classes/Domain/Index/Queue/UpdateHandler/EventListener/ImmediateProcessingEventListener.php @@ -104,7 +104,7 @@ protected function handleVersionSwappedEvent(VersionSwappedEvent $event): void protected function handleRecordMovedEvent(RecordMovedEvent $event): void { if ($event->isPageUpdate()) { - $this->getDataUpdateHandler()->handleMovedPage($event->getUid()); + $this->getDataUpdateHandler()->handleMovedPage($event->getUid(), $event->getPreviousParentId()); } else { $this->getDataUpdateHandler()->handleMovedRecord($event->getUid(), $event->getTable()); } @@ -150,7 +150,7 @@ protected function handleRecordDeletedEvent(RecordDeletedEvent $event): void */ protected function handlePageMovedEvent(PageMovedEvent $event): void { - $this->getGarbageHandler()->handlePageMovement($event->getUid()); + $this->getGarbageHandler()->handlePageMovement($event->getUid(), $event->getPreviousParentId()); } /** diff --git a/Classes/Domain/Index/Queue/UpdateHandler/Events/AbstractRecordMovedEvent.php b/Classes/Domain/Index/Queue/UpdateHandler/Events/AbstractRecordMovedEvent.php new file mode 100644 index 0000000000..6f298a74fa --- /dev/null +++ b/Classes/Domain/Index/Queue/UpdateHandler/Events/AbstractRecordMovedEvent.php @@ -0,0 +1,51 @@ +previousParentId = $pid; + } + + /** + * Returns the record's pid prior moving + * + * @return int|null + */ + public function getPreviousParentId(): ?int + { + return $this->previousParentId; + } +} diff --git a/Classes/Domain/Index/Queue/UpdateHandler/Events/PageMovedEvent.php b/Classes/Domain/Index/Queue/UpdateHandler/Events/PageMovedEvent.php index e2b3b7e052..8036065881 100644 --- a/Classes/Domain/Index/Queue/UpdateHandler/Events/PageMovedEvent.php +++ b/Classes/Domain/Index/Queue/UpdateHandler/Events/PageMovedEvent.php @@ -20,7 +20,7 @@ /** * Event fired if a page is moved */ -class PageMovedEvent extends AbstractDataUpdateEvent +class PageMovedEvent extends AbstractRecordMovedEvent { /** * Constructor diff --git a/Classes/Domain/Index/Queue/UpdateHandler/Events/RecordMovedEvent.php b/Classes/Domain/Index/Queue/UpdateHandler/Events/RecordMovedEvent.php index 577341f85c..3bfe8737ed 100644 --- a/Classes/Domain/Index/Queue/UpdateHandler/Events/RecordMovedEvent.php +++ b/Classes/Domain/Index/Queue/UpdateHandler/Events/RecordMovedEvent.php @@ -20,4 +20,4 @@ /** * Event fired if a record is moved */ -class RecordMovedEvent extends AbstractDataUpdateEvent {} +class RecordMovedEvent extends AbstractRecordMovedEvent {} diff --git a/Classes/Domain/Index/Queue/UpdateHandler/GarbageHandler.php b/Classes/Domain/Index/Queue/UpdateHandler/GarbageHandler.php index f79e2f7986..b82bd8a074 100644 --- a/Classes/Domain/Index/Queue/UpdateHandler/GarbageHandler.php +++ b/Classes/Domain/Index/Queue/UpdateHandler/GarbageHandler.php @@ -22,6 +22,7 @@ use Doctrine\DBAL\Exception as DBALException; use PDO; use Throwable; +use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException; use TYPO3\CMS\Core\Utility\GeneralUtility; use UnexpectedValueException; @@ -79,20 +80,30 @@ public function collectGarbage(string $table, int $uid): void /** * Handles moved pages * + * As rootline and page slug might have changed on page movement, + * document have to be removed from Solr. Reindexing is taken + * care of by the DataUpdateHandler. + * + * @param int $uid + * @param int|null $previousParentId * @throws DBALException * @throws UnexpectedTYPO3SiteInitializationException */ - public function handlePageMovement(int $uid): void + public function handlePageMovement(int $uid, ?int $previousParentId = null): void { - // TODO the below comment is not valid anymore, pid has been removed from doc ID - // ...still needed? - - // must be removed from index since the pid changes and - // is part of the Solr document ID $this->collectGarbage('pages', $uid); - // now re-index with new properties - $this->indexQueue->updateItem('pages', $uid); + // collect garbage of subpages + if ($previousParentId !== null) { + $pageRecord = BackendUtility::getRecord('pages', $uid); + if ($pageRecord !== null && (int)$pageRecord['pid'] !== $previousParentId) { + $subPageIds = $this->getSubPageIds($uid); + array_walk( + $subPageIds, + fn (int $subPageId) => $this->collectGarbage('pages', $subPageId) + ); + } + } } /** diff --git a/Classes/GarbageCollector.php b/Classes/GarbageCollector.php index bf17356fa1..7ef8b7ae3e 100644 --- a/Classes/GarbageCollector.php +++ b/Classes/GarbageCollector.php @@ -23,6 +23,7 @@ use ApacheSolrForTypo3\Solr\Domain\Index\Queue\UpdateHandler\GarbageHandler; use ApacheSolrForTypo3\Solr\System\TCA\TCAService; use Psr\EventDispatcher\EventDispatcherInterface; +use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -67,11 +68,18 @@ public function __construct(TCAService $TCAService = null, EventDispatcherInterf */ public function processCmdmap_preProcess($command, $table, $uid, $value, DataHandler $tceMain): void { - // workspaces: collect garbage only for LIVE workspace - if ($command === 'delete' && ($GLOBALS['BE_USER']->workspace ?? null) == 0) { + // workspaces: process command map only for LIVE workspace + if (($GLOBALS['BE_USER']->workspace ?? null) != 0) { + return; + } + + if ($command === 'delete') { $this->eventDispatcher->dispatch( new RecordDeletedEvent((int)$uid, (string)$table) ); + } elseif ($command === 'move' && $table === 'pages') { + $pageRow = BackendUtility::getRecord('pages', $uid); + $this->trackedRecords['pages'][$uid] = $pageRow; } } @@ -104,9 +112,11 @@ public function processCmdmap_postProcess($command, $table, $uid, $value, DataHa { // workspaces: collect garbage only for LIVE workspace if ($command === 'move' && $table === 'pages' && ($GLOBALS['BE_USER']->workspace ?? null) == 0) { - $this->eventDispatcher->dispatch( - new PageMovedEvent((int)$uid) - ); + $event = new PageMovedEvent((int)$uid); + if (($this->trackedRecords['pages'][$uid] ?? null) !== null) { + $event->setPreviousParentId((int)$this->trackedRecords['pages'][$uid]['pid']); + } + $this->eventDispatcher->dispatch($event); } } diff --git a/Classes/IndexQueue/RecordMonitor.php b/Classes/IndexQueue/RecordMonitor.php index 8af370ef0c..e50b09d193 100644 --- a/Classes/IndexQueue/RecordMonitor.php +++ b/Classes/IndexQueue/RecordMonitor.php @@ -24,6 +24,7 @@ use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration; use ApacheSolrForTypo3\Solr\Util; use Psr\EventDispatcher\EventDispatcherInterface; +use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\Exception\Page\PageNotFoundException; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -38,6 +39,7 @@ */ class RecordMonitor { + protected array $trackedRecords = []; protected EventDispatcherInterface $eventDispatcher; public function __construct(EventDispatcherInterface $eventDispatcher = null) @@ -59,10 +61,17 @@ public function processCmdmap_preProcess( $table, $uid, ): void { - if ($command === 'delete' && $table === 'tt_content' && ($GLOBALS['BE_USER']->workspace ?? null) == 0) { + if (($GLOBALS['BE_USER']->workspace ?? null) != 0) { + return; + } + + if ($command === 'delete' && $table === 'tt_content') { $this->eventDispatcher->dispatch( new ContentElementDeletedEvent($uid) ); + } elseif ($command === 'move' && $table === 'pages') { + $pageRow = BackendUtility::getRecord('pages', $uid); + $this->trackedRecords['pages'][$uid] = $pageRow; } } @@ -97,9 +106,11 @@ public function processCmdmap_postProcess( // moving pages/records in LIVE workspace if ($command === 'move' && ($GLOBALS['BE_USER']->workspace ?? null) == 0) { - $this->eventDispatcher->dispatch( - new RecordMovedEvent($uid, $table) - ); + $event = new RecordMovedEvent($uid, $table); + if ($table === 'pages' && ($this->trackedRecords['pages'][$uid] ?? null) !== null) { + $event->setPreviousParentId((int)$this->trackedRecords['pages'][$uid]['pid']); + } + $this->eventDispatcher->dispatch($event); } } diff --git a/Tests/Integration/Fixtures/can_collect_garbage_if_page_tree_is_moved.csv b/Tests/Integration/Fixtures/can_collect_garbage_if_page_tree_is_moved.csv new file mode 100644 index 0000000000..a08488e908 --- /dev/null +++ b/Tests/Integration/Fixtures/can_collect_garbage_if_page_tree_is_moved.csv @@ -0,0 +1,9 @@ +"pages", +,"uid","pid","is_siteroot","doktype","sys_language_uid","l10n_parent","slug","title","sorting","no_search_sub_entries" +,2,1,0,1,0,0,"/1st-subpage-in-root-1","1st subpage in root 1",10,0 +,3,1,0,1,0,0,"/2nd-subpage-in-root 1","2nd subpage in root 1",20,0 +,4,1,0,254,"sys_language_uid","l10n_parent","/sysfolder-with-set-option-no_search_sub_entries","sysfolder with set option no_search_sub_entries",99,1 +,10,1,0,1,0,0,"/root-of-subtree-to-be-moved","root of subtree to be moved",30,0 +,11,10,0,1,0,0,"/root-of-subtree-to-be-moved/first-child-of-subtree-to-be-moved","first child of subtree to be moved",10,0 +,12,10,0,1,0,0,"/root-of-subtree-to-be-moved/2nd-child-of-subtree-to-be-moved","2nd child of subtree to be moved",20,0 +,13,11,0,1,0,0,"/root-of-subtree-to-be-moved/first-child-of-subtree-to-be-moved/3rd-child-of-subtree-to-be-moved","3rd child of subtree to be moved",10,0 \ No newline at end of file diff --git a/Tests/Integration/GarbageCollectorTest.php b/Tests/Integration/GarbageCollectorTest.php index e86f3b6284..51e6264272 100644 --- a/Tests/Integration/GarbageCollectorTest.php +++ b/Tests/Integration/GarbageCollectorTest.php @@ -116,7 +116,9 @@ protected function tearDown(): void $this->garbageCollector, $this->indexer, $this->extensionConfiguration, - $this->eventQueue + $this->eventQueue, + $this->backendUser, + $GLOBALS['LANG'] ); parent::tearDown(); } @@ -337,6 +339,83 @@ protected function prepareCanCollectGarbageFromSubPagesWhenPageIsSetToHiddenAndE $this->garbageCollector->processDatamap_afterDatabaseOperations('update', 'pages', 2, $changeSet, $dataHandler); } + /** + * @test + */ + public function canCollectGarbageIfPageTreeIsMoved(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/can_collect_garbage_if_page_tree_is_moved.csv'); + + $this->assertEmptyIndexQueue(); + $this->addToQueueAndIndexRecord('pages', 10); + $this->addToQueueAndIndexRecord('pages', 11); + $this->addToQueueAndIndexRecord('pages', 12); + $this->addToQueueAndIndexRecord('pages', 13); + $this->waitToBeVisibleInSolr(); + $this->assertSolrContainsDocumentCount(4); + + $this->dataHandler->start( + [], + ['pages' => [10 => ['move' => 2]]], + $this->backendUser + ); + + $this->dataHandler->process_cmdmap(); + $this->assertIndexQueueContainsItemAmount(4); + $this->assertSolrContainsDocumentCount(0); + } + + /** + * @test + */ + public function canCollectGarbageIfPageTreeIsMovedToSysfolderWithDisabledOptionIncludeSubEntriesInSearch(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/can_collect_garbage_if_page_tree_is_moved.csv'); + + $this->assertEmptyIndexQueue(); + $this->addToQueueAndIndexRecord('pages', 10); + $this->addToQueueAndIndexRecord('pages', 11); + $this->addToQueueAndIndexRecord('pages', 12); + $this->addToQueueAndIndexRecord('pages', 13); + $this->waitToBeVisibleInSolr(); + $this->assertIndexQueueContainsItemAmount(4); + + $this->dataHandler->start( + [], + ['pages' => [10 => ['move' => 4]]], + $this->backendUser + ); + $this->dataHandler->process_cmdmap(); + $this->assertEmptyIndexQueue(); + $this->assertSolrContainsDocumentCount(0); + } + + /** + * @test + */ + public function canCollectGarbageIfPageTreeIsMovedButStaysOnSamePage(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/can_collect_garbage_if_page_tree_is_moved.csv'); + + $this->assertEmptyIndexQueue(); + $this->addToQueueAndIndexRecord('pages', 10); + $this->addToQueueAndIndexRecord('pages', 11); + $this->addToQueueAndIndexRecord('pages', 12); + $this->addToQueueAndIndexRecord('pages', 13); + $this->waitToBeVisibleInSolr(); + $this->assertSolrContainsDocumentCount(4); + + $this->dataHandler->start( + [], + ['pages' => [10 => ['move' => -2]]], + $this->backendUser + ); + + $this->dataHandler->process_cmdmap(); + $this->assertIndexQueueContainsItemAmount(4); + $this->assertSolrContainsDocumentCount(3); + } + /** * @test */ diff --git a/Tests/Integration/IndexQueue/Fixtures/can_handle_mounted_page_tree_movement.csv b/Tests/Integration/IndexQueue/Fixtures/can_handle_mounted_page_tree_movement.csv new file mode 100644 index 0000000000..555c7a12e2 --- /dev/null +++ b/Tests/Integration/IndexQueue/Fixtures/can_handle_mounted_page_tree_movement.csv @@ -0,0 +1,7 @@ +"pages", +,"uid","pid","is_siteroot","doktype","sys_language_uid","l10n_parent","slug","title","sorting","no_search_sub_entries","mount_pid_ol","mount_pid" +,2,1,0,1,0,0,"/1st-subpage-in-root-1","1st subpage in root 1",10,0,0,0 +,3,1,0,7,0,0,"/mount-point-for-subtree","mount point for subtree",20,0,0,10 +,4,1,0,254,"sys_language_uid","l10n_parent","/sysfolder-with-set-option-no_search_sub_entries","sysfolder with set option no_search_sub_entries",99,1,0,0 +,10,1,0,1,0,0,"/root-of-subtree-to-be-moved","root of subtree to be moved",30,0,0,0 +,11,10,0,1,0,0,"/root-of-subtree-to-be-moved/first-child-of-subtree-to-be-moved","first child of subtree to be moved",10,0,0,0 \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/Fixtures/can_handle_page_tree_movement.csv b/Tests/Integration/IndexQueue/Fixtures/can_handle_page_tree_movement.csv new file mode 100644 index 0000000000..a08488e908 --- /dev/null +++ b/Tests/Integration/IndexQueue/Fixtures/can_handle_page_tree_movement.csv @@ -0,0 +1,9 @@ +"pages", +,"uid","pid","is_siteroot","doktype","sys_language_uid","l10n_parent","slug","title","sorting","no_search_sub_entries" +,2,1,0,1,0,0,"/1st-subpage-in-root-1","1st subpage in root 1",10,0 +,3,1,0,1,0,0,"/2nd-subpage-in-root 1","2nd subpage in root 1",20,0 +,4,1,0,254,"sys_language_uid","l10n_parent","/sysfolder-with-set-option-no_search_sub_entries","sysfolder with set option no_search_sub_entries",99,1 +,10,1,0,1,0,0,"/root-of-subtree-to-be-moved","root of subtree to be moved",30,0 +,11,10,0,1,0,0,"/root-of-subtree-to-be-moved/first-child-of-subtree-to-be-moved","first child of subtree to be moved",10,0 +,12,10,0,1,0,0,"/root-of-subtree-to-be-moved/2nd-child-of-subtree-to-be-moved","2nd child of subtree to be moved",20,0 +,13,11,0,1,0,0,"/root-of-subtree-to-be-moved/first-child-of-subtree-to-be-moved/3rd-child-of-subtree-to-be-moved","3rd child of subtree to be moved",10,0 \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/RecordMonitorTest.php b/Tests/Integration/IndexQueue/RecordMonitorTest.php index d18cfb543e..c47fccde49 100644 --- a/Tests/Integration/IndexQueue/RecordMonitorTest.php +++ b/Tests/Integration/IndexQueue/RecordMonitorTest.php @@ -30,6 +30,7 @@ use ApacheSolrForTypo3\Solr\Task\EventQueueWorkerTask; use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest; use Psr\Log\LogLevel; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\DataHandling\DataHandler; @@ -79,6 +80,8 @@ class RecordMonitorTest extends IntegrationTest */ protected $eventQueue; + protected BackendUserAuthentication $backendUser; + protected function setUp(): void { parent::setUp(); @@ -89,6 +92,10 @@ protected function setUp(): void $this->extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); $this->eventQueue = GeneralUtility::makeInstance(EventQueueItemRepository::class); $this->extensionConfiguration->set('solr', ['monitoringType' => 0]); + // fake that a backend user is logged in + $this->importCSVDataSet(__DIR__ . '/../Fixtures/sites_setup_and_data_set/be_users.csv'); + $this->backendUser = $this->setUpBackendUser(1); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } protected function tearDown(): void @@ -100,7 +107,9 @@ protected function tearDown(): void $this->dataHandler, $this->indexQueue, $this->extensionConfiguration, - $this->eventQueue + $this->eventQueue, + $this->backendUser, + $GLOBALS['LANG'] ); parent::tearDown(); } @@ -793,6 +802,57 @@ protected function prepareCanQueueUpdatePagesWithCustomPageType(): void $this->recordMonitor->processDatamap_afterDatabaseOperations('update', 'pages', 8, $changeSet, $dataHandler); } + /** + * @test + */ + public function canHandePageTreeMovement(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/can_handle_page_tree_movement.csv'); + $this->assertEmptyIndexQueue(); + + $this->dataHandler->start( + [], + ['pages' => [10 => ['move' => 2]]], + $this->backendUser + ); + $this->dataHandler->process_cmdmap(); + $this->assertIndexQueueContainsItemAmount(4); + } + + /** + * @test + */ + public function canHandePageTreeMovementIfPageTreeIsMovedToSysfolderWithDisabledOptionIncludeSubEntriesInSearch(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/can_handle_page_tree_movement.csv'); + $this->assertEmptyIndexQueue(); + + $this->dataHandler->start( + [], + ['pages' => [10 => ['move' => 4]]], + $this->backendUser + ); + $this->dataHandler->process_cmdmap(); + $this->assertEmptyIndexQueue(); + } + + /** + * @test + */ + public function canHandePageTreeMovementIfPageTreeIsMounted(): void + { + $this->importCSVDataSet(__DIR__ . '/Fixtures/can_handle_mounted_page_tree_movement.csv'); + $this->assertEmptyIndexQueue(); + + $this->dataHandler->start( + [], + ['pages' => [10 => ['move' => 2]]], + $this->backendUser + ); + $this->dataHandler->process_cmdmap(); + $this->assertIndexQueueContainsItemAmount(3); + } + /** * @test */ @@ -1842,8 +1902,6 @@ protected function prepareUpdateRecordMonitoringTablesTests(int $monitoringType, public function canCreateSiteOneRootLevel(): void { $this->importCSVDataSet(__DIR__ . '/Fixtures/recordmonitor_can_create_new_page.csv'); - $this->importCSVDataSet(__DIR__ . '/../Fixtures/sites_setup_and_data_set/be_users.csv'); - $GLOBALS['BE_USER'] = $this->setUpBackendUser(1); $this->assertIndexQueueContainsItemAmount(0); $dataHandler = $this->getDataHandler(); @@ -1862,8 +1920,6 @@ public function canCreateSiteOneRootLevel(): void public function canCreateSubPageBelowSiteRoot(): void { $this->importCSVDataSet(__DIR__ . '/Fixtures/recordmonitor_can_create_new_page.csv'); - $this->importCSVDataSet(__DIR__ . '/../Fixtures/sites_setup_and_data_set/be_users.csv'); - $GLOBALS['BE_USER'] = $this->setUpBackendUser(1); $this->assertIndexQueueContainsItemAmount(0); $dataHandler = $this->getDataHandler(); diff --git a/Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php b/Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php index 5b66405011..8e7190c153 100644 --- a/Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php +++ b/Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php @@ -91,11 +91,6 @@ protected function initGarbageCollectionExpectations(string $strategy, string $t public function handlePageMovementTriggersGarbageCollectionAndReindexing(): void { $this->initGarbageCollectionExpectations(PageStrategy::class, 'pages', 123); - $this->indexQueueMock - ->expects(self::once()) - ->method('updateItem') - ->with('pages', 123); - $this->garbageHandler->handlePageMovement(123); }