Skip to content

Commit

Permalink
[TASK] Skip pages with "no_search" via query
Browse files Browse the repository at this point in the history
It does not make much sense to load such pages only to skip them
immediately afterwards.
  • Loading branch information
mbrodala committed Oct 9, 2020
1 parent 156fa03 commit d8e703e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Classes/DataCollector/PagesDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,20 @@ 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')
;

$rawList = $this->pageRepository->getMenu(
$pid,
'uid, doktype, shortcut, shortcut_mode, no_search',
implode(',', [
'uid',
'doktype',
'shortcut',
'shortcut_mode',
]),
'sorting',
$whereClause
);
Expand All @@ -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);
}

Expand Down
20 changes: 20 additions & 0 deletions Tests/Functional/Service/IndexingServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit d8e703e

Please sign in to comment.