Skip to content

Commit

Permalink
Return success when disabling a disabled record via REST 2
Browse files Browse the repository at this point in the history
RT's internal API returns "false" when you update a record
to the value it already has. This false return caused a
REST 2 DELETE (which is 'disable' on most records) to return
failure (500) if you disabled an already-disabled queue.

This commit directly return true if record is already disabled.

Fixes: I#37591
  • Loading branch information
cbrandtbuffalo authored and sunnavy committed Sep 6, 2023
1 parent 2170daf commit 089eeb3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/RT/REST2/Resource/Record/DeletableByDisabling.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ with 'RT::REST2::Resource::Record::Deletable';

sub delete_resource {
my $self = shift;

# Don't return failure if the resource is already disabled since
# the final state is correct, the resource is disabled.
return 1 if $self->record->Disabled == 1;

my ($ok, $msg) = $self->record->SetDisabled(1);
RT->Logger->debug("Failed to disable ", $self->record_class, " #", $self->record->id, ": $msg")
unless $ok;
Expand Down

0 comments on commit 089eeb3

Please sign in to comment.