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>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
ecfac4b43f
commit
a1f10a1900
|
|
@ -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 );
|
||||
|
|
@ -1736,7 +1737,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.
|
||||
|
|
@ -2499,7 +2507,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
|
||||
|
|
@ -3410,7 +3425,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");
|
||||
|
|
|
|||
|
|
@ -768,6 +768,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
|
||||
|
|
|
|||
|
|
@ -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 %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue