From 9ead06892044ef76d4a2817ed17bbff136fb6788 Mon Sep 17 00:00:00 2001 From: =?utf8?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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. Signed-off-by: David Nind Signed-off-by: Martin Renvoize Bug 29380: (follow-up) Fix renewal feature in staff interface The commit "Bug 29290: Rename relationships borrower => patron" (d46492ac23) renamed the relation for the borrowers table from 'borrower' to 'patron' but the usage in the renew.pl script was not updated. To test: 1) Try to renew a book in intranet through the renewal tab 2) Notice it gives error 3) Apply patch 4) Notice the error is now gone Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart --- circ/checkout-notes.pl | 2 +- circ/renew.pl | 2 +- misc/cronjobs/automatic_renewals.pl | 2 +- tools/batch_extend_due_dates.pl | 4 ++-- 4 files changed, 5 insertions(+), 5 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/circ/renew.pl b/circ/renew.pl index 4a0db8a114..97b6317067 100755 --- a/circ/renew.pl +++ b/circ/renew.pl @@ -63,7 +63,7 @@ if ($barcode) { if ($issue) { - $borrower = $issue->borrower(); + $borrower = $issue->patron(); if ( ( $borrower->debarred() || q{} ) lt dt_from_string()->ymd() ) { my $can_renew; diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index d972dd79d6..b21f9a42e2 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.39.5