From fd73f99b31600774ce4a5e9417edf01f966bd4f6 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 6 Sep 2024 10:45:57 +0100 Subject: [PATCH 1/2] Fixed `ElementCondition::$elementType` being reset in `__construct()` --- CHANGELOG.md | 1 + src/elements/conditions/ElementCondition.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e20e0091137..b7b224cea3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fixed styling issues with Template field layout UI elements’ selector labels. - Fixed a validation error that could occur when saving a relational field, if the “Maintain hierarchy” setting had been enabled but was no longer applicable. ([#15666](https://github.com/craftcms/cms/issues/15666)) - Fixed an information disclosure vulnerability. +- Fixed a bug where element conditions could have their `$elementType` property reset. ## 4.12.0 - 2024-09-03 diff --git a/src/elements/conditions/ElementCondition.php b/src/elements/conditions/ElementCondition.php index 666797f9f38..4db897b43ec 100644 --- a/src/elements/conditions/ElementCondition.php +++ b/src/elements/conditions/ElementCondition.php @@ -73,7 +73,10 @@ public function __construct(?string $elementType = null, array $config = []) throw new InvalidConfigException("Invalid element type: $elementType"); } - $this->elementType = $elementType; + if ($elementType !== null) { + $this->elementType = $elementType; + } + parent::__construct($config); } From 636fa3dbc464fd48aa66545a31e2ad8dbe0511c9 Mon Sep 17 00:00:00 2001 From: Brandon Kelly Date: Fri, 6 Sep 2024 03:38:45 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b224cea3d..e20e0091137 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,6 @@ - Fixed styling issues with Template field layout UI elements’ selector labels. - Fixed a validation error that could occur when saving a relational field, if the “Maintain hierarchy” setting had been enabled but was no longer applicable. ([#15666](https://github.com/craftcms/cms/issues/15666)) - Fixed an information disclosure vulnerability. -- Fixed a bug where element conditions could have their `$elementType` property reset. ## 4.12.0 - 2024-09-03