From fe500fdf1e7db31222fd543afe8aee67b2849c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Sat, 30 Oct 2021 19:02:39 +0000 Subject: [PATCH] Bug 29380: Correct table name in joins to prevent errors The commit "Bug 29290: Rename relationships borrower => patron" (d46492ac23) renamed the relation for the borrowers table from 'borrower' to 'patron' but the joins were not updated accordingly so a few scripts got broken. To test: 1) Notice that $ perl misc/cronjobs/automatic_renewals.pl -c -s -v returns 255 error code on exit 2) Apply patch 3) Notice the automatic_renewals.pl works now and exit code is 0 4) Make sure /cgi-bin/koha/tools/batch_extend_due_dates.pl works. 5) Try to grep for 'borrower' in Koha source code and see if there are any other join done using the Koha::Checkout or Koha::Old::Checkout objects. --- circ/checkout-notes.pl | 2 +- misc/cronjobs/automatic_renewals.pl | 2 +- tools/batch_extend_due_dates.pl | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/circ/checkout-notes.pl b/circ/checkout-notes.pl index e94bea06c9..9f5e1c7bdf 100755 --- a/circ/checkout-notes.pl +++ b/circ/checkout-notes.pl @@ -56,7 +56,7 @@ if ( $action eq 'seen' ) { } } -my $notes = Koha::Checkouts->search({ 'me.note' => { '!=', undef } }, { prefetch => [ 'borrower', { item => 'biblionumber' } ] }); +my $notes = Koha::Checkouts->search({ 'me.note' => { '!=', undef } }, { prefetch => [ 'patron', { item => 'biblionumber' } ] }); $template->param( selected_count => scalar(@issue_ids), action => $action, diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index cb45e68cbd..172a8ff14a 100755 --- a/misc/cronjobs/automatic_renewals.pl +++ b/misc/cronjobs/automatic_renewals.pl @@ -132,7 +132,7 @@ $verbose = 1 unless $verbose or $confirm; print "Test run only\n" unless $confirm; print "getting auto renewals\n" if $verbose; -my $auto_renews = Koha::Checkouts->search({ auto_renew => 1, 'borrower.autorenew_checkouts' => 1 },{ join => 'borrower'}); +my $auto_renews = Koha::Checkouts->search({ auto_renew => 1, 'patron.autorenew_checkouts' => 1 },{ join => 'patron'}); print "found " . $auto_renews->count . " auto renewals\n" if $verbose; my $renew_digest = {}; diff --git a/tools/batch_extend_due_dates.pl b/tools/batch_extend_due_dates.pl index 77c80237ab..1ce79eeb68 100755 --- a/tools/batch_extend_due_dates.pl +++ b/tools/batch_extend_due_dates.pl @@ -59,7 +59,7 @@ elsif ( $op eq 'list' ) { my $dtf = Koha::Database->new->schema->storage->datetime_parser; my $search_params; if (@categorycodes) { - $search_params->{'borrower.categorycode'} = { -in => \@categorycodes }; + $search_params->{'patron.categorycode'} = { -in => \@categorycodes }; } if (@branchcodes) { $search_params->{'me.branchcode'} = { -in => \@branchcodes }; @@ -98,7 +98,7 @@ elsif ( $op eq 'list' ) { my $checkouts = Koha::Checkouts->search( $search_params, { - join => [ 'item', 'borrower' ] + join => [ 'item', 'patron' ] } ); -- 2.20.1