Bug 33885: Make Koha::Acq::Order->creator return undef if no creator
If the account of the creator of an order has been deleted we should
return undef here, instead of crashing with
GET /api/v1/acquisitions/orders: unhandled exception (Mojo::Exception)<<DBIC result _type isn't of the _type Borrower at /kohadevbox/koha/Koha/Objects.pm line 445.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 1c3a35418e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
67dfa18089
commit
fdc345dd9c
|
|
@ -425,6 +425,7 @@ Retrieves patron that created this order.
|
|||
sub creator {
|
||||
my ( $self ) = @_;
|
||||
my $creator_rs = $self->_result->creator;
|
||||
return unless $creator_rs;
|
||||
return Koha::Patron->_new_from_dbic( $creator_rs );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ subtest 'filter_by_current & filter_by_cancelled' => sub {
|
|||
};
|
||||
|
||||
subtest 'creator ()' => sub {
|
||||
plan tests => 1;
|
||||
plan tests => 2;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -650,6 +650,10 @@ subtest 'creator ()' => sub {
|
|||
|
||||
is($creator->borrowernumber, $patron->borrowernumber, 'Patron is order creator');
|
||||
|
||||
$creator->delete;
|
||||
|
||||
is( $order->get_from_storage->creator, undef );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue