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: #3046
Relates: #3050, #2976
  • Loading branch information
saitho authored and dkd-kaehm committed Dec 2, 2021
1 parent 0e6bf90 commit d509473
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Classes/FrontendEnvironment/Tsfe.php
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 d509473

Please sign in to comment.