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.

Directly return true if the record is already disabled.

Fixes: I#37591
  • Loading branch information
cbrandtbuffalo committed Sep 7, 2023
1 parent b9558de commit 4157646
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 4157646

Please sign in to comment.