Bugzilla – Attachment 182691 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]
Bug 39180: Catch exception when updating patron lastseen date
Bug-39180-Catch-exception-when-updating-patron-las.patch (text/plain), 5.54 KB, created by
Nick Clemens (kidclamp)
on 2025-05-21 14:28:51 UTC
(
hide
)
Description:
Bug 39180: Catch exception when updating patron lastseen date
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-05-21 14:28:51 UTC
Size:
5.54 KB
patch
obsolete
>From 99fa26bbd6b8109bd21f67d1cc005e4c81b128ea Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 5 May 2025 18:37:33 +0000 >Subject: [PATCH] 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 >--- > C4/Circulation.pm | 27 ++++++++++++++++--- > circ/returns.pl | 2 ++ > .../prog/en/modules/circ/returns.tt | 8 ++++++ > 3 files changed, 34 insertions(+), 3 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index afcec2d895e..42258f532dd 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 ); >@@ -1783,7 +1784,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' ) ) >@@ -2576,7 +2584,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 >@@ -3524,7 +3539,13 @@ 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 ) >diff --git a/circ/returns.pl b/circ/returns.pl >index 9a55093893f..70c5b02e0f9 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -743,6 +743,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 0309793b6fe..1634b826d60 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -294,6 +294,14 @@ > [% END %] > </p> > [% END %] >+ [% 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.ItemLocationUpdated ) %] > <p class="problem ret_location_update"> > Item shelving location updated. >-- >2.39.5
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