Skip to content

Commit

Permalink
FIX Use canDelete, not the now-deleted canArchive
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Aug 13, 2024
1 parent 1bf5db0 commit cf4a6a8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion code/Controller/AssetAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +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')) ? $file->canArchive() : $file->canDelete();
$object['canDelete'] = $file->canDelete();

$owner = $file->Owner();

Expand Down
2 changes: 1 addition & 1 deletion code/GraphQL/Resolvers/AssetAdminResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function resolveDeleteFiles($object, array $args, $context, Resolv
$deletedIDs = [];
$member = UserContextProvider::get($context);
foreach ($files as $file) {
if ($file->canArchive($member)) {
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

0 comments on commit cf4a6a8

Please sign in to comment.