Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX Use canDelete, not the now-deleted canArchive #2984

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions code/BatchActions/CMSBatchAction_Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use SilverStripe\ORM\SS_List;
use SilverStripe\Admin\CMSBatchAction;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Dev\Deprecation;

/**
* Delete items batch action.
Expand All @@ -28,7 +27,6 @@ public function run(SS_List $pages): HTTPResponse

public function applicablePages($ids)
{
// canArchive() is deprecated, not $this->applicablePagesHelper()
return Deprecation::withNoReplacement(fn() => $this->applicablePagesHelper($ids, 'canArchive'));
return $this->applicablePagesHelper($ids, 'canDelete');
}
}
4 changes: 1 addition & 3 deletions code/Controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use SilverStripe\Core\Environment;
use SilverStripe\Core\Flushable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\DateField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldGroup;
Expand Down Expand Up @@ -1998,8 +1997,7 @@ public function archive(array $data, Form $form): HTTPResponse
if (!$record || !$record->exists()) {
throw new HTTPResponse_Exception("Bad record ID #$id", 404);
}
$canArchive = Deprecation::withNoReplacement(fn() => $record->canArchive());
if (!$canArchive) {
if (!$record->canDelete()) {
return Security::permissionFailure();
}

Expand Down
28 changes: 12 additions & 16 deletions code/Model/SiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use SilverStripe\Core\Manifest\ModuleResourceLoader;
use SilverStripe\Core\Manifest\VersionProvider;
use SilverStripe\Core\Resettable;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\CompositeField;
use SilverStripe\Forms\DropdownField;
Expand Down Expand Up @@ -2593,21 +2592,18 @@ public function getCMSActions()
}

// If a page is on any stage it can be archived
if (($isOnDraft || $isPublished)) {
$canArchive = Deprecation::withNoReplacement(fn() => $this->canArchive());
if ($canArchive) {
$title = $isPublished
? _t('SilverStripe\\CMS\\Controllers\\CMSMain.UNPUBLISH_AND_ARCHIVE', 'Unpublish and archive')
: _t('SilverStripe\\CMS\\Controllers\\CMSMain.ARCHIVE', 'Archive');
$moreOptions->push(
FormAction::create('archive', $title)
->addExtraClass('delete btn btn-secondary' . ($this->isHomePage() ? ' homepage-warning' : ''))
->setDescription(_t(
'SilverStripe\\CMS\\Model\\SiteTree.BUTTONDELETEDESC',
'Remove from draft/live and send to archive'
))
);
}
if (($isOnDraft || $isPublished) && $this->canDelete()) {
$title = $isPublished
? _t('SilverStripe\\CMS\\Controllers\\CMSMain.UNPUBLISH_AND_ARCHIVE', 'Unpublish and archive')
: _t('SilverStripe\\CMS\\Controllers\\CMSMain.ARCHIVE', 'Archive');
$moreOptions->push(
FormAction::create('archive', $title)
->addExtraClass('delete btn btn-secondary' . ($this->isHomePage() ? ' homepage-warning' : ''))
->setDescription(_t(
'SilverStripe\\CMS\\Model\\SiteTree.BUTTONDELETEDESC',
'Remove from draft/live and send to archive'
))
);
}

// "save", supports an alternate state that is still clickable, but notifies the user that the action is not needed.
Expand Down
Loading