From 0265805f05a1d2af72602ff1455aaa3c4d13d101 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 27 Dec 2024 06:44:48 -0800 Subject: [PATCH] Filter out field layouts for invalid element types Fixes #16352 --- CHANGELOG.md | 1 + src/services/Fields.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abcf648300c..2d4bbb12105 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Fixed a bug where custom fields were getting included in rendered field layout forms, even if their `getInputHtml()` method returned an empty string. - Fixed a bug where the password input on the Set Password page wasn’t including the “Show” button. - Fixed a SQL error that could occur if an element was saved with a title longer than 255 characters. +- Fixed errors that could occur when working with field layouts for element types that are no longer installed. ([#16352](https://github.com/craftcms/cms/issues/16352)) - Fixed an RCE vulnerability. ## 4.13.7 - 2024-12-17 diff --git a/src/services/Fields.php b/src/services/Fields.php index 69dfc959285..8d4c348a5d5 100644 --- a/src/services/Fields.php +++ b/src/services/Fields.php @@ -1098,7 +1098,10 @@ private function _layouts(): MemoizableArray { if (!isset($this->_layouts)) { if (Craft::$app->getIsInstalled()) { - $layoutConfigs = $this->_createLayoutQuery()->all(); + $layoutConfigs = $this->_createLayoutQuery()->collect() + ->filter(fn(array $config) => ComponentHelper::validateComponentClass($config['type'], ElementInterface::class)) + ->values() + ->all(); $layoutTabConfigs = ArrayHelper::index($this->_createLayoutTabQuery()->all(), null, ['layoutId']); } else { $layoutConfigs = [];