From fa6a3e710ec2d4ccde86de4dc6bd5fae4308d4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20K=C3=A4hm?= Date: Fri, 23 Sep 2022 18:30:28 +0200 Subject: [PATCH] [BUGFIX] TSFE can not be initialized for pages with fe_group="-2" The TSFE can not be initialized in record-monitoring(BE editiing) context for pages, whichs fe_group is set to -2(show if fe_user is logged in). This leads to following behavior: * After editing the [sub]pages in BE, the page is removed from index and never indexed again. * By reinitialization of pages index queue the page is indexed as expected with expected groups. Fixes: #3351 Relates: #3347 Ports: #3352 --- ...page_with_different_fe_groups_settings.xml | 23 +++++++++++++ .../FrontendEnvironment/TsfeTest.php | 34 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Tests/Integration/FrontendEnvironment/Fixtures/can_initialize_tsfe_for_page_with_different_fe_groups_settings.xml diff --git a/Tests/Integration/FrontendEnvironment/Fixtures/can_initialize_tsfe_for_page_with_different_fe_groups_settings.xml b/Tests/Integration/FrontendEnvironment/Fixtures/can_initialize_tsfe_for_page_with_different_fe_groups_settings.xml new file mode 100644 index 0000000000..03c15cc880 --- /dev/null +++ b/Tests/Integration/FrontendEnvironment/Fixtures/can_initialize_tsfe_for_page_with_different_fe_groups_settings.xml @@ -0,0 +1,23 @@ + + + + 2 + 0 + 1 + 1 + 1 + + + 3 + 0 + 1 + 1 + -2 + + + + 1 + 1 + dummy group + + diff --git a/Tests/Integration/FrontendEnvironment/TsfeTest.php b/Tests/Integration/FrontendEnvironment/TsfeTest.php index 1648899157..97dce55166 100644 --- a/Tests/Integration/FrontendEnvironment/TsfeTest.php +++ b/Tests/Integration/FrontendEnvironment/TsfeTest.php @@ -6,6 +6,7 @@ use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest; use RuntimeException; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; class TsfeTest extends IntegrationTest { @@ -53,4 +54,37 @@ public function initializeTsfeWithNoDefaultPageAndPageErrorHandlerDoNotThrowAnEr $tsfeManager = GeneralUtility::makeInstance(Tsfe::class); $tsfeManager->getTsfeByPageIdAndLanguageId(1); } + + /** + * @test + */ + public function canInitializeTsfeForPageWithDifferentFeGroupsSettings() + { + $this->writeDefaultSolrTestSiteConfiguration(); + $this->importDataSetFromFixture('can_initialize_tsfe_for_page_with_different_fe_groups_settings.xml'); + + $tsfeNotRestricted = GeneralUtility::makeInstance(Tsfe::class)->getTsfeByPageIdIgnoringLanguage(1); + self::assertInstanceOf( + TypoScriptFrontendController::class, + $tsfeNotRestricted, + 'The TSFE can not be initialized at all, nor for public page either for access restricted(fe_group) page. ' . + 'Most probably nothing will work.' + ); + + $tsfeRestrictedForExistingFeGroup = GeneralUtility::makeInstance(Tsfe::class)->getTsfeByPageIdIgnoringLanguage(2); + self::assertInstanceOf( + TypoScriptFrontendController::class, + $tsfeRestrictedForExistingFeGroup, + 'The TSFE can not be initialized for existing fe_group. ' . + 'This will lead to failures on editing the access restricted [sub]pages in BE.' + ); + + $tsfeForLoggedInUserOnly = GeneralUtility::makeInstance(Tsfe::class)->getTsfeByPageIdIgnoringLanguage(3); + self::assertInstanceOf( + TypoScriptFrontendController::class, + $tsfeForLoggedInUserOnly, + 'The TSFE can not be initialized for page with fe_group="-2". ' . + 'This will lead to failures on editing the [sub]pages in BE for pages with fe_group="-2".' + ); + } }