View | Details | Raw Unified | Return to bug 29346
Collapse All | Expand All

(-)a/C4/Biblio.pm (-1 / +15 lines)
Lines 106-111 use Koha::Logger; Link Here
106
use Koha::Caches;
106
use Koha::Caches;
107
use Koha::Authority::Types;
107
use Koha::Authority::Types;
108
use Koha::Acquisition::Currencies;
108
use Koha::Acquisition::Currencies;
109
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
109
use Koha::Biblio::Metadatas;
110
use Koha::Biblio::Metadatas;
110
use Koha::Holds;
111
use Koha::Holds;
111
use Koha::ItemTypes;
112
use Koha::ItemTypes;
Lines 428-433 sub ModBiblio { Link Here
428
        C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
429
        C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
429
    }
430
    }
430
431
432
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
433
        {
434
            biblio_ids => [ $biblionumber ]
435
        }
436
    );
437
431
    return 1;
438
    return 1;
432
}
439
}
433
440
Lines 490-496 sub DelBiblio { Link Here
490
    # We delete any existing holds
497
    # We delete any existing holds
491
    my $holds = $biblio->holds;
498
    my $holds = $biblio->holds;
492
    while ( my $hold = $holds->next ) {
499
    while ( my $hold = $holds->next ) {
493
        $hold->cancel;
500
        # no need to update the holds queue on each step, we'll do it at the end
501
        $hold->cancel({ skip_holds_queue => 1 });
494
    }
502
    }
495
503
496
    unless ( $params->{skip_record_index} ){
504
    unless ( $params->{skip_record_index} ){
Lines 519-524 sub DelBiblio { Link Here
519
527
520
    logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
528
    logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog");
521
529
530
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
531
        {
532
            biblio_ids => [ $biblionumber ]
533
        }
534
    );
535
522
    return;
536
    return;
523
}
537
}
524
538
(-)a/t/db_dependent/Biblio.t (-2 / +44 lines)
Lines 251-256 sub run_tests { Link Here
251
    # roll back ES index changes.
251
    # roll back ES index changes.
252
    t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
252
    t::lib::Mocks::mock_preference('SearchEngine', 'Zebra');
253
253
254
    my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
255
    $bgj_mock->mock( 'enqueue', undef );
256
254
    my $isbn = '0590353403';
257
    my $isbn = '0590353403';
255
    my $title = 'Foundation';
258
    my $title = 'Foundation';
256
    my $subtitle1 = 'Research';
259
    my $subtitle1 = 'Research';
Lines 636-641 subtest 'IsMarcStructureInternal' => sub { Link Here
636
subtest 'deletedbiblio_metadata' => sub {
639
subtest 'deletedbiblio_metadata' => sub {
637
    plan tests => 2;
640
    plan tests => 2;
638
641
642
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
643
    $mock->mock( 'enqueue', undef );
644
639
    my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
645
    my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
640
    my $biblio_metadata = C4::Biblio::GetXmlBiblio( $biblionumber );
646
    my $biblio_metadata = C4::Biblio::GetXmlBiblio( $biblionumber );
641
    C4::Biblio::DelBiblio( $biblionumber );
647
    C4::Biblio::DelBiblio( $biblionumber );
Lines 646-652 subtest 'deletedbiblio_metadata' => sub { Link Here
646
};
652
};
647
653
648
subtest 'DelBiblio' => sub {
654
subtest 'DelBiblio' => sub {
649
    plan tests => 5;
655
656
    plan tests => 6;
657
658
    my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
659
    $mock->mock( 'enqueue', undef );
650
660
651
    my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
661
    my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
652
    my $deleted = C4::Biblio::DelBiblio( $biblionumber );
662
    my $deleted = C4::Biblio::DelBiblio( $biblionumber );
Lines 684-689 subtest 'DelBiblio' => sub { Link Here
684
    is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' );
694
    is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' );
685
    is( $serial->get_from_storage, undef, 'serial should be deleted on biblio deletion' );
695
    is( $serial->get_from_storage, undef, 'serial should be deleted on biblio deletion' );
686
    is( $subscription_history->get_from_storage, undef, 'subscription history should be deleted on biblio deletion' );
696
    is( $subscription_history->get_from_storage, undef, 'subscription history should be deleted on biblio deletion' );
697
698
    subtest 'holds_queue update tests' => sub {
699
700
        plan tests => 1;
701
702
        $schema->storage->txn_begin;
703
704
        my $biblio = $builder->build_sample_biblio;
705
706
        my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue');
707
        $mock->mock( 'enqueue', sub {
708
            my ( $self, $args ) = @_;
709
            is_deeply(
710
                $args->{biblio_ids},
711
                [ $biblio->id ],
712
                '->cancel triggers a holds queue update for the related biblio'
713
            );
714
        } );
715
716
        # add a hold
717
        $builder->build_object(
718
            {
719
                class => 'Koha::Holds',
720
                value => {
721
                    biblionumber   => $biblio->id,
722
                }
723
            }
724
        );
725
726
        C4::Biblio::DelBiblio( $biblio->id );
727
728
        $schema->storage->txn_rollback;
729
    };
687
};
730
};
688
731
689
subtest 'MarcFieldForCreatorAndModifier' => sub {
732
subtest 'MarcFieldForCreatorAndModifier' => sub {
690
- 

Return to bug 29346