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 #1482

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
5 changes: 1 addition & 4 deletions code/Controller/AssetAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormFactory;
use SilverStripe\ORM\ArrayList;
Expand Down Expand Up @@ -1082,9 +1081,7 @@ public function getObjectFromData(File $file, $thumbnailLinks = true)
$object['filename'] = $file->Filename;
$object['url'] = $file->AbsoluteURL;
$object['canEdit'] = $file->canEdit();
$object['canDelete'] = ($file->hasMethod('canArchive'))
? Deprecation::withNoReplacement(fn() => $file->canArchive())
: $file->canDelete();
$object['canDelete'] = $file->canDelete();

$owner = $file->Owner();

Expand Down
4 changes: 1 addition & 3 deletions code/GraphQL/Resolvers/AssetAdminResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use SilverStripe\ORM\Filterable;
use SilverStripe\Versioned\Versioned;
use InvalidArgumentException;
use SilverStripe\Dev\Deprecation;

class AssetAdminResolver
{
Expand Down Expand Up @@ -127,8 +126,7 @@ public static function resolveDeleteFiles($object, array $args, $context, Resolv
$deletedIDs = [];
$member = UserContextProvider::get($context);
foreach ($files as $file) {
$canArchive = Deprecation::withNoReplacement(fn() => $file->canArchive($member));
if ($canArchive) {
if ($file->canDelete($member)) {
$file->doArchive();
$deletedIDs[] = $file->ID;
}
Expand Down
8 changes: 0 additions & 8 deletions tests/php/Controller/AssetAdminTest/FileExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ public function canDelete($member = null)
}
}

public function canArchive($member = null)
{
if ($this->owner->Name === 'disallowCanDelete.txt') {
return false;
}
return $this->owner->canDelete($member);
}


public function canCreate($member = null, $context = [])
{
Expand Down
Loading