From 68e6b76a0dc0f9800f5aa95c4cb12a5e01c24800 Mon Sep 17 00:00:00 2001 From: Susanne Moog <look@susi.dev> Date: Wed, 9 Nov 2022 10:44:25 +0100 Subject: [PATCH] [FEATURE] Show warning about duplicate rootPageIds in sites module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sites module now displays a warning in case the same root page ID is used for multiple site configurations, as only the last one will be used. Resolves: #93423 Releases: main Change-Id: I984fde19a96ef73e6282f70d45775264c141c147 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76516 Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Oliver Bartsch <bo@cedev.de> --- .../SiteConfigurationController.php | 8 ++++++ .../Language/locallang_siteconfiguration.xlf | 6 +++++ .../Templates/SiteConfiguration/Overview.html | 22 +++++++++++++++ ...gAboutDuplicatedRootPagesInSitesModule.rst | 27 +++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 typo3/sysext/core/Documentation/Changelog/12.1/Feature-93423-ShowWarningAboutDuplicatedRootPagesInSitesModule.rst diff --git a/typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php b/typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php index 53f563c47058..c259e333c405 100644 --- a/typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php +++ b/typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php @@ -98,8 +98,15 @@ class SiteConfigurationController $allSites = $this->siteFinder->getAllSites(); $pages = $this->getAllSitePages(); $unassignedSites = []; + $duplicatedRootPages = []; foreach ($allSites as $identifier => $site) { $rootPageId = $site->getRootPageId(); + if (isset($pages[$rootPageId]['siteConfiguration'])) { + // rootPage is already used in a site configuration + $duplicatedRootPages[$rootPageId][] = $pages[$rootPageId]['siteConfiguration']->getIdentifier(); + $duplicatedRootPages[$rootPageId][] = $site->getIdentifier(); + $duplicatedRootPages[$rootPageId] = array_unique($duplicatedRootPages[$rootPageId]); + } if (isset($pages[$rootPageId])) { $pages[$rootPageId]['siteIdentifier'] = $identifier; $pages[$rootPageId]['siteConfiguration'] = $site; @@ -116,6 +123,7 @@ class SiteConfigurationController $view->assignMultiple([ 'pages' => $pages, 'unassignedSites' => $unassignedSites, + 'duplicatedRootPages' => $duplicatedRootPages, 'duplicatedEntryPoints' => $this->getDuplicatedEntryPoints($allSites, $pages), ]); return $view->renderResponse('SiteConfiguration/Overview'); diff --git a/typo3/sysext/backend/Resources/Private/Language/locallang_siteconfiguration.xlf b/typo3/sysext/backend/Resources/Private/Language/locallang_siteconfiguration.xlf index 4bbe05e83cef..c54671f16c2b 100644 --- a/typo3/sysext/backend/Resources/Private/Language/locallang_siteconfiguration.xlf +++ b/typo3/sysext/backend/Resources/Private/Language/locallang_siteconfiguration.xlf @@ -45,6 +45,12 @@ <trans-unit id="overview.duplicatedEntryPoints.listing" resname="overview.duplicatedEntryPoints.listing"> <source>The following entry points are used more than once:</source> </trans-unit> + <trans-unit id="overview.duplicatedRootPage" resname="overview.duplicatedRootPage"> + <source>Duplicated root pages</source> + </trans-unit> + <trans-unit id="overview.duplicatedRootPage.message" resname="overview.duplicatedRootPage.message"> + <source>The page with ID "%1s" is used in the following site configurations:</source> + </trans-unit> <trans-unit id="validation.identifierRenamed.title" resname="validation.identifierRenamed.title"> <source>Renamed identifier</source> </trans-unit> diff --git a/typo3/sysext/backend/Resources/Private/Templates/SiteConfiguration/Overview.html b/typo3/sysext/backend/Resources/Private/Templates/SiteConfiguration/Overview.html index 5f362e0aabfa..8a869608e8f2 100644 --- a/typo3/sysext/backend/Resources/Private/Templates/SiteConfiguration/Overview.html +++ b/typo3/sysext/backend/Resources/Private/Templates/SiteConfiguration/Overview.html @@ -19,6 +19,28 @@ <f:if condition="{pages}"> <f:then> + <f:if condition="{duplicatedRootPages}"> + <f:be.infobox title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_siteconfiguration.xlf:overview.duplicatedRootPage')}" state="1"> + <ul> + <f:for each="{duplicatedRootPages}" key="rootPage" as="duplicateSites"> + <li> + <strong> + <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_siteconfiguration.xlf:overview.duplicatedRootPage.message" arguments="{0: rootPage}" /> + </strong> + <f:if condition="{duplicateSites}"> + <ul> + <f:for each="{duplicateSites}" as="duplicateSite"> + <li> + {duplicateSite} + </li> + </f:for> + </ul> + </f:if> + </li> + </f:for> + </ul> + </f:be.infobox> + </f:if> <f:if condition="{duplicatedEntryPoints}"> <f:be.infobox title="{f:translate(key: 'LLL:EXT:backend/Resources/Private/Language/locallang_siteconfiguration.xlf:overview.duplicatedEntryPoints')}" state="1"> <f:translate key="LLL:EXT:backend/Resources/Private/Language/locallang_siteconfiguration.xlf:overview.duplicatedEntryPoints.listing" /> diff --git a/typo3/sysext/core/Documentation/Changelog/12.1/Feature-93423-ShowWarningAboutDuplicatedRootPagesInSitesModule.rst b/typo3/sysext/core/Documentation/Changelog/12.1/Feature-93423-ShowWarningAboutDuplicatedRootPagesInSitesModule.rst new file mode 100644 index 000000000000..9fc901bf309f --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/12.1/Feature-93423-ShowWarningAboutDuplicatedRootPagesInSitesModule.rst @@ -0,0 +1,27 @@ +.. include:: /Includes.rst.txt + +.. _feature-93423-1667988850: + +========================================================================== +Feature: #93423 - Show warning about duplicated root pages in sites module +========================================================================== + +See :issue:`93423` + +Description +=========== + +It might happen that the same root page ID is configured for multiple site +configurations, e.g. in case corresponding files were copied manually. This +might lead to misbehavior, since always the last site with this root page +id defined is used by TYPO3. As such configuration errors might be hard to +spot does the :guilabel:`Sites` module now inform about such duplications in +the site configuration overview view. + +Impact +====== + +The site module now warns administrators in case the same root page ID is used +in multiple site configurations. + +.. index:: Backend, ext:backend -- GitLab