Bugzilla – Attachment 184740 Details for
Bug 39180
Handle and report exception at checkout/checkin due to missing guarantor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[24.11] Bug 39180: Catch exception when updating patron lastseen date
2411-Bug-39180-Catch-exception-when-updating-patro.patch (text/plain), 6.42 KB, created by
Baptiste Wojtkowski (bwoj)
on 2025-07-28 12:11:08 UTC
(
hide
)
Description:
[24.11] Bug 39180: Catch exception when updating patron lastseen date
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2025-07-28 12:11:08 UTC
Size:
6.42 KB
patch
obsolete
>From 5960262aef6f1cf93e25b0fb02d5748a4e746364 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 5 May 2025 18:37:33 +0000 >Subject: [PATCH] [24.11] Bug 39180: Catch exception when updating patron > lastseen date > >This patch adds a catch during circulatoin actions and passes a message back to the caller > >For checkouts and renewals we don't have a method for passing messages so we simply catch the exception >and warn - this seems reasonable, as we have now added a warning on the patron display that they are missing >a guarantor > >To test: > 1 - Create a Child type patron with no guarantor > 2 - Create a patron in a non-child category that can_be_guarantee with no guarantor > 3 - Check out an item to each patron above > 4 - Enable system preference 'ChildNeedsGuarantor' and TrackLastPatronActivityTriggers - select all > 5 - In mysql > UPDATE borrowers SET datelastseen = '2025-01-01'; > 6 - Restart all to clear cache (so update last seen will update) > 7 - Attempt to checkout a book to either patron - 500 error > 8 - Attempt to returnt he books the patrons have checked out - 500 error > 9 - Attempt to renew their items - 500 error >10 - Apply patches, restart all >11 - Repeat checkout, renewal, checkin >12 - On checkout and renewal there should be a warning on the patron page, but actions succeed with no additional problems >13 - On return you get a warning letting you know the action succeeded but there is still a problem to resolve > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >--- > C4/Circulation.pm | 28 +++++++++++++++++-- > circ/returns.pl | 2 ++ > .../prog/en/modules/circ/returns.tt | 9 ++++++ > 3 files changed, 36 insertions(+), 3 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 04312712ff..6da74311c4 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use DateTime; > use POSIX qw( floor ); > use Encode; >+use Try::Tiny; > > use C4::Context; > use C4::Stats qw( UpdateStats ); >@@ -1735,7 +1736,14 @@ sub AddIssue { > ); > } > $issue->discard_changes; >- $patron->update_lastseen('check_out'); >+ #Update borrowers.lastseen >+ try{ >+ $patron->update_lastseen('check_out'); >+ } >+ catch { >+ my $exception = $_; >+ warn "Problem updating lastseen date for borrowernumber " . $patron->borrowernumber . ": $exception"; >+ }; > if ( $item_object->location && $item_object->location eq 'CART' > && ( !$item_object->permanent_location || $item_object->permanent_location ne 'CART' ) ) { > ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart. >@@ -2493,7 +2501,14 @@ sub AddReturn { > if C4::Context->preference("ReturnLog"); > > #Update borrowers.lastseen >- $patron->update_lastseen('check_in'); >+ try{ >+ $patron->update_lastseen('check_in'); >+ } >+ catch { >+ my $exception = $_; >+ warn "Problem updating lastseen date for borrowernumber " . $patron->borrowernumber . ": $exception"; >+ $messages->{UpdateLastSeenError} = "$exception"; >+ }; > } > > # Check if this item belongs to a biblio record that is attached to an >@@ -3404,7 +3419,14 @@ sub AddRenewal { > } > ); > #Update borrowers.lastseen >- $patron->update_lastseen('renewal'); >+ try{ >+ $patron->update_lastseen('renewal'); >+ } >+ catch { >+ my $exception = $_; >+ warn "Problem updating lastseen date for borrowernumber " . $patron->borrowernumber . ": $exception"; >+ }; >+ > > #Log the renewal > logaction("CIRCULATION", "RENEWAL", $borrowernumber, $itemnumber) if C4::Context->preference("RenewalLog"); >diff --git a/circ/returns.pl b/circ/returns.pl >index 9f2e52dab1..0afc93799c 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -766,6 +766,8 @@ foreach my $code ( keys %$messages ) { > ; > } elsif ( $code eq 'InBundle' ) { > $template->param( InBundle => $messages->{InBundle} ); >+ } elsif ( $code eq 'UpdateLastSeenError' ) { >+ $err{UpdateLastSeenError} = $messages->{UpdateLastSeenError}; > } else { > die "Unknown error code $code"; # note we need all the (empty) elsif's above, or we die. > # This forces the issue of staying in sync w/ Circulation.pm >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >index 972dc19de8..29947906d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -267,8 +267,17 @@ > <p><a href="/cgi-bin/koha/catalogue/detail.pl?type=intra&biblionumber=[% itembiblionumber | uri %]">[% item.barcode | html %]: [% title | html %]</a></p> > [% END %] > [% FOREACH errmsgloo IN errmsgloop %] >+ [% IF ( errmsgloo.UpdateLastSeenError ) %] >+ <div id="update_last_seen_error" class="alert alert-warning audio-alert-warning"> >+ <h3>Error updating patron's last seen date</h3> >+ <p>The item has been checked in, but the issue below must be corrected:</p> >+ <p>The system encountered an error when updating the patron's last seen date:</p> >+ <p>[% errmsgloo.UpdateLastSeenError | html %]</p> >+ </div> >+ [% END %] > [% IF ( errmsgloo.NotForLoanStatusUpdated ) %] > <p class="problem ret_nflupdate"> >+ > [% IF errmsgloo.NotForLoanStatusUpdated.to == 'ONLYMESSAGE' %] > [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.from ) | html %] > [% ELSE %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39180
:
181941
|
182691
|
182692
|
182693
|
183084
|
183085
|
183086
|
184632
|
184633
|
184634
|
184635
| 184740 |
184741
|
184742