@@ -, +, @@ $ ktd --shell k$ updatedatabase k$ qa --run-tests --- C4/Biblio.pm | 2 ++ t/db_dependent/Biblio.t | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -523,6 +523,8 @@ sub DelBiblio { # We update any existing orders my $orders = $biblio->orders; $orders->update({ deleted_biblionumber => $biblionumber}, { no_triggers => 1 }); + # Update related ILL requests + $biblio->ill_requests->update({ deleted_biblio_id => $biblio->id, biblio_id => undef }); unless ( $params->{skip_record_index} ){ my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); --- a/t/db_dependent/Biblio.t +++ a/t/db_dependent/Biblio.t @@ -670,7 +670,7 @@ subtest 'deletedbiblio_metadata' => sub { subtest 'DelBiblio' => sub { - plan tests => 6; + plan tests => 10; t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 ); @@ -716,11 +716,22 @@ subtest 'DelBiblio' => sub { my $order = $builder->build_object( { class => 'Koha::Acquisition::Orders', value => $orderinfo } ); + # Add some ILL requests + my $ill_req_1 = $builder->build_object({ class => 'Koha::Illrequests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } }); + my $ill_req_2 = $builder->build_object({ class => 'Koha::Illrequests', value => { biblio_id => $biblio->id, deleted_biblio_id => undef } }); + C4::Biblio::DelBiblio($biblio->biblionumber); # Or $biblio->delete is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' ); is( $serial->get_from_storage, undef, 'serial should be deleted on biblio deletion' ); is( $subscription_history->get_from_storage, undef, 'subscription history should be deleted on biblio deletion' ); is( $order->get_from_storage->deleted_biblionumber, $biblio->biblionumber, 'biblionumber of order has been moved to deleted_biblionumber column' ); + + $ill_req_1 = $ill_req_1->get_from_storage; + $ill_req_2 = $ill_req_2->get_from_storage; + is( $ill_req_1->biblio_id, undef, 'biblio_id cleared on biblio deletion' ); + is( $ill_req_1->deleted_biblio_id, $biblio->id, 'biblio_id is kept on the deleted_biblio_id column' ); + is( $ill_req_2->biblio_id, undef, 'biblio_id cleared on biblio deletion' ); + is( $ill_req_2->deleted_biblio_id, $biblio->id, 'biblio_id is kept on the deleted_biblio_id column' ); }; subtest 'MarcFieldForCreatorAndModifier' => sub { --