From b4587f5d66679bf770404eaf5f1bef5f17b4eb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20K=C3=A4hm?= Date: Tue, 31 Oct 2023 00:46:34 +0100 Subject: [PATCH] [BUGFIX] Avoid unacceptable slug changes on locked slugs EXT:sluggi always(on each pages change) rewrites the slug with path segments to the last path segment, even the slug is locked and not changed by editor. Also from `/virtual-parent-slug/my-test-page` to `/my-test-page`. This change prevents overrides on slugs at least on "locked" slugs. **Note: This is a partial fix only and not locked slugs will be still overridden.** Relates: #98 --- Classes/Backend/Form/InputSlugElement.php | 2 +- Classes/DataHandler/HandlePageUpdate.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/Backend/Form/InputSlugElement.php b/Classes/Backend/Form/InputSlugElement.php index ff7a49b..f39a750 100644 --- a/Classes/Backend/Form/InputSlugElement.php +++ b/Classes/Backend/Form/InputSlugElement.php @@ -73,7 +73,7 @@ private function updateUiForRestrictedAccess(array $result): array if (!empty($inaccessibleSlugSegments) && 0 === strncmp($editableSlugSegments, $inaccessibleSlugSegments, strlen($inaccessibleSlugSegments))) { $editableSlugSegments = substr($editableSlugSegments, strlen($inaccessibleSlugSegments)); } - if ($allowOnlyLastSegment && !empty($editableSlugSegments)) { + if ($allowOnlyLastSegment && !($this->data['databaseRow']['slug_locked']) && !empty($editableSlugSegments)) { $segments = explode('/', $editableSlugSegments); $editableSlugSegments = '/' . array_pop($segments); $prefix .= implode('/', $segments); diff --git a/Classes/DataHandler/HandlePageUpdate.php b/Classes/DataHandler/HandlePageUpdate.php index af78cfa..732e87c 100644 --- a/Classes/DataHandler/HandlePageUpdate.php +++ b/Classes/DataHandler/HandlePageUpdate.php @@ -66,7 +66,7 @@ public function processDatamap_preProcessFieldArray( if ($this->shouldSynchronize($pageRecord, $fields)) { $fields = $this->synchronize($pageRecord, $fields); - } elseif ($this->isManualUpdateWithOnlyLastSegmentAllowed($fields)) { + } elseif ($this->isManualUpdateWithOnlyLastSegmentAllowed($fields) && !($pageRecord['slug_locked'])) { $fields = $this->updateLastSegment($pageRecord, $fields); } }