From 1e766c5c5d418ce37c01537f2fea1cc67a02f9a5 Mon Sep 17 00:00:00 2001 From: Helmut Hummel <typo3@helhum.io> Date: Tue, 19 May 2020 12:09:55 +0200 Subject: [PATCH] [BUGFIX] Loosen site check for records not stored in site context When saving a record on a page that is not part of a site, the slug field of this record, despite being set to "uniqueInSite" is not checked for uniqueness, as it is assumed unique enough. This assumption needs to be applied as well when resolving the record, instead of assuming the resolved record is not part of the current site. Releases: master, 9.5 Resolves: #91438 Change-Id: I347909b9b4caa523de3ad8e5d84c465e5d57b052 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64520 Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Hader <oliver.hader@typo3.org> Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Oliver Hader <oliver.hader@typo3.org> --- typo3/sysext/core/Classes/DataHandling/SlugHelper.php | 3 +++ .../core/Classes/Routing/Aspect/SiteAccessorTrait.php | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/typo3/sysext/core/Classes/DataHandling/SlugHelper.php b/typo3/sysext/core/Classes/DataHandling/SlugHelper.php index 77aee4f2a7f2..d6327ebbc7ad 100644 --- a/typo3/sysext/core/Classes/DataHandling/SlugHelper.php +++ b/typo3/sysext/core/Classes/DataHandling/SlugHelper.php @@ -303,6 +303,9 @@ class SlugHelper $siteOfCurrentRecord = $siteFinder->getSiteByPageId($pageId); } catch (SiteNotFoundException $e) { // Not within a site, so nothing to do + // TODO: Rather than silently ignoring this misconfiguration, + // a warning should be thrown here, or maybe even let the + // exception bubble up and catch it in places that uses this API return true; } foreach ($records as $record) { diff --git a/typo3/sysext/core/Classes/Routing/Aspect/SiteAccessorTrait.php b/typo3/sysext/core/Classes/Routing/Aspect/SiteAccessorTrait.php index cb444d519fb9..1fce0616a8a5 100644 --- a/typo3/sysext/core/Classes/Routing/Aspect/SiteAccessorTrait.php +++ b/typo3/sysext/core/Classes/Routing/Aspect/SiteAccessorTrait.php @@ -95,7 +95,11 @@ trait SiteAccessorTrait $expectedSite = $this->getSiteMatcher()->matchByPageId($pageId); return $expectedSite->getRootPageId() === $this->site->getRootPageId(); } catch (SiteNotFoundException $exception) { - return false; + // Same as in \TYPO3\CMS\Core\DataHandling\SlugHelper::isUniqueInSite + // where it is assumed that a record, that is not in site context, + // but still configured uniqueInSite is unique. We therefore must assume + // the resolved record to be rightfully part of the current site. + return true; } } -- GitLab