Skip to content

Commit

Permalink
Fixed #15517
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Aug 12, 2024
1 parent 94465bb commit 32e3eb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft CMS 5

## Unreleased

- Fixed an error that could occur if a new element was saved recursively. ([#15517](https://github.com/craftcms/cms/issues/15517))

## 5.3.2 - 2024-08-10

- Added `craft\db\afterDown()`.
Expand Down
6 changes: 6 additions & 0 deletions src/services/Elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,11 @@ public function saveElement(
$duplicateOf = $element->duplicateOf;
$element->duplicateOf = null;

// Force isNewForSite = false here, in case the element is getting saved recursively
// (see https://github.com/craftcms/cms/issues/15517)
$isNewForSite = $element->isNewForSite;
$element->isNewForSite = false;

$success = $this->_saveElementInternal(
$element,
$runValidation,
Expand All @@ -1290,6 +1295,7 @@ public function saveElement(
);

$element->duplicateOf = $duplicateOf;
$element->isNewForSite = $isNewForSite;

return $success;
}
Expand Down

0 comments on commit 32e3eb5

Please sign in to comment.