diff --git a/Classes/Domain/Index/PageIndexer/PageUriBuilder.php b/Classes/Domain/Index/PageIndexer/PageUriBuilder.php index a719f311c4..ddfeacfeb2 100644 --- a/Classes/Domain/Index/PageIndexer/PageUriBuilder.php +++ b/Classes/Domain/Index/PageIndexer/PageUriBuilder.php @@ -61,7 +61,15 @@ protected function buildPageIndexingUriFromPageItemAndLanguageId( int $language = 0, string $mountPointParameter = '', ): UriInterface { - $site = $this->siteFinder->getSiteByPageId($item->getRecordUid()); + + if ($item->hasIndexingProperty('isMountedPage')) { + $recordUid = (int)$item->getIndexingProperty('mountPageDestination'); + } else { + $recordUid = $item->getRecordUid(); + } + + $site = $this->siteFinder->getSiteByPageId($recordUid); + $parameters = []; if ($language > 0) { diff --git a/Documentation/FAQ/Index.rst b/Documentation/FAQ/Index.rst index 07d526e818..16682b2dda 100644 --- a/Documentation/FAQ/Index.rst +++ b/Documentation/FAQ/Index.rst @@ -693,7 +693,7 @@ Yes. If user is not logged in one can redirect to a login page with the help of The reason for that: -With Typo3 10 and solr 11.0.1 it was possible for solr to read it's configuration from shortcut pages directly. With Typo3 11 and solr 11.5 these shortcuts are followed. And if the access to the destination of the shortcut is restricted, solr cannot read the configuration because solr is not logged in. +With TYPO3 10 and solr 11.0.1 it was possible for solr to read it's configuration from shortcut pages directly. With TYPO3 11 and solr 11.5 these shortcuts are followed. And if the access to the destination of the shortcut is restricted, solr cannot read the configuration because solr is not logged in. The solution: @@ -721,3 +721,17 @@ The container log did not contain any output relevant to the container quitting. Changing to Docker Desktop as provider keep the container alive. Relevant DDEV link: https://ddev.readthedocs.io/en/latest/users/providers/ + + + +Can mount points be indexed? +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Mount points are supported in general and the mounted pages will be indexed like standard pages. + +But there are some points to consider: + +* Cross-site mounts require that `config.index_enable = 1` is set in the page tree of the mounted page + This might change as due to changes in RootlineUtility->generateRootlineCache the mount point pid isn't used for the rootline. +* Mounted pages from a pagetree without a site configuration cannot be indexed, in fact TYPO3 currently can't mount a page from a page tree without a site configuration and an exeception occurs + diff --git a/Documentation/Releases/solr-release-13-0.rst b/Documentation/Releases/solr-release-13-0.rst index 30fcec9662..b08a3af27e 100644 --- a/Documentation/Releases/solr-release-13-0.rst +++ b/Documentation/Releases/solr-release-13-0.rst @@ -5,19 +5,44 @@ Releases 13.0 ============= + +Release 13.0.0-beta-1 +===================== + +This is a first beta release for TYPO3 13.4 LTS + +New in this release +------------------- + +Adjust mount point indexing +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Mount point indexing and corresponding tests have been adjusted for TYPO3 13. Mount points are supported in general and the mounted pages will be indexed like standard pages. + +But there are some points to consider: + +* Cross-site mounts require that `config.index_enable = 1` is set in the pagetree of the mounted page, as TYPO3 loads the TypoScript of the mounted page +* Mounted pages from a pagetree without a site configuration cannot be indexed, in fact TYPO3 currently can't mount a page from a page tree without a site configuration and an exeception occurs + + Release 13.0.0-alpha-1 ====================== This is a first alpha release for upcoming TYPO3 13 LTS -Known Bugs ----------- - -* Mount pages cannot be indexed, see `#4160 `__ - New in this release ------------------- +Adjust mount point indexing +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Mount point indexing and corresponding tests have been adjusted for TYPO3 13. Mount points are supported in general and the mounted pages will be indexed like standard pages. + +But there are some points to consider: + +* Cross-site mounts require that `config.index_enable = 1` is set in the pagetree of the mounted page, as TYPO3 loads the TypoScript of the mounted page +* Mounted pages from a pagetree without a site configuration cannot be indexed, in fact TYPO3 currently can't mount a page from a page tree without a site configuration and an exeception occurs + !!! Upgrade to Apache Solr 9.7.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Tests/Integration/ConnectionManagerTest.php b/Tests/Integration/ConnectionManagerTest.php index cb4c75f5cd..d48bdeeabe 100644 --- a/Tests/Integration/ConnectionManagerTest.php +++ b/Tests/Integration/ConnectionManagerTest.php @@ -31,12 +31,6 @@ */ class ConnectionManagerTest extends IntegrationTestBase { - /** - * @inheritdoc - * @todo: Remove unnecessary fixtures and remove that property as intended. - */ - protected bool $skipImportRootPagesAndTemplatesForConfiguredSites = true; - protected function setUp(): void { parent::setUp(); @@ -195,24 +189,32 @@ public function exceptionIsThrownForUnAvailableSolrConnectionOnGetConnectionByPa * ConnectionManager must use the connection for site(tree), where mount Point is defined. * There is following scenario: * - * [0] - * | - * ——[20] Shared-Pages (Folder) - * | | - * | ——[24] FirstShared - * | | - * | ——[25] first sub page from FirstShared - * | | - * | ——[26] second sub page from FirstShared - * | - * ——[ 1] Page (Root) - * | - * ——[14] Mount Point 1 (to [24] to show contents from) + * [0] + * | + * |—[211] Page3 (Root) + * | | + * | |—[24] FirstShared + * | | + * | |—[25] first sub page from FirstShared + * | | + * | |—[26] second sub page from FirstShared + * | + * |—[ 1] Page (Root) + * | | + * | |—[14] Mount Point 1 (to [24] to show contents from) + * | + * |—[111] Page2 (Root) + * | + * |—[34] Mount Point 2 (to [24] to show contents from) */ #[Test] public function canFindSolrConnectionForMountedPageIfMountPointIsGiven(): void { - self::markTestSkipped('@todo: Fix it. See: https://github.com/TYPO3-Solr/ext-solr/issues/4160'); + self::markTestSkipped( + '@todo: Test currently fails in TYPO3 13.4 due to changes in RootlineUtility' + . ' RootlineUtility doesn\'t use the mount point pid in RootlineUtility->generateRootlineCache currently,' + . ' which is probably a bug. See: https://github.com/TYPO3-Solr/ext-solr/issues/4160' + ); $this->importCSVDataSet(__DIR__ . '/Fixtures/connection_for_mounted_page.csv'); diff --git a/Tests/Integration/Fixtures/connection_basic.csv b/Tests/Integration/Fixtures/connection_basic.csv index fb2012a54f..f9cdba92c9 100644 --- a/Tests/Integration/Fixtures/connection_basic.csv +++ b/Tests/Integration/Fixtures/connection_basic.csv @@ -18,28 +18,9 @@ # "pages", ,"uid","pid","is_siteroot","doktype","mount_pid","mount_pid_ol","slug","title" -,1,0,1,1,0,0,"/","First site" ,11,1,0,7,24,1,"/subpage","Subpage of first site" -,111,0,1,1,0,0,"/","Second site" ,21,111,0,7,24,1,"/subpage","Subpage of second site" # detached and non Root Page-Tree ,3,0,0,1,0,0,"/","Detached and non Root Page-Tree" ,31,3,0,7,24,1,"/subpage","Subpage 1 of Detached" -,32,3,0,7,24,1,"/subpage-2","Subpage 2 of Detached" -"sys_template", -,"uid","pid","root","clear","sorting","config" -,1,1,1,3,100," -page = PAGE -page.typeNum = 0 -plugin.tx_solr { - enabled = 1 -}" -,111,111,1,3,100," -page = PAGE -page.typeNum = 0 - -plugin.tx_solr { - enabled = 1 -}" - - +,32,3,0,7,24,1,"/subpage-2","Subpage 2 of Detached" \ No newline at end of file diff --git a/Tests/Integration/Fixtures/connection_for_mounted_page.csv b/Tests/Integration/Fixtures/connection_for_mounted_page.csv index 20aa824beb..71448fea4e 100644 --- a/Tests/Integration/Fixtures/connection_for_mounted_page.csv +++ b/Tests/Integration/Fixtures/connection_for_mounted_page.csv @@ -2,75 +2,28 @@ # # [0] # | -# ——[20] Shared-Pages (Folder: Not root) +# |—[211] Page3 (Root) # | | -# | ——[24] FirstShared +# | |—[24] FirstShared # | | -# | ——[25] first sub page from FirstShared +# | |—[25] first sub page from FirstShared # | | -# | ——[26] second sub page from FirstShared +# | |—[26] second sub page from FirstShared # | -# ——[ 1] Page (Root) +# |—[ 1] Page (Root) # | | -# | ——[14] Mount Point 1 (to [24] to show contents from) +# | |—[14] Mount Point 1 (to [24] to show contents from) # | -# ——[ 2] Page2 (Root) +# |—[111] Page2 (Root) # | -# ——[34] Mount Point 2 (to [24] to show contents from) +# |—[34] Mount Point 2 (to [24] to show contents from) "pages", ,"uid","pid","is_siteroot","doktype","mount_pid","mount_pid_ol","slug","title" # Shared Pages tree -,20,0,0,254,0,0,"/","Shared-Pages" -,24,20,0,1,0,0,"/first-shared","FirstShared (Not root)" +,24,211,0,1,0,0,"/first-shared","FirstShared (Not root)" ,25,24,0,1,0,0,"/first-shared/first-subpage","first sub page from FirstShared (Not root)" ,26,24,0,1,0,0,"/first-shared/second-subpage","second sub page from FirstShared (Not root)" # Site tree -,1,0,1,1,0,0,"/","Page (Root)" ,14,1,0,7,24,1,"/mount-point-1","Mount Point 1" # Second Site tree -,2,0,1,1,0,0,"/","Second Site (Root)" -,34,2,0,7,24,1,"/mount-point-2","Mount Point 2" -"sys_template", -,"uid","pid","root","clear","sorting","config" -,1,1,1,3,100," -page = PAGE -page.typeNum = 0 -config.index_enable = 1 - -plugin.tx_solr { - enabled = 1 - - index { - fieldProcessingInstructions { - changed = timestampToIsoDate - created = timestampToIsoDate - endtime = timestampToUtcIsoDate - rootline = pageUidToHierarchy - } - - queue { - // mapping tableName.fields.SolrFieldName => TableFieldName (+ cObj processing) - pages = 1 - pages { - initialization = ApacheSolrForTypo3\Solr\IndexQueue\Initializer\Page - - // allowed page types (doktype) when indexing records from pages - allowedPageTypes = 1,7 - - indexingPriority = 0 - - indexer = ApacheSolrForTypo3\Solr\IndexQueue\PageIndexer - indexer { - // add options for the indexer here - } - - // Only index standard pages and mount points that are not overlayed. - additionalWhereClause = (doktype = 1 OR (doktype=7 AND mount_pid_ol=0)) AND no_search = 0 - - fields { - sortSubTitle_stringS = subtitle - } - } - } - } -}" +,34,111,0,7,24,1,"/mount-point-2","Mount Point 2" \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page.csv b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page.csv index 93b85faada..3338c0214b 100644 --- a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page.csv +++ b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page.csv @@ -1,24 +1,23 @@ # There is following scenario: # # [0] -# | -# ——[20] Shared-Pages (Not root) -# | | -# | ——[24] FirstShared (Not root) -# | -# ——[ 1] Page (Root) +# |—[ 1] Page (Root Testpage 1) # | -# ——[14] Mount Point (to [24] to show contents from) +# |—[14] Mount Point (to [24] to show contents from) +# | +# |—[24] FirstShared "pages", ,"uid","pid","is_siteroot","doktype","mount_pid","mount_pid_ol","slug","title" -# Site tree ,14,1,0,7,24,1,"/mount-point","Mount Point" -# Shared Pages tree -,20,0,0,254,0,0,"/","Shared-Pages" -,24,20,0,1,0,0,"/first-shared","FirstShared (Not root)" +,24,1,0,1,0,0,"/first-shared","FirstShared" "tt_content", ,"uid","pid","colPos","CType","bodytext" ,99,24,0,"text","Some Lorem Ipsum conteint!" "tx_solr_indexqueue_item", -,"uid","root","item_type","item_uid","indexing_configuration","changed","indexed","has_indexing_properties","indexing_priority","indexed","errors" -,4711,1,"pages",24,"pages",1449151778,0,0,0,0,0 \ No newline at end of file +,"uid","root","item_type","item_uid","indexing_configuration","changed","indexed","has_indexing_properties","indexing_priority","indexed","errors","pages_mountidentifier" +,4711,1,"pages",24,"pages",1449151778,0,1,0,0,0,"24-14-1" +"tx_solr_indexqueue_indexing_property", +,"uid","root","item_id","property_key","property_value" +,1,1,4711,"mountPageSource",24 +,2,1,4711,"mountPageDestination",14 +,3,1,4711,"isMountedPage",1 \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page_from_another_site.csv b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page_from_another_site.csv new file mode 100644 index 0000000000..563f2687d0 --- /dev/null +++ b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page_from_another_site.csv @@ -0,0 +1,26 @@ +# There is following scenario: +# +# [0] +# | +# |—[ 111] Page (Root Testpage 2) +# | | +# | |—[24] FirstShared +# | +# |—[ 1] Page (Root Testpage 1) +# | +# |—[14] Mount Point (to [24] to show contents from) +"pages", +,"uid","pid","is_siteroot","doktype","mount_pid","mount_pid_ol","slug","title" +,14,1,0,7,24,1,"/mount-point","Mount Point" +,24,111,0,1,0,0,"/first-shared","FirstShared" +"tt_content", +,"uid","pid","colPos","CType","bodytext" +,99,24,0,"text","Some Lorem Ipsum conteint!" +"tx_solr_indexqueue_item", +,"uid","root","item_type","item_uid","indexing_configuration","changed","indexed","has_indexing_properties","indexing_priority","indexed","errors","pages_mountidentifier" +,4711,1,"pages",24,"pages",1449151778,0,1,0,0,0,"24-14-1" +"tx_solr_indexqueue_indexing_property", +,"uid","root","item_id","property_key","property_value" +,1,1,4711,"mountPageSource",24 +,2,1,4711,"mountPageDestination",14 +,3,1,4711,"isMountedPage",1 \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page_outside_site_root.csv b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page_outside_site_root.csv new file mode 100644 index 0000000000..5b79301ae6 --- /dev/null +++ b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_mounted_page_outside_site_root.csv @@ -0,0 +1,26 @@ +# There is following scenario: +# +# [0] +# | +# |—[20] Shared-Pages (Not root) +# | | +# | |—[24] FirstShared (Not root) +# | +# |—[ 1] Page (Root) +# | +# |—[14] Mount Point (to [24] to show contents from) +"pages", +,"uid","pid","is_siteroot","doktype","mount_pid","mount_pid_ol","slug","title" +,14,1,0,7,24,1,"/mount-point","Mount Point" +,24,20,0,1,0,0,"/first-shared","FirstShared" +"tt_content", +,"uid","pid","colPos","CType","bodytext" +,99,24,0,"text","Some Lorem Ipsum conteint!" +"tx_solr_indexqueue_item", +,"uid","root","item_type","item_uid","indexing_configuration","changed","indexed","has_indexing_properties","indexing_priority","indexed","errors","pages_mountidentifier" +,4711,1,"pages",24,"pages",1449151778,0,1,0,0,0,"24-14-1" +"tx_solr_indexqueue_indexing_property", +,"uid","root","item_id","property_key","property_value" +,1,1,4711,"mountPageSource",24 +,2,1,4711,"mountPageDestination",14 +,3,1,4711,"isMountedPage",1 \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_multiple_mounted_page.csv b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_multiple_mounted_page.csv index c97e1be9a2..d351e07436 100644 --- a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_multiple_mounted_page.csv +++ b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_multiple_mounted_page.csv @@ -1,29 +1,34 @@ # There is following scenario: # [0] # | -# ——[20] Shared-Pages (Not root) +# |—[111] 2nd page root # | | -# | ——[44] FirstShared (Not root) +# | |—[44] FirstShared (Not root) # | -# ——[ 1] Page (Root) +# |—[ 1] Page (Root) # | -# ——[14] Mount Point (to [44] to show contents from) -# | -# ——[ 2] Page (Root) +# |—[14] Mount Point (to [44] to show contents from) # | -# ——[24] Mount Point (to [44] to show contents from) +# |—[24] Mount Point (to [44] to show contents from) "pages", ,"uid","pid","is_siteroot","doktype","mount_pid","mount_pid_ol","slug","title" # Site tree a ,14,1,0,7,44,1,"/mount-point","Mount Point" ,24,1,0,7,44,1,"/mount-point-2","Mount Point 2" # Shared Pages tree -,20,0,0,254,0,0,"/shared-pages","Shared-Pages" -,44,20,0,1,0,0,"/first-shared","FirstShared (Not root)" +,44,111,0,1,0,0,"/first-shared","FirstShared (Not root)" "tt_content", ,"uid","pid","colPos","CType","bodytext" ,99,44,0,"text","Some Lorem Ipsum conteint!" "tx_solr_indexqueue_item", ,"uid","root","item_type","item_uid","indexing_configuration","changed","indexed","has_indexing_properties","indexing_priority","indexed","errors" -,4711,1,"pages",44,"pages",1449151778,0,0,0,0,0 -,4712,1,"pages",44,"pages",1449151778,0,0,0,0,0 +,4711,1,"pages",14,"pages",1449151778,0,1,0,0,0 +,4712,1,"pages",24,"pages",1449151778,0,1,0,0,0 +"tx_solr_indexqueue_indexing_property", +,"uid","root","item_id","property_key","property_value" +,1,1,4711,"mountPageSource",44 +,2,1,4711,"mountPageDestination",14 +,3,1,4711,"isMountedPage",1 +,4,1,4712,"mountPageSource",44 +,5,1,4712,"mountPageDestination",24 +,6,1,4712,"isMountedPage",1 \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_with_additional_fields_into_solr.csv b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_with_additional_fields_into_solr.csv index 60b4e2b293..699bc9b9d1 100644 --- a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_with_additional_fields_into_solr.csv +++ b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/can_index_with_additional_fields_into_solr.csv @@ -1,6 +1,6 @@ "pages", ,"uid","pid","is_siteroot","doktype","slug","title","subtitle","crdate","tstamp" -,2,1,1,1,"/","hello solr","the subtitle",1449151778,1449151778 +,2,1,1,1,"/hello-solr","hello solr","the subtitle",1449151778,1449151778 "tx_solr_indexqueue_item", ,"uid","root","item_type","item_uid","indexing_configuration","changed","indexed","has_indexing_properties","indexing_priority","indexed","errors" ,4711,1,"pages",2,"pages",1449151778,0,0,0,0,0 \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/does_not_die_if_page_not_available.csv b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/does_not_die_if_page_not_available.csv index 201435dac6..d02bfe35bd 100644 --- a/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/does_not_die_if_page_not_available.csv +++ b/Tests/Integration/IndexQueue/FrontendHelper/Fixtures/does_not_die_if_page_not_available.csv @@ -1,3 +1,3 @@ "tx_solr_indexqueue_item", ,"uid","root","item_type","item_uid","indexing_configuration","changed","indexed","has_indexing_properties","indexing_priority","indexed","errors" -,4711,999,"pages",1636120156,"pages",1449151778,0,0,0,0,0 \ No newline at end of file +,4711,1,"pages",1636120156,"pages",1449151778,0,0,0,0,0 \ No newline at end of file diff --git a/Tests/Integration/IndexQueue/FrontendHelper/PageIndexerTest.php b/Tests/Integration/IndexQueue/FrontendHelper/PageIndexerTest.php index 144996e0aa..c5b3eb7ebe 100644 --- a/Tests/Integration/IndexQueue/FrontendHelper/PageIndexerTest.php +++ b/Tests/Integration/IndexQueue/FrontendHelper/PageIndexerTest.php @@ -17,9 +17,11 @@ namespace ApacheSolrForTypo3\Solr\Tests\Integration\IndexQueue\FrontendHelper; +use ApacheSolrForTypo3\Solr\Domain\Index\PageIndexer\PageUriBuilder; use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTestBase; use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\ResponseInterface; +use TYPO3\CMS\Core\Http\Uri; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Page\CacheHashCalculator; @@ -66,7 +68,7 @@ public function canIndexPageIntoSolr(): void ' ); - $this->indexQueuedPage(2); + $this->indexQueuedPage(); // we wait to make sure the document will be available in solr $this->waitToBeVisibleInSolr(); @@ -100,7 +102,7 @@ public function canIndexPageWithCustomPageTypeIntoSolr(): void ' ); - $this->indexQueuedPage(2); + $this->indexQueuedPage(); // we wait to make sure the document will be available in solr $this->waitToBeVisibleInSolr(); @@ -133,8 +135,8 @@ public function canIndexTranslatedPageToPageRelation(): void ' ); - $this->indexQueuedPage(2, '/en/'); - $this->indexQueuedPage(2, '/de/'); + $this->indexQueuedPage(4711, 0); + $this->indexQueuedPage(4711, 1); // do we have the record in the index with the value from the mm relation? $this->waitToBeVisibleInSolr('core_en'); @@ -173,7 +175,7 @@ public function canIndexPageToCategoryRelation(): void ' ); - $this->indexQueuedPage(10); + $this->indexQueuedPage(); $this->waitToBeVisibleInSolr('core_en'); @@ -199,7 +201,7 @@ public function canIndexPageIntoSolrWithAdditionalFields(): void } ' ); - $this->indexQueuedPage(2); + $this->indexQueuedPage(); // we wait to make sure the document will be available in solr $this->waitToBeVisibleInSolr(); @@ -229,7 +231,7 @@ public function canIndexPageIntoSolrWithAdditionalFieldsFromRootLine(): void ' ); - $this->indexQueuedPage(2); + $this->indexQueuedPage(); // we wait to make sure the document will be available in solr $this->waitToBeVisibleInSolr(); @@ -249,7 +251,7 @@ public function canExecutePostProcessor(): void $this->importCSVDataSet(__DIR__ . '/Fixtures/can_index_into_solr.csv'); $this->addTypoScriptToTemplateRecord(1, 'config.index_enable = 1'); - $this->indexQueuedPage(2); + $this->indexQueuedPage(); // we wait to make sure the document will be available in solr $this->waitToBeVisibleInSolr(); @@ -273,7 +275,7 @@ public function canExecuteAdditionalPageIndexer(): void } ' ); - $this->indexQueuedPage(2, '/en/', ['additionalTestPageIndexer' => true]); + $this->indexQueuedPage(4711, 0, ['additionalTestPageIndexer' => 1]); // we wait to make sure the document will be available in solr $this->waitToBeVisibleInSolr(); @@ -285,67 +287,133 @@ public function canExecuteAdditionalPageIndexer(): void } /** - * This testcase should check if we can queue an custom record with MM relations and respect the additionalWhere clause. + * This testcase should check if we can index a mounted page in the same site * * There is following scenario: * * [0] * | - * ——[20] Shared-Pages (Not root) - * | | - * | ——[24] FirstShared (Not root) - * | - * ——[ 1] Page (Root) - * | - * ——[14] Mount Point (to [24] to show contents from) + * |—[ 1] Page (Root Testpage 1) + * | + * |——[14] Mount Point (to [24] to show contents from) + * |——[24] FirstShared */ #[Test] public function canIndexMountedPage(): void { - self::markTestSkipped('@todo: Fix it. See: https://github.com/TYPO3-Solr/ext-solr/issues/4160'); - $GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] = 1; $this->cleanUpAllCoresOnSolrServerAndAssertEmpty(); $this->importCSVDataSet(__DIR__ . '/Fixtures/can_index_mounted_page.csv'); $this->addTypoScriptToTemplateRecord(1, 'config.index_enable = 1'); - $this->indexQueuedPage(24, '/en/', ['MP' => '24-14']); + $this->indexQueuedPage(); // we wait to make sure the document will be available in solr $this->waitToBeVisibleInSolr(); $solrContent = file_get_contents($this->getSolrConnectionUriAuthority() . '/solr/core_en/select?q=*:*'); - self::assertStringContainsString('"title":"FirstShared (Not root)"', $solrContent, 'Could not find content from mounted page in solr'); + self::assertStringContainsString('"title":"FirstShared"', $solrContent, 'Could not find content from mounted page in Solr'); } /** + * This testcase should check if we can index a cross-site mount, a mount point + * that mounts a page from another site + * * There is following scenario: * * [0] * | - * ——[20] Shared-Pages (Not root) + * |—[ 111] Page (Root Testpage 2) * | | - * | ——[44] FirstShared (Not root) + * | |—[24] FirstShared + * | + * |—[ 1] Page (Root Testpage 1) + * |—[14] Mount Point (to [24] to show contents from) + * + * + * Note: Indexing a cross-site mount point requires that "index_enable" is set + * in the pagetree of the mounted page, as TYPO3 loads the TypoScript + * of the mounted page since TYPO3 13. + */ + #[Test] + public function canIndexCrossSiteMounts(): void + { + $GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] = 1; + + $this->cleanUpAllCoresOnSolrServerAndAssertEmpty(); + $this->importCSVDataSet(__DIR__ . '/Fixtures/can_index_mounted_page_from_another_site.csv'); + $this->addTypoScriptToTemplateRecord(1, 'config.index_enable = 1'); + $this->addTypoScriptToTemplateRecord(111, 'config.index_enable = 1'); + $this->indexQueuedPage(); + + // we wait to make sure the document will be available in solr + $this->waitToBeVisibleInSolr(); + + $solrContent = file_get_contents($this->getSolrConnectionUriAuthority() . '/solr/core_en/select?q=*:*'); + self::assertStringContainsString('"title":"FirstShared"', $solrContent, 'Could not find content from mounted page in Solr'); + } + + /** + * This testcase should check if we can index a cross-site mount, a mount point + * that mounts a page from another pagetree that has no site configuration + * + * There is following scenario: + * + * [0] * | - * ——[ 1] Page (Root) + * |—[ 20] Shared-Pages (Not root) + * | | + * | |—[24] FirstShared (Not root) * | - * ——[14] Mount Point (to [24] to show contents from) + * |—[ 1] Page (Root Testpage 1) + * | + * |—[14] Mount Point (to [24] to show contents from) + */ + #[Test] + public function canIndexCrossSiteMountsWithoutSiteConfiguration(): void + { + self::markTestSkipped('Fails as TYPO3 13 currently can\'t mount a page from a pagetree without a site configuration!'); + $GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] = 1; + + $this->cleanUpAllCoresOnSolrServerAndAssertEmpty(); + $this->importCSVDataSet(__DIR__ . '/Fixtures/can_index_mounted_page_outside_site_root.csv'); + $this->addTypoScriptToTemplateRecord(1, 'config.index_enable = 1'); + $this->indexQueuedPage(24, '/en/'); + + // we wait to make sure the document will be available in solr + $this->waitToBeVisibleInSolr(); + + $solrContent = file_get_contents($this->getSolrConnectionUriAuthority() . '/solr/core_en/select?q=*:*'); + self::assertStringContainsString('"title":"FirstShared"', $solrContent, 'Could not find content from mounted page in Solr'); + } + + /** + * There is following scenario: * + * [0] * | - * ——[ 2] Page (Root) + * |—[111] 2nd page root + * | | + * | |—[44] FirstShared (Not root) * | - * ——[24] Mount Point (to [24] to show contents from) + * |—[ 1] Page (Root) + * | + * |—[14] Mount Point (to [24] to show contents from) + * | + * |—[24] Mount Point (to [24] to show contents from) */ #[Test] public function canIndexMultipleMountedPage(): void { - self::markTestSkipped('@todo: Fix it. See: https://github.com/TYPO3-Solr/ext-solr/issues/4160'); - $this->cleanUpAllCoresOnSolrServerAndAssertEmpty(); $this->importCSVDataSet(__DIR__ . '/Fixtures/can_index_multiple_mounted_page.csv'); $this->addTypoScriptToTemplateRecord(1, 'config.index_enable = 1'); - $this->indexQueuedPage(44, '/en/', ['MP' => '44-14']); - $this->indexQueuedPage(44, '/en/', ['MP' => '44-24']); + + // Enabling "index_enable" is currently required as due to changes in RootlineUtility->generateRootlineCache + // the mount point pid isn't used for the rootline and the TypoScript of the mounted page is loaded. + $this->addTypoScriptToTemplateRecord(111, 'config.index_enable = 1'); + $this->indexQueuedPage(); + $this->indexQueuedPage(4712); // we wait to make sure the document will be available in solr $this->waitToBeVisibleInSolr(); @@ -366,7 +434,7 @@ public function canIndexMultipleMountedPage(): void public function phpProcessDoesNotDieIfPageIsNotAvailable(): void { $this->importCSVDataSet(__DIR__ . '/Fixtures/does_not_die_if_page_not_available.csv'); - $response = $this->indexQueuedPage(1636120156); + $response = $this->indexQueuedPage(forceUrl: 'http://testone.site/?id=1636120156'); $decodedResponse = json_decode($response->getBody()->getContents(), true); self::assertIsArray($decodedResponse, 'Response couldn\'t be decoded'); @@ -378,19 +446,45 @@ public function phpProcessDoesNotDieIfPageIsNotAvailable(): void /** * Executes a Frontend request within the same PHP process (possible since TYPO3 v11). */ - protected function indexQueuedPage(int $pageId = 1, string $siteLanguageBase = '/en/', $additionalQueryParams = [], string $domain = 'http://testone.site'): ResponseInterface - { - $additionalQueryParams['id'] = $pageId; - $additionalQueryParams = array_filter($additionalQueryParams); - $queryString = http_build_query($additionalQueryParams, '', '&'); - $cacheHash = GeneralUtility::makeInstance(CacheHashCalculator::class)->generateForParameters($queryString); - if ($cacheHash) { - $queryString .= '&cHash=' . $cacheHash; + protected function indexQueuedPage( + int $indexQueueItem = 4711, + int $siteLanguageUid = 0, + array $additionalQueryParams = [], + string $forceUrl = '' + ): ResponseInterface { + $item = $this->getIndexQueueItem($indexQueueItem); + + if ($forceUrl !== '') { + return $this->executePageIndexer($forceUrl, $item); + } + + $uriBuilder = GeneralUtility::makeInstance(PageUriBuilder::class); + $mountPointParameter = ''; + if ($item->hasIndexingProperty('isMountedPage')) { + $mountPointParameter = $item->getIndexingProperty('mountPageSource') + . '-' . $item->getIndexingProperty('mountPageDestination'); + } + $url = $uriBuilder->getPageIndexingUriFromPageItemAndLanguageId( + $item, + $siteLanguageUid, + $mountPointParameter, + ); + + if ($additionalQueryParams !== []) { + $url = new Uri($url); + $queryString = ltrim( + $url->getQuery() + . '&id=' . $item->getRecordUid() + . GeneralUtility::implodeArrayForUrl('', $additionalQueryParams), + '&' + ); + $cacheHash = GeneralUtility::makeInstance(CacheHashCalculator::class)->generateForParameters($queryString); + if ($cacheHash) { + $queryString .= '&cHash=' . $cacheHash; + } + $url = (string)$url->withQuery($queryString); } - $url = rtrim($domain, '/') . '/' . ltrim($siteLanguageBase, '/') . '?' . $queryString; - // Now add the headers for item 4711 to the request - $item = $this->getIndexQueueItem(4711); return $this->executePageIndexer($url, $item); } }