From 375df696e3ae9c1dd7605bfee8a6d6c780ba070a Mon Sep 17 00:00:00 2001 From: i-just Date: Wed, 11 Dec 2024 14:52:32 +0000 Subject: [PATCH 1/2] when getting element by uid check for unpublished draft too --- src/controllers/ElementsController.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/controllers/ElementsController.php b/src/controllers/ElementsController.php index 550b78327c6..b075dad18d2 100644 --- a/src/controllers/ElementsController.php +++ b/src/controllers/ElementsController.php @@ -2351,19 +2351,28 @@ private function _elementById( } if ($elementUid) { - $withDrafts = false; - if (!Craft::$app->getConfig()->getGeneral()->autosaveDrafts) { - $withDrafts = null; + $element = $this->_elementQuery($elementType) + ->uid($elementUid) + ->siteId($siteId) + ->preferSites($preferSites) + ->unique() + ->status(null) + ->one(); + + if ($element) { + return $element; } + + // check for an unpublished draft if we got this far + // (e.g. newly added matrix "block" or where autosaveDrafts is off) + // https://github.com/craftcms/cms/issues/15985 return $this->_elementQuery($elementType) ->uid($elementUid) ->siteId($siteId) ->preferSites($preferSites) - // when autosaveDrafts is off, we need search among drafts too - // https://github.com/craftcms/cms/issues/15985 - ->drafts($withDrafts) ->unique() ->status(null) + ->draftOf(false) ->one(); } From 37c6f58ff28d663c246436d0cc609e0db33b7653 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Wed, 11 Dec 2024 14:56:10 -0800 Subject: [PATCH 2/2] Release note [ci skip] --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccea4310eda..3e683a6ed54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Craft CMS 5 +## Unreleased + +- Fixed a bug where field conditions weren’t taking effect within Matrix fields set to inline-editable blocks mode, if the owner element didn’t support drafts. ([#16315](https://github.com/craftcms/cms/pull/16315)) + ## 5.5.6.1 - 2024-12-11 - Fixed a bug where Tags fields had “Replace” actions. ([#16310](https://github.com/craftcms/cms/issues/16310))