From 5906f6dbe94b818e001977e57d88550063a0ceab Mon Sep 17 00:00:00 2001 From: Roman Schilter Date: Tue, 12 Mar 2024 14:47:11 +0100 Subject: [PATCH] [BUGFIX] Allow fe_group modification when indexing subpage of restricted page Fixes #3969 --- .../PageIndexer/FrontendGroupsModifier.php | 22 +++++++++++-------- ..._protected_page_with_extend_to_subpage.csv | 13 +++++++++++ .../IndexQueue/PageIndexerTest.php | 11 ++++++++++ 3 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 Tests/Integration/IndexQueue/Fixtures/can_index_sub_page_of_protected_page_with_extend_to_subpage.csv diff --git a/Classes/EventListener/PageIndexer/FrontendGroupsModifier.php b/Classes/EventListener/PageIndexer/FrontendGroupsModifier.php index 196063eac8..da9391d3ec 100644 --- a/Classes/EventListener/PageIndexer/FrontendGroupsModifier.php +++ b/Classes/EventListener/PageIndexer/FrontendGroupsModifier.php @@ -40,15 +40,20 @@ class FrontendGroupsModifier public function __invoke(ModifyResolvedFrontendGroupsEvent $event): void { $pageIndexerRequest = $event->getRequest()->getAttribute('solr.pageIndexingInstructions'); - if (!$pageIndexerRequest instanceof PageIndexerRequest - || ( - (int)$pageIndexerRequest->getParameter('userGroup') === 0 - && ( - (int)$pageIndexerRequest->getParameter('pageUserGroup') !== -2 - && - (int)$pageIndexerRequest->getParameter('pageUserGroup') < 1 - ) + if (!$pageIndexerRequest instanceof PageIndexerRequest) { + return; + } + + $groups = $this->resolveFrontendUserGroups($pageIndexerRequest); + + $noRelevantFrontendUserGroupResolved = empty($groups) || (count($groups) === 1 && $groups[0] === 0); + if ((int)$pageIndexerRequest->getParameter('userGroup') === 0 + && ( + (int)$pageIndexerRequest->getParameter('pageUserGroup') !== -2 + && + (int)$pageIndexerRequest->getParameter('pageUserGroup') < 1 ) + && $noRelevantFrontendUserGroupResolved ) { return; } @@ -76,7 +81,6 @@ public function __invoke(ModifyResolvedFrontendGroupsEvent $event): void ); } - $groups = $this->resolveFrontendUserGroups($pageIndexerRequest); if ((int)$pageIndexerRequest->getParameter('pageUserGroup') > 0) { $groups[] = (int)$pageIndexerRequest->getParameter('pageUserGroup'); } diff --git a/Tests/Integration/IndexQueue/Fixtures/can_index_sub_page_of_protected_page_with_extend_to_subpage.csv b/Tests/Integration/IndexQueue/Fixtures/can_index_sub_page_of_protected_page_with_extend_to_subpage.csv new file mode 100644 index 0000000000..58781e6318 --- /dev/null +++ b/Tests/Integration/IndexQueue/Fixtures/can_index_sub_page_of_protected_page_with_extend_to_subpage.csv @@ -0,0 +1,13 @@ +"fe_groups", +,"uid","pid","title" +,1,1,"group 1" +"pages", +,"uid","pid","is_siteroot","doktype","slug","title","subtitle","crdate","tstamp","fe_group",extendToSubpages +,2,1,0,1,"/protected_page","protected page","",1449151778,1449151778,1,1 +,3,2,0,1,/sub_page,sub page, ,1449151779,1449151779,0,0 +"tt_content", +,"uid","pid","CType","header","fe_group","sorting" +,10,3,"header",public content of protected page,0,10 +"tx_solr_indexqueue_item", +,"uid","root","item_type","item_uid","indexing_configuration","changed","indexed","has_indexing_properties","indexing_priority","indexed","errors" +,4711,1,"pages",3,"pages",1449151778,0,0,0,0,0 diff --git a/Tests/Integration/IndexQueue/PageIndexerTest.php b/Tests/Integration/IndexQueue/PageIndexerTest.php index 7ca8573e05..6531785f8f 100644 --- a/Tests/Integration/IndexQueue/PageIndexerTest.php +++ b/Tests/Integration/IndexQueue/PageIndexerTest.php @@ -202,6 +202,17 @@ public function canIndexPageWithAccessProtectedContentIntoSolrDataProvider(): Tr 'protected ce', ], ]; + + yield 'page protected by extend to subpages' => [ + 'can_index_sub_page_of_protected_page_with_extend_to_subpage', + 1, + [ + '2:1/c:0', + ], + [ + 'public content of protected page', + ] + ]; } /**