Bug 16534: Block AddIssue from issuing if the return is not possible
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sun, 22 May 2016 09:01:56 +0000 (10:01 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 24 Jun 2016 11:45:01 +0000 (11:45 +0000)
To make sure the return can be done, AddIssue must not trust callers (they
should have done their job, but we are not sure) and check that the issue can
be returned before issuing to the patron.

There is no test plan here, this should not be possible from the Koha
interface.
However, looking at the code, it may be possible using SIP.

Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Circulation.pm

index cd3ac70..13caa3f 100644 (file)
@@ -1386,6 +1386,8 @@ sub AddIssue {
                        if ( $actualissue->{borrowernumber}) {
                                # This book is currently on loan, but not to the person
                                # who wants to borrow it now. mark it returned before issuing to the new borrower
+                my ( $allowed, $message ) = CanBookBeReturned( $item, C4::Context->userenv->{branch} );
+                return unless $allowed;
                                AddReturn(
                                        $item->{'barcode'},
                                        C4::Context->userenv->{'branch'}