Browse Source

Only create a new draft row if duplicating a draft to another draft

pull/7531/head
brandonkelly 5 years ago
parent
commit
d7f4861cd7
  1. 3
      CHANGELOG.md
  2. 4
      src/services/Elements.php

3
CHANGELOG.md

@ -1,5 +1,8 @@
# Release Notes for Craft CMS 3.x
## Unreleased
- Fixed a bug where extra rows could be created in the `drafts` table.
## 3.6.4 - 2021-02-05
### Added

4
src/services/Elements.php

@ -987,8 +987,8 @@ class Elements extends Component
throw new UnsupportedSiteException($element, $mainClone->siteId, 'Attempting to duplicate an element in an unsupported site.');
}
// If this is a draft, create a new draft row
if ($mainClone->draftId) {
// If we are duplicating a draft as another draft, create a new draft row
if ($mainClone->draftId && $mainClone->draftId === $element->draftId) {
/** @var ElementInterface|DraftBehavior $element */
$mainClone->draftId = Craft::$app->getDrafts()->insertDraftRow(Craft::t('app', 'First draft'), null, Craft::$app->getUser()->getId());
}

Loading…
Cancel
Save