From 13c2fcff5d7cad988079c7e8b20555bdbd0f79c7 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 14 Aug 2024 11:31:14 +1200 Subject: [PATCH] ENH Don't emit deprecation warnings for unavoidable API calls --- code/Controller/AssetAdmin.php | 5 ++++- code/GraphQL/Resolvers/AssetAdminResolver.php | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/code/Controller/AssetAdmin.php b/code/Controller/AssetAdmin.php index 14d6542ed..5ae2da7b5 100644 --- a/code/Controller/AssetAdmin.php +++ b/code/Controller/AssetAdmin.php @@ -28,6 +28,7 @@ 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; @@ -1081,7 +1082,9 @@ public function getObjectFromData(File $file, $thumbnailLinks = true) $object['filename'] = $file->Filename; $object['url'] = $file->AbsoluteURL; $object['canEdit'] = $file->canEdit(); - $object['canDelete'] = ($file->hasMethod('canArchive')) ? $file->canArchive() : $file->canDelete(); + $object['canDelete'] = ($file->hasMethod('canArchive')) + ? Deprecation::withNoReplacement(fn() => $file->canArchive()) + : $file->canDelete(); $owner = $file->Owner(); diff --git a/code/GraphQL/Resolvers/AssetAdminResolver.php b/code/GraphQL/Resolvers/AssetAdminResolver.php index 642552fbb..812be0569 100644 --- a/code/GraphQL/Resolvers/AssetAdminResolver.php +++ b/code/GraphQL/Resolvers/AssetAdminResolver.php @@ -16,6 +16,7 @@ use SilverStripe\ORM\Filterable; use SilverStripe\Versioned\Versioned; use InvalidArgumentException; +use SilverStripe\Dev\Deprecation; class AssetAdminResolver { @@ -126,7 +127,8 @@ public static function resolveDeleteFiles($object, array $args, $context, Resolv $deletedIDs = []; $member = UserContextProvider::get($context); foreach ($files as $file) { - if ($file->canArchive($member)) { + $canArchive = Deprecation::withNoReplacement(fn() => $file->canArchive($member)); + if ($canArchive) { $file->doArchive(); $deletedIDs[] = $file->ID; }