From eeeacf640bc231e1a2bd5c92af3d744232813992 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20E=C3=9Fl?= <indy.essl@gmail.com>
Date: Sat, 4 Apr 2020 16:07:54 +0200
Subject: [PATCH] [TASK] Lift doktype restrictions in
 SlugHelper::resolveParentPageRecord

The changes made in #18079 lifted the restrictions for using doktypes
with a number higher than 200 in several parts of the frontend.
These restrictions were still present in the SlugHelper upon resolving
a parent page record (which automatically fetches the slugs of parent
pages for a child page upon creating its slug).
This hard restriction made it impossible to automatically resolve the
slug of a parent page with a doktype higher than 200.

The check is now adjusted to solely exclude the following doktypes:
* DOKTYPE_SPACER (199)
* DOKTYPE_SYSFOLDER (254)
* DOKTYPE_RECYCLER (255)

Resolves: #90947
Related: #18079
Releases: master
Change-Id: Ia71ad2251969a73875124c80ea7521212e459150
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64073
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Guido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
---
 .../sysext/core/Classes/DataHandling/SlugHelper.php  | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/core/Classes/DataHandling/SlugHelper.php b/typo3/sysext/core/Classes/DataHandling/SlugHelper.php
index a2227ca981b1..83d309c8ec8d 100644
--- a/typo3/sysext/core/Classes/DataHandling/SlugHelper.php
+++ b/typo3/sysext/core/Classes/DataHandling/SlugHelper.php
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\WorkspaceRestriction;
 use TYPO3\CMS\Core\DataHandling\Model\RecordState;
 use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory;
+use TYPO3\CMS\Core\Domain\Repository\PageRepository;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -548,7 +549,7 @@ class SlugHelper
     }
 
     /**
-     * Fetch a parent page, but exclude spacers, recyclers and sys-folders and all doktypes > 200
+     * Fetch a parent page, but exclude spacers, recyclers and sys-folders
      * @param int $pid
      * @param int $languageId
      * @return array|null
@@ -557,10 +558,15 @@ class SlugHelper
     {
         $parentPageRecord = null;
         $rootLine = BackendUtility::BEgetRootLine($pid, '', true, ['nav_title']);
+        $excludeDokTypes = [
+            PageRepository::DOKTYPE_SPACER,
+            PageRepository::DOKTYPE_RECYCLER,
+            PageRepository::DOKTYPE_SYSFOLDER
+        ];
         do {
             $parentPageRecord = array_shift($rootLine);
-            // do not use spacers (199), recyclers and folders and everything else
-        } while (!empty($rootLine) && (int)$parentPageRecord['doktype'] >= 199);
+            // exclude spacers, recyclers and folders
+        } while (!empty($rootLine) && in_array((int)$parentPageRecord['doktype'], $excludeDokTypes, true));
         if ($languageId > 0) {
             $languageIds = [$languageId];
             $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
-- 
GitLab