diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a2317882ff..3d48cb98df3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ - Fixed styling issues with classic Live Preview. ([#15640](https://github.com/craftcms/cms/issues/15640)) - Fixed a bug where fields were bleeding out of the content pane on smaller viewports. - Fixed a bug where Link fields didn’t allow URLs with TLDs longer than six characters. +- Fixed a bug where hard-deleting an element wasn’t hard-deleting any nested elements as well. ([#15645](https://github.com/craftcms/cms/pull/15645)) +- Fixed a bug where it wasn’t possible to hard-delete nested elements from embedded element index views. ([#15645](https://github.com/craftcms/cms/pull/15645)) ## 5.3.6 - 2024-08-26 diff --git a/src/elements/NestedElementManager.php b/src/elements/NestedElementManager.php index 0836b106413..1540b50088f 100644 --- a/src/elements/NestedElementManager.php +++ b/src/elements/NestedElementManager.php @@ -1236,6 +1236,7 @@ public function deleteNestedElements(ElementInterface $owner, bool $hardDelete = $elementsService = Craft::$app->getElements(); $query = $this->nestedElementQuery($owner) ->status(null) + ->trashed(null) ->siteId($siteId); $query->{$this->ownerIdParam} = null; $query->{$this->primaryOwnerIdParam} = $owner->id; diff --git a/src/elements/actions/Delete.php b/src/elements/actions/Delete.php index c4b247430d4..29f80cb6e9f 100644 --- a/src/elements/actions/Delete.php +++ b/src/elements/actions/Delete.php @@ -231,8 +231,8 @@ private function deleteElement( Elements $elementsService, array &$deleteOwnership, ): void { - // If the element primarily belongs to a different element, just delete the ownership - if ($element instanceof NestedElementInterface) { + // If the element primarily belongs to a different element, (and we're not hard deleting) just delete the ownership + if (!$this->hard && $element instanceof NestedElementInterface) { $ownerId = $element->getOwnerId(); if ($ownerId && $element->getPrimaryOwnerId() !== $ownerId) { $deleteOwnership[$ownerId][] = $element->id;