Skip to content

Commit

Permalink
[BUGFIX] Enforce visibility context in Tsfe
Browse files Browse the repository at this point in the history
TYPO3 by default enables a preview mode if a backend user is logged in,
the VisibilityAspect is configured to show hidden elements.

Due to this setting hidden relations/translations might be indexed
when running the Solr indexer via the TYPO3 backend.

To avoid this, the VisibilityAspect is adapted for indexing.

Resolves: TYPO3-Solr#3046
Relates: TYPO3-Solr#3050, TYPO3-Solr#2976
  • Loading branch information
saitho authored and dkd-kaehm committed Nov 12, 2021
1 parent c9ca72f commit 24d1188
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Classes/FrontendEnvironment/Tsfe.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\Context\LanguageAspectFactory;
use TYPO3\CMS\Core\Context\TypoScriptAspect;
use TYPO3\CMS\Core\Context\VisibilityAspect;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Error\Http\InternalServerErrorException;
Expand Down Expand Up @@ -69,7 +70,6 @@ public function changeLanguageContext(int $pageId, int $language): void
*/
public function initializeTsfe($pageId, $language = 0)
{

// resetting, a TSFE instance with data from a different page Id could be set already
unset($GLOBALS['TSFE']);

Expand All @@ -95,8 +95,21 @@ public function initializeTsfe($pageId, $language = 0)
}
$GLOBALS['TYPO3_REQUEST'] = $this->requestCache[$cacheId];


if (!isset($this->tsfeCache[$cacheId])) {
// TYPO3 by default enables a preview mode if a backend user is logged in,
// the VisibilityAspect is configured to show hidden elements.
// Due to this setting hidden relations/translations might be indexed
// when running the Solr indexer via the TYPO3 backend.
// To avoid this, the VisibilityAspect is adapted for indexing.
$context->setAspect(
'visibility',
GeneralUtility::makeInstance(
VisibilityAspect::class,
false,
false
)
);

$feUser = GeneralUtility::makeInstance(FrontendUserAuthentication::class);

/* @var PageArguments $pageArguments */
Expand Down

0 comments on commit 24d1188

Please sign in to comment.