Skip to content

Commit

Permalink
ENH Don't emit deprecation warnings for unavoidable API calls (#1483)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Aug 15, 2024
1 parent be18dbb commit ea42210
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion code/Controller/AssetAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

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

class AssetAdminResolver
{
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ea42210

Please sign in to comment.