From 24d8532ef3a60add995192138dd3c790cd696754 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 18 Oct 2024 11:10:10 -0700 Subject: [PATCH] Respect predefined volume UUIDs --- CHANGELOG.md | 2 +- src/services/Volumes.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1da745eead5..f270ff3361a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - Fixed errors that occurred when working with nested entries for a newly-added site. ([#15898](https://github.com/craftcms/cms/pull/15898)) - Fixed a bug where it wasn’t possible to scroll the section select modal when moving entries to a different section. ([#15900](https://github.com/craftcms/cms/issues/15900)) - Fixed a bug where query params in the format of `' '` weren’t being parsed correctly. -- Fixed a bug there `craft\services\Entries::saveSection()` wasn’t respecting predefined UUID values on new sections. +- Fixed a bug `craft\services\Entries::saveSection()` and `craft\services\Volumes::saveVolume()` weren’t respecting predefined UUID values on new models. ## 5.4.8 - 2024-10-15 diff --git a/src/services/Volumes.php b/src/services/Volumes.php index 7860529b608..378d47f4dc9 100644 --- a/src/services/Volumes.php +++ b/src/services/Volumes.php @@ -296,7 +296,10 @@ public function saveVolume(Volume $volume, bool $runValidation = true): bool } if ($isNewVolume) { - $volume->uid = StringHelper::UUID(); + if (!$volume->uid) { + $volume->uid = StringHelper::UUID(); + } + $volume->sortOrder = (new Query()) ->from([Table::VOLUMES]) ->max('[[sortOrder]]') + 1;