Skip to content

Commit ca81320

Browse files
committed
Tighten it up
1 parent b395611 commit ca81320

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/base/Element.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4006,7 +4006,7 @@ public function getAltActions(): array
40064006
}
40074007
}
40084008

4009-
if ($this->getIsDraft()) {
4009+
if ($this->getIsDraft() && !$this->getIsUnpublishedDraft() && !$this->isProvisionalDraft) {
40104010
$altActions[] = [
40114011
'label' => Craft::t('app', 'Save as a new {type}', [
40124012
'type' => Craft::t('app', 'draft'),

src/controllers/ElementsController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,9 +1659,11 @@ public function actionDuplicate(): ?Response
16591659
$elementsService = Craft::$app->getElements();
16601660
$user = static::currentUser();
16611661

1662+
$isExplicitDraft = $element->getIsDraft() && !$element->getIsUnpublishedDraft() && !$element->isProvisionalDraft;
1663+
16621664
// save as a new is now available to people who can create drafts
16631665
$asUnpublishedDraft = $this->_asUnpublishedDraft && $element::hasDrafts();
1664-
if ($asUnpublishedDraft || $element->getIsDraft()) {
1666+
if ($asUnpublishedDraft || $isExplicitDraft) {
16651667
$authorized = $elementsService->canDuplicateAsDraft($element, $user);
16661668
} else {
16671669
$authorized = $elementsService->canDuplicate($element, $user);
@@ -1673,7 +1675,7 @@ public function actionDuplicate(): ?Response
16731675

16741676
$newAttributes = [
16751677
'isProvisionalDraft' => false,
1676-
'draftId' => $element->draftId,
1678+
'draftId' => $isExplicitDraft ? $element->draftId : null,
16771679
];
16781680

16791681
if ($asUnpublishedDraft &&

0 commit comments

Comments
 (0)