From f7b09b0514d73124a9e65bea653f9b5100b790be Mon Sep 17 00:00:00 2001 From: Ransom Date: Mon, 24 Feb 2020 15:15:19 -0500 Subject: [PATCH] Fix field layout determination for entries --- CHANGELOG.md | 4 ++++ composer.json | 4 ++-- src/elements/processors/EntryProcessor.php | 15 +++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8554501..63681a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Bulk Edit Changelog +## 2.0.3 - 2020-02-24 +### Fixed +- Bug where bulk editing a section with a field layout that had been deleted could yield no fields + ## 2.0.2.1 - 2020-02-20 ### Fixed - Error that can occur if trying to bulkedit fields on a soft-deleted layout diff --git a/composer.json b/composer.json index f69620e..509a0cc 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "name": "venveo/craft-bulkedit", - "description": "Bulk edit entries", + "description": "Bulk edit Craft CMS element fields", "type": "craft-plugin", - "version": "2.0.2.1", + "version": "2.0.3", "keywords": [ "craft", "cms", diff --git a/src/elements/processors/EntryProcessor.php b/src/elements/processors/EntryProcessor.php index a5232b0..aa028e1 100644 --- a/src/elements/processors/EntryProcessor.php +++ b/src/elements/processors/EntryProcessor.php @@ -21,17 +21,16 @@ class EntryProcessor extends AbstractElementTypeProcessor */ public static function getLayoutsFromElementIds($elementIds): array { - $layouts = FieldLayout::find() - ->select('fieldlayouts.*') + $types = \craft\records\Entry::find() + ->select('entrytypes.fieldLayoutId') ->distinct(true) ->limit(null) - ->from('{{%fieldlayouts}} fieldlayouts') - ->leftJoin('{{%elements}} elements', '[[elements.fieldLayoutId]] = [[fieldlayouts.id]]') - ->where(['IN', '[[elements.id]]', $elementIds]) - ->andWhere(['=','fieldlayouts.dateDeleted', null]) - ->all(); + ->from('{{%entries}} entries') + ->leftJoin('{{%entrytypes}} entrytypes', '[[entries.typeId]] = [[entrytypes.id]]') + ->where(['IN', '[[entries.id]]', $elementIds]) + ->column(); - return $layouts; + return FieldLayout::find()->where(['IN', '[[id]]', $types])->all(); } /**