Bug 27808: Refresh the item object when AddReturn is called
This patch changes the original implementation so the item object is refreshed altogether instead of explicitly pinpointing a specific field we identified an edge case can leave out from ->store. I propose this alterate implementation because what this bug highlights is the fact we don't code thinking calls to things can have side-effects (like this case, with AddReturn updating the onloan status (and maybe other things?). To test: 1. Make sure circ tests pass with and without this patch Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> (cherry picked from commit26b57ad5d2) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit52babece97) Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
parent
f9d204bd18
commit
e22376c7e9
|
|
@ -1376,6 +1376,8 @@ sub AddIssue {
|
|||
my ( $allowed, $message ) = CanBookBeReturned( $item_unblessed, C4::Context->userenv->{branch} );
|
||||
return unless $allowed;
|
||||
AddReturn( $item_object->barcode, C4::Context->userenv->{'branch'} );
|
||||
# AddReturn certainly has side-effects, like onloan => undef
|
||||
$item_object->discard_changes;
|
||||
}
|
||||
|
||||
C4::Reserves::MoveReserve( $item_object->itemnumber, $borrower->{'borrowernumber'}, $cancelreserve );
|
||||
|
|
@ -1463,7 +1465,6 @@ sub AddIssue {
|
|||
$item_object->holdingbranch(C4::Context->userenv->{'branch'});
|
||||
$item_object->itemlost(0);
|
||||
$item_object->onloan($datedue->ymd());
|
||||
$item_object->make_column_dirty('onloan'); # Force write onloan so we don't need to fetch from db
|
||||
$item_object->datelastborrowed( dt_from_string()->ymd() );
|
||||
$item_object->datelastseen( dt_from_string()->ymd() );
|
||||
$item_object->store({log_action => 0});
|
||||
|
|
|
|||
Loading…
Reference in New Issue