From af25ac54b3672124f57bda99aeaf83064077b400 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 19 Nov 2024 09:09:09 -0800 Subject: [PATCH] Fixed #16150 --- CHANGELOG.md | 1 + src/services/Fields.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bcaf1a4844..b59ca74678f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fixed an error that could occur if an invalid folder ID was passed to `craft\services\Assets::deleteFoldersByIds()`. ([#16147](https://github.com/craftcms/cms/pull/16147)) - Fixed a SQL error that occurred when creating a new Single section. ([#16145](https://github.com/craftcms/cms/issues/16145)) - Fixed an error that occurred when running the `resave/all` command, if any of the options passed weren’t supported by other `resave/*` commands. ([#16148](https://github.com/craftcms/cms/pull/16148)) +- Fixed an error that occurred when restoring a soft-deleted custom field. ([#16150](https://github.com/craftcms/cms/issues/16150)) - Fixed an RCE vulnerability. ## 5.5.1.1 - 2024-11-18 diff --git a/src/services/Fields.php b/src/services/Fields.php index 168fe599ebe..41543f1fd9e 100644 --- a/src/services/Fields.php +++ b/src/services/Fields.php @@ -1410,7 +1410,7 @@ public function applyFieldSave(string $fieldUid, array $data, string $context): // Tell the current CustomFieldBehavior class about the field CustomFieldBehavior::$fieldHandles[$fieldRecord->handle] = true; - if ($isNewField) { + if ($isNewField || $field === null) { // Try fetching the field again, if it didn’t exist to begin with $field ??= $this->getFieldById($fieldRecord->id); $field->id = $fieldRecord->id;