diff --git a/CHANGELOG.md b/CHANGELOG.md index f76c3c72b52..6304573d7db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft CMS 4 +## Unreleased + +- Fixed an error that occurred when creating a new Structure section. ([#16476](https://github.com/craftcms/cms/issues/16476)) + ## 4.14.0.1 - 2025-01-21 - Fixed an error that occurred when referencing a single section entry by its handle. ([#16474](https://github.com/craftcms/cms/issues/16474)) diff --git a/src/services/Sections.php b/src/services/Sections.php index e33288864dd..b3c47104dfa 100644 --- a/src/services/Sections.php +++ b/src/services/Sections.php @@ -616,8 +616,8 @@ public function handleChangedSection(ConfigEvent $event): void // see https://github.com/craftcms/cms/issues/16450 if ( $isNewStructure && - $event->oldValue['type'] === Section::TYPE_STRUCTURE && - $event->oldValue['structure']['uid'] !== $structureUid && + ($event->oldValue['type'] ?? null) === Section::TYPE_STRUCTURE && + ($event->oldValue['structure']['uid'] ?? null) !== $structureUid && $sectionRecord->structureId ) { $structuresService->deleteStructureById($sectionRecord->structureId);