[BUGFIX] Ensure to use parent's page slug for generating a new pages' slug 00/58100/3
authorBenni Mack <benni@typo3.org>
Fri, 31 Aug 2018 09:43:25 +0000 (11:43 +0200)
committerFrans Saris <franssaris@gmail.com>
Fri, 31 Aug 2018 12:10:19 +0000 (14:10 +0200)
When creating page with slug "/my-page", and then renaming the page title
to "My new page", the slug for a newly created SUBpage will be "/my-new-page/subpage",
however, it is expected to use the slug of the parent page, if it exists,
creating a new URL like "{current-slug-of-parent-page}/subpage"

Resolves: #85997
Releases: master
Change-Id: I1c6371d174c8251623e806beb1544c477c31d5b0
Reviewed-on: https://review.typo3.org/58100
Reviewed-by: Francois Suter <sutfra@gmail.com>
Tested-by: Francois Suter <sutfra@gmail.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/core/Classes/DataHandling/SlugHelper.php

index c081e8b..e2a8369 100644 (file)
@@ -151,7 +151,12 @@ class SlugHelper
                 }
             }
             if (is_array($parentPageRecord)) {
-                $rootLineItemSlug = $this->generate($parentPageRecord, (int)$parentPageRecord['pid']);
+                // If the parent page has a slug, use that instead of "re-generating" the slug from the parents' page title
+                if (!empty($parentPageRecord['slug'])) {
+                    $rootLineItemSlug = $parentPageRecord['slug'];
+                } else {
+                    $rootLineItemSlug = $this->generate($parentPageRecord, (int)$parentPageRecord['pid']);
+                }
                 $rootLineItemSlug = trim($rootLineItemSlug, '/');
                 if (!empty($rootLineItemSlug)) {
                     $prefix = $rootLineItemSlug;