From d8e703e32dabc54bcb8de2666f84349bbd0826cd Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Fri, 9 Oct 2020 15:55:42 +0200 Subject: [PATCH] [TASK] Skip pages with "no_search" via query It does not make much sense to load such pages only to skip them immediately afterwards. --- Classes/DataCollector/PagesDataCollector.php | 10 ++++++++-- .../Service/IndexingServiceTest.php | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Classes/DataCollector/PagesDataCollector.php b/Classes/DataCollector/PagesDataCollector.php index 6284f4ff..9b77e371 100644 --- a/Classes/DataCollector/PagesDataCollector.php +++ b/Classes/DataCollector/PagesDataCollector.php @@ -104,6 +104,7 @@ protected function getPageRecords($pid = null) { $whereClause = ' AND pages.hidden = 0' . + ' AND pages.no_search = 0' . ' AND pages.doktype IN(' . $this->getDoktypes() . ')' . $this->config['groupWhereClause'] . ($this->config['includeHideInMenu'] ? '' : ' AND pages.nav_hide = 0') @@ -111,7 +112,12 @@ protected function getPageRecords($pid = null) $rawList = $this->pageRepository->getMenu( $pid, - 'uid, doktype, shortcut, shortcut_mode, no_search', + implode(',', [ + 'uid', + 'doktype', + 'shortcut', + 'shortcut_mode', + ]), 'sorting', $whereClause ); @@ -120,7 +126,7 @@ protected function getPageRecords($pid = null) foreach ($rawList as $uid => $page) { // Check if page is directly indexable or only transient, // also skip page if search has been disabled - if (in_array($page['doktype'], $this->config['doktypes']) && !$page['no_search']) { + if (in_array($page['doktype'], $this->config['doktypes'])) { yield $this->getRecord($uid); } diff --git a/Tests/Functional/Service/IndexingServiceTest.php b/Tests/Functional/Service/IndexingServiceTest.php index 3234d005..0264975a 100644 --- a/Tests/Functional/Service/IndexingServiceTest.php +++ b/Tests/Functional/Service/IndexingServiceTest.php @@ -215,6 +215,26 @@ public function indexesRecordsPartially(): void ]); } + /** + * @test + */ + public function skipsPagesWithNoSearchFromIndexing(): void + { + $this->getDatabaseConnection()->insertArray('pages', [ + 'uid' => 2, + 'pid' => 1, + 'doktype' => PageRepository::DOKTYPE_DEFAULT, + 'title' => 'Test page', + 'no_search' => 1, + ]); + + $this->assertIndexEmpty(); + + $this->indexingService->indexFull(); + + $this->assertIndexEmpty(); + } + /** * @return void */