Skip to content

Commit

Permalink
[BUGFIX] Skip hidden content/records on indexing
Browse files Browse the repository at this point in the history
The "visibility" aspect set up by the TYPO3 CommandApplication includes
hidden content (and thus records) by default. This can be seen
especially when using the Extbase persistence during the indexing
process. Related objects ignore any enable fields and are loaded
unconditionally.

This whole topic very likely needs further investigation and additional
restrictions (e.g. skip hidden pages and scheduled records) but left for
another change.
  • Loading branch information
mbrodala committed Jan 6, 2025
1 parent c43421c commit 76e2352
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Classes/Command/Index/AbstractIndexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use PAGEmachine\Searchable\Service\IndexingService;
use Symfony\Component\Console\Command\Command;
use TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\VisibilityAspect;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Utility\GeneralUtility;

Expand All @@ -27,5 +29,14 @@ public function __construct(...$arguments)
if ($GLOBALS['BE_USER'] instanceof CommandLineUserAuthentication) {
$GLOBALS['BE_USER']->initializeUserSessionManager();
}

$context = GeneralUtility::makeInstance(Context::class);
$currentVisibilityAspect = $context->getAspect('visibility');
$context->setAspect('visibility', new VisibilityAspect(
includeHiddenPages: $currentVisibilityAspect->includeHiddenPages(),
includeHiddenContent: false,
includeDeletedRecords: $currentVisibilityAspect->includeDeletedRecords(),
includeScheduledRecords: $currentVisibilityAspect->includeScheduledRecords(),
));
}
}

0 comments on commit 76e2352

Please sign in to comment.