From 8283b3b33efa2f782cfee0e68e0b247ea4ae6272 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 18 May 2022 18:04:09 -1000 Subject: [PATCH] Bug 30725: Rename BatchDeleteItem job param from record_ids to item_ids It is clearly a copy and paste error, but the parameter is called 'record_ids' when it should be 'item_ids'. Test plan : Run prove t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t Perform a batch items deletion via staff interface Signed-off-by: David Nind --- Koha/BackgroundJob/BatchDeleteItem.pm | 20 +++++++++---------- .../Koha/BackgroundJobs/BatchDeleteItem.t | 8 ++++---- tools/batchMod.pl | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Koha/BackgroundJob/BatchDeleteItem.pm b/Koha/BackgroundJob/BatchDeleteItem.pm index 57371289a9..4d902d2a6a 100644 --- a/Koha/BackgroundJob/BatchDeleteItem.pm +++ b/Koha/BackgroundJob/BatchDeleteItem.pm @@ -49,7 +49,7 @@ sub job_type { Koha::BackgroundJobs->find($id)->process( { - record_ids => \@itemnumbers, + item_ids => \@itemnumbers, deleted_biblios => 0|1, } ); @@ -85,11 +85,11 @@ sub process { $self->started_on(dt_from_string)->progress($job_progress) ->status('started')->store; - my @record_ids = @{ $args->{record_ids} }; + my @item_ids = @{ $args->{item_ids} }; my $delete_biblios = $args->{delete_biblios}; my $report = { - total_records => scalar @record_ids, + total_records => scalar @item_ids, total_success => 0, }; my @messages; @@ -102,11 +102,11 @@ sub process { $schema->txn_do( sub { my (@biblionumbers); - for my $record_id ( sort { $a <=> $b } @record_ids ) { + for my $item_id ( sort { $a <=> $b } @item_ids ) { last if $self->get_from_storage->status eq 'cancelled'; - my $item = Koha::Items->find($record_id) || next; + my $item = Koha::Items->find($item_id) || next; my $return = $item->safe_delete({ skip_record_index => 1, skip_holds_queue => 1 }); unless ( $return ) { @@ -212,7 +212,7 @@ sub process { Koha::BackgroundJob::BatchDeleteItem->new->enqueue( { - record_ids => \@itemnumbers, + item_ids => \@itemnumbers, deleted_biblios => 0|1, } ); @@ -225,16 +225,16 @@ sub enqueue { my ( $self, $args ) = @_; # TODO Raise exception instead - return unless exists $args->{record_ids}; + return unless exists $args->{item_ids}; - my @record_ids = @{ $args->{record_ids} }; + my @item_ids = @{ $args->{item_ids} }; my $delete_biblios = $args->{delete_biblios} || 0; $self->SUPER::enqueue( { - job_size => scalar @record_ids, + job_size => scalar @item_ids, job_args => { - record_ids => \@record_ids, + item_ids => \@item_ids, delete_biblios => $delete_biblios, }, queue => 'long_tasks', diff --git a/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t b/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t index ee40088c8c..db087d6aa8 100755 --- a/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t +++ b/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t @@ -57,7 +57,7 @@ subtest "process() tests" => sub { borrowernumber => undef, type => 'batch_item_record_deletion', data => encode_json { - record_ids => [ $item_1->id, $item_2->id ], + item_ids => [ $item_1->id, $item_2->id ], delete_biblios => 1, } } @@ -65,7 +65,7 @@ subtest "process() tests" => sub { $job->process( { - record_ids => [ $item_1->id, $item_2->id ], + item_ids => [ $item_1->id, $item_2->id ], delete_biblios => 1, } ); @@ -84,7 +84,7 @@ subtest "process() tests" => sub { borrowernumber => undef, type => 'batch_item_record_deletion', data => encode_json { - record_ids => [ $item->id ], + item_ids => [ $item->id ], delete_biblios => 1, } } @@ -92,7 +92,7 @@ subtest "process() tests" => sub { $job->process( { - record_ids => [ $item->id ], + item_ids => [ $item->id ], delete_biblios => 1, } ); diff --git a/tools/batchMod.pl b/tools/batchMod.pl index e24db19104..34334e734a 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -90,7 +90,7 @@ if ( $op eq "action" ) { if ($del) { try { my $params = { - record_ids => \@itemnumbers, + item_ids => \@itemnumbers, delete_biblios => $del_records, }; my $job_id = -- 2.30.2