From 7eb915d14d3ba5718bf7109ace1cae5445e16b05 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:30:56 +1200 Subject: [PATCH] FIX Use canDelete, not the now-deleted canArchive (#1482) --- code/Controller/AssetAdmin.php | 5 +---- code/GraphQL/Resolvers/AssetAdminResolver.php | 4 +--- tests/php/Controller/AssetAdminTest/FileExtension.php | 8 -------- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/code/Controller/AssetAdmin.php b/code/Controller/AssetAdmin.php index 5ae2da7b5..5be50322f 100644 --- a/code/Controller/AssetAdmin.php +++ b/code/Controller/AssetAdmin.php @@ -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; @@ -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(); diff --git a/code/GraphQL/Resolvers/AssetAdminResolver.php b/code/GraphQL/Resolvers/AssetAdminResolver.php index 812be0569..06410f908 100644 --- a/code/GraphQL/Resolvers/AssetAdminResolver.php +++ b/code/GraphQL/Resolvers/AssetAdminResolver.php @@ -16,7 +16,6 @@ use SilverStripe\ORM\Filterable; use SilverStripe\Versioned\Versioned; use InvalidArgumentException; -use SilverStripe\Dev\Deprecation; class AssetAdminResolver { @@ -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; } diff --git a/tests/php/Controller/AssetAdminTest/FileExtension.php b/tests/php/Controller/AssetAdminTest/FileExtension.php index ae55b11b8..8727d54d0 100644 --- a/tests/php/Controller/AssetAdminTest/FileExtension.php +++ b/tests/php/Controller/AssetAdminTest/FileExtension.php @@ -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 = []) {