From fc8ca3e9999523b4b4c52d43b48f921e3c337173 Mon Sep 17 00:00:00 2001 From: Rias Date: Mon, 20 Jul 2026 09:57:19 +0200 Subject: [PATCH 1/2] Prevent incompatible bulk entry moves --- src/controllers/EntriesController.php | 9 ++++++++- src/services/Entries.php | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/controllers/EntriesController.php b/src/controllers/EntriesController.php index e7762a8380a..6e1d762f5ab 100644 --- a/src/controllers/EntriesController.php +++ b/src/controllers/EntriesController.php @@ -424,7 +424,7 @@ public function actionMoveToSectionModalData(): Response $sectionEntryTypes = array_map(fn($et) => $et->id, $section->entryTypes); - return !empty(array_intersect($entryTypes, $sectionEntryTypes)); + return !empty($entryTypes) && empty(array_diff($entryTypes, $sectionEntryTypes)); }) ->sortBy(fn(Section $section) => $section->getUiLabel()) ->all(); @@ -491,6 +491,13 @@ public function actionMoveToSection(): Response } } + $sectionEntryTypeIds = array_map(fn($entryType) => $entryType->id, $section->getEntryTypes()); + $entryTypeIds = array_unique(array_map(fn(Entry $entry) => $entry->typeId, $entries)); + + if (!empty(array_diff($entryTypeIds, $sectionEntryTypeIds))) { + throw new BadRequestHttpException('Not all entries have a type supported by the target section.'); + } + $errors = []; foreach ($entries as $entry) { try { diff --git a/src/services/Entries.php b/src/services/Entries.php index 9e3d4672526..f8146b5d9e3 100644 --- a/src/services/Entries.php +++ b/src/services/Entries.php @@ -2214,6 +2214,12 @@ public function moveEntryToSection(Entry $entry, Section $section): bool throw new Exception('Attempting to move a nested element.'); } + $sectionEntryTypeIds = array_map(fn($entryType) => $entryType->id, $section->getEntryTypes()); + + if (!in_array($entry->typeId, $sectionEntryTypeIds, true)) { + throw new Exception('Entry type is not supported by the target section.'); + } + // Ensure all fields have been normalized $entry->getFieldValues(); From fb05fa772e4744a27f1596d8d94e259049aab3dd Mon Sep 17 00:00:00 2001 From: Rias Date: Mon, 20 Jul 2026 09:59:06 +0200 Subject: [PATCH 2/2] Changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 531c8fae8fc..50b8472f02b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft CMS 5 +## Unreleased + +- Fixed a bug where bulk entry moves could assign entries to sections that didn’t support their entry types. ([#19268](https://github.com/craftcms/cms/pull/19268)) + ## 5.10.11 - 2026-07-15 - Added `craft\gql\base\MutationResolver::requireAllowedSite()`.