Bug 16187: (QA follow-up) Additional fixes
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 20 Oct 2017 06:11:38 +0000 (08:11 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 20 Oct 2017 19:51:25 +0000 (16:51 -0300)
Fix:
Can't locate object method "next" via package "13" (perhaps you forgot to load "13"?) at misc/cronjobs/holds/cancel_unfilled_holds.pl line 119.
Undefined subroutine &main::CancelReserve called at misc/cronjobs/holds/cancel_unfilled_holds.pl line 143.

The script does not use Koha::Object's get_column correctly for getting
the branch codes.
The call to CancelReserve is obsolete. Was moved in the meantime to
Koha::Hold->cancel.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
misc/cronjobs/holds/cancel_unfilled_holds.pl

index 29e7472..08c2029 100755 (executable)
@@ -112,12 +112,7 @@ warn "Running in test mode, no actions will be taken" unless ($confirm);
 
 $verbose and warn "Looking for unfilled holds placed $days or more days ago\n";
 
-unless ( scalar @branchcodes > 0 ) {
-    my $branches = Koha::Libraries->search->get_column('branchcode');
-    while ( my $branch = $branches->next ) {
-        push @branchcodes, $branch->branchcode;
-    }
-}
+@branchcodes = Koha::Libraries->search->get_column('branchcode') if !@branchcodes;
 $verbose and warn "Running for branch(es): " . join( "|", @branchcodes ) . "\n";
 
 foreach my $branch (@branchcodes) {
@@ -144,7 +139,7 @@ foreach my $branch (@branchcodes) {
               . $hold->borrowernumber
               . " on biblio: "
               . $hold->biblionumber . "\n";
-            CancelReserve( { reserve_id => $hold->reserve_id } ) if $confirm;
+            $hold->cancel if $confirm;
         }
 
     }