Skip to content

Commit

Permalink
Merge pull request #15645 from craftcms/bugfix/delete-permanently-and…
Browse files Browse the repository at this point in the history
…-nested-elements

get trashed elements too, so that delete permanently works as expected
  • Loading branch information
brandonkelly committed Sep 3, 2024
2 parents b64b9b6 + 5136c9f commit 8f3c12d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/elements/NestedElementManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/elements/actions/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8f3c12d

Please sign in to comment.