diff --git a/Classes/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandler.php b/Classes/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandler.php index ee178e9beb..90580decf4 100644 --- a/Classes/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandler.php +++ b/Classes/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandler.php @@ -25,7 +25,7 @@ use Doctrine\DBAL\Driver\Exception as DBALDriverException; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; -use TYPO3\CMS\Core\Database\QueryGenerator; +use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -173,8 +173,12 @@ protected function getSubPageIds(int $pageId): array // here we retrieve only the subpages of this page because the permission clause is not evaluated // on the root node. $permissionClause = ' 1 ' . $this->getPagesRepository()->getBackendEnableFields(); - $treePageIdList = (string)$this->getQueryGenerator()->getTreeList($pageId, 20, 0, $permissionClause); - $treePageIds = array_map('intval', explode(',', $treePageIdList)); + $pageRepository = GeneralUtility::makeInstance(PageRepository::class); + $treePageIds = $pageRepository->getDescendantPageIdsRecursive( + $pageId, + 20, + 0 + ); // the first one can be ignored because this is the page itself array_shift($treePageIds); @@ -302,14 +306,6 @@ protected function getUpdateSubPagesRecursiveTriggerConfiguration(): array return $this->updateSubPagesRecursiveTriggerConfiguration; } - /** - * @return QueryGenerator - */ - protected function getQueryGenerator(): QueryGenerator - { - return GeneralUtility::makeInstance(QueryGenerator::class); - } - /** * @return PagesRepository */ diff --git a/Tests/Unit/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandlerTest.php b/Tests/Unit/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandlerTest.php index 3780b393dd..e0bbc08093 100644 --- a/Tests/Unit/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandlerTest.php +++ b/Tests/Unit/Domain/Index/Queue/UpdateHandler/AbstractUpdateHandlerTest.php @@ -23,7 +23,7 @@ use ApacheSolrForTypo3\Solr\System\TCA\TCAService; use ApacheSolrForTypo3\Solr\Tests\Unit\UnitTest; use PHPUnit\Framework\MockObject\MockObject; -use TYPO3\CMS\Core\Database\QueryGenerator; +use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -63,6 +63,11 @@ abstract class AbstractUpdateHandlerTest extends UnitTest */ protected $queryGeneratorMock; + /** + * @var PageRepository|MockObject + */ + protected PageRepository|MockObject $typo3PageRepositoryMock; + /** * @var PagesRepository|MockObject */ @@ -82,9 +87,9 @@ protected function setUp(): void ->method('getSolrConfigurationFromPageId') ->willReturn($this->typoScriptConfigurationMock); - $this->queryGeneratorMock = $this->createMock(QueryGenerator::class); + $this->typo3PageRepositoryMock = $this->createMock(PageRepository::class); - GeneralUtility::addInstance(QueryGenerator::class, $this->queryGeneratorMock); + GeneralUtility::addInstance(PageRepository::class, $this->typo3PageRepositoryMock); parent::setUp(); } diff --git a/Tests/Unit/Domain/Index/Queue/UpdateHandler/DataUpdateHandlerTest.php b/Tests/Unit/Domain/Index/Queue/UpdateHandler/DataUpdateHandlerTest.php index 0c19b33e19..92fb1791c5 100644 --- a/Tests/Unit/Domain/Index/Queue/UpdateHandler/DataUpdateHandlerTest.php +++ b/Tests/Unit/Domain/Index/Queue/UpdateHandler/DataUpdateHandlerTest.php @@ -378,10 +378,10 @@ public function handlePageUpdateTriggersRecursivePageProcessing(): void $GLOBALS['TCA']['pages'] = ['columns' => []]; - $this->queryGeneratorMock + $this->typo3PageRepositoryMock ->expects(self::any()) - ->method('getTreeList') - ->willReturn($dummyPageRecord['uid'] . ',100,200'); + ->method('getDescendantPageIdsRecursive') + ->willReturn([$dummyPageRecord['uid'], 100, 200]); $this->pagesRepositoryMock ->expects(self::any()) diff --git a/Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php b/Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php index 34e9e95edf..fdc6c784c9 100644 --- a/Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php +++ b/Tests/Unit/Domain/Index/Queue/UpdateHandler/GarbageHandlerTest.php @@ -191,10 +191,10 @@ public function performRecordGarbageCheckTriggersPageGarbageCollection(): void ->with('pages', $dummyPageRecord) ->willReturn($dummyPageRecord); - $this->queryGeneratorMock + $this->typo3PageRepositoryMock ->expects(self::any()) - ->method('getTreeList') - ->willReturn($dummyPageRecord['uid'] . ',100,200'); + ->method('getDescendantPageIdsRecursive') + ->willReturn([$dummyPageRecord['uid'], 100, 200]); $this->garbageHandler->performRecordGarbageCheck($dummyPageRecord['uid'], 'pages', ['hidden' => 1], true); }