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

(-)a/C4/ImportBatch.pm (+3 lines)
Lines 36-41 use C4::AuthoritiesMarc Link Here
36
    qw( AddAuthority GuessAuthTypeCode GetAuthorityXML ModAuthority DelAuthority GetAuthorizedHeading );
36
    qw( AddAuthority GuessAuthTypeCode GetAuthorityXML ModAuthority DelAuthority GetAuthorizedHeading );
37
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate );
37
use C4::MarcModificationTemplates qw( ModifyRecordWithTemplate );
38
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
38
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
39
use Koha::BackgroundJob;
39
use Koha::Items;
40
use Koha::Items;
40
use Koha::SearchEngine;
41
use Koha::SearchEngine;
41
use Koha::SearchEngine::Indexer;
42
use Koha::SearchEngine::Indexer;
Lines 566-571 sub BatchCommitRecords { Link Here
566
                             LEFT JOIN import_biblios ON (import_records.import_record_id=import_biblios.import_record_id)
567
                             LEFT JOIN import_biblios ON (import_records.import_record_id=import_biblios.import_record_id)
567
                             WHERE import_batch_id = ?"
568
                             WHERE import_batch_id = ?"
568
    );
569
    );
570
    Koha::BackgroundJob->before_batch_action_hooks();
569
    $sth->execute($batch_id);
571
    $sth->execute($batch_id);
570
    my $marcflavour = C4::Context->preference('marcflavour');
572
    my $marcflavour = C4::Context->preference('marcflavour');
571
573
Lines 737-742 sub BatchCommitRecords { Link Here
737
    }
739
    }
738
740
739
    $sth->finish();
741
    $sth->finish();
742
    Koha::BackgroundJob->after_batch_action_hooks();
740
743
741
    SetImportBatchStatus( $batch_id, 'imported' );
744
    SetImportBatchStatus( $batch_id, 'imported' );
742
745
(-)a/Koha/BackgroundJob.pm (+24 lines)
Lines 29-34 use Koha::Exceptions::BackgroundJob; Link Here
29
use Koha::Plugins;
29
use Koha::Plugins;
30
30
31
use base qw( Koha::Object );
31
use base qw( Koha::Object );
32
use Koha::Plugins;
32
33
33
=head1 NAME
34
=head1 NAME
34
35
Lines 543-546 sub _type { Link Here
543
    return 'BackgroundJob';
544
    return 'BackgroundJob';
544
}
545
}
545
546
547
548
=head3 after_batch_action_hooks
549
550
Helper method that takes care of calling all plugin hooks
551
552
=cut
553
554
sub after_batch_action_hooks {
555
    my ( $self, $args ) = @_;
556
    Koha::Plugins->call( 'after_batch_action', {} );
557
}
558
559
=head3 before_batch_action_hooks
560
561
Helper method that takes care of calling all plugin hooks
562
563
=cut
564
565
sub before_batch_action_hooks {
566
    my ( $self, $args ) = @_;
567
    Koha::Plugins->call('before_batch_action', {} );
568
}
569
546
1;
570
1;
(-)a/Koha/BackgroundJob/BatchDeleteAuthority.pm (+3 lines)
Lines 28-33 sub process { Link Here
28
    my $mmtid      = $args->{mmtid};
28
    my $mmtid      = $args->{mmtid};
29
    my @record_ids = @{ $args->{record_ids} };
29
    my @record_ids = @{ $args->{record_ids} };
30
30
31
    $self->before_batch_action_hooks();
32
31
    my $report = {
33
    my $report = {
32
        total_records => scalar @record_ids,
34
        total_records => scalar @record_ids,
33
        total_success => 0,
35
        total_success => 0,
Lines 79-84 RECORD_IDS: for my $record_id ( sort { $a <=> $b } @record_ids ) { Link Here
79
    $data->{report}   = $report;
81
    $data->{report}   = $report;
80
82
81
    $self->finish($data);
83
    $self->finish($data);
84
    $self->after_batch_action_hooks();
82
}
85
}
83
86
84
sub enqueue {
87
sub enqueue {
(-)a/Koha/BackgroundJob/BatchDeleteBiblio.pm (+3 lines)
Lines 52-57 sub process { Link Here
52
    my $mmtid      = $args->{mmtid};
52
    my $mmtid      = $args->{mmtid};
53
    my @record_ids = @{ $args->{record_ids} };
53
    my @record_ids = @{ $args->{record_ids} };
54
54
55
    $self->before_batch_action_hooks();
56
55
    my $report = {
57
    my $report = {
56
        total_records => scalar @record_ids,
58
        total_records => scalar @record_ids,
57
        total_success => 0,
59
        total_success => 0,
Lines 172-177 RECORD_IDS: for my $record_id ( sort { $a <=> $b } @record_ids ) { Link Here
172
    $data->{report}   = $report;
174
    $data->{report}   = $report;
173
175
174
    $self->finish($data);
176
    $self->finish($data);
177
    $self->after_batch_action_hooks();
175
}
178
}
176
179
177
=head3 enqueue
180
=head3 enqueue
(-)a/Koha/BackgroundJob/BatchDeleteItem.pm (+3 lines)
Lines 84-89 sub process { Link Here
84
    my @record_ids     = @{ $args->{record_ids} };
84
    my @record_ids     = @{ $args->{record_ids} };
85
    my $delete_biblios = $args->{delete_biblios};
85
    my $delete_biblios = $args->{delete_biblios};
86
86
87
    $self->before_batch_action_hooks();
88
87
    my $report = {
89
    my $report = {
88
        total_records => scalar @record_ids,
90
        total_records => scalar @record_ids,
89
        total_success => 0,
91
        total_success => 0,
Lines 200-205 sub process { Link Here
200
    $data->{report}   = $report;
202
    $data->{report}   = $report;
201
203
202
    $self->finish($data);
204
    $self->finish($data);
205
    $self->after_batch_action_hooks();
203
}
206
}
204
207
205
=head3 enqueue
208
=head3 enqueue
(-)a/Koha/BackgroundJob/BatchUpdateAuthority.pm (+3 lines)
Lines 64-69 sub process { Link Here
64
    my $mmtid      = $args->{mmtid};
64
    my $mmtid      = $args->{mmtid};
65
    my @record_ids = @{ $args->{record_ids} };
65
    my @record_ids = @{ $args->{record_ids} };
66
66
67
    $self->before_batch_action_hooks();
68
67
    my $report = {
69
    my $report = {
68
        total_records => scalar @record_ids,
70
        total_records => scalar @record_ids,
69
        total_success => 0,
71
        total_success => 0,
Lines 106-111 RECORD_IDS: for my $record_id ( sort { $a <=> $b } @record_ids ) { Link Here
106
    $data->{report}   = $report;
108
    $data->{report}   = $report;
107
109
108
    $self->finish($data);
110
    $self->finish($data);
111
    $self->after_batch_action_hooks();
109
112
110
}
113
}
111
114
(-)a/Koha/BackgroundJob/BatchUpdateBiblio.pm (+3 lines)
Lines 70-75 sub process { Link Here
70
    my $mmtid      = $args->{mmtid};
70
    my $mmtid      = $args->{mmtid};
71
    my @record_ids = @{ $args->{record_ids} };
71
    my @record_ids = @{ $args->{record_ids} };
72
72
73
    $self->before_batch_action_hooks();
74
73
    my $report = {
75
    my $report = {
74
        total_records => scalar @record_ids,
76
        total_records => scalar @record_ids,
75
        total_success => 0,
77
        total_success => 0,
Lines 133-138 RECORD_IDS: for my $biblionumber ( sort { $a <=> $b } @record_ids ) { Link Here
133
    $data->{report}   = $report;
135
    $data->{report}   = $report;
134
136
135
    $self->finish($data);
137
    $self->finish($data);
138
    $self->after_batch_action_hooks();
136
}
139
}
137
140
138
=head3 enqueue
141
=head3 enqueue
(-)a/Koha/BackgroundJob/BatchUpdateItem.pm (+3 lines)
Lines 98-103 sub process { Link Here
98
    my $exclude_from_local_holds_priority = $args->{exclude_from_local_holds_priority};
98
    my $exclude_from_local_holds_priority = $args->{exclude_from_local_holds_priority};
99
    my $mark_items_returned               = $args->{mark_items_returned};
99
    my $mark_items_returned               = $args->{mark_items_returned};
100
100
101
    $self->before_batch_action_hooks();
102
101
    my $report = {
103
    my $report = {
102
        total_records   => scalar @record_ids,
104
        total_records   => scalar @record_ids,
103
        modified_fields => 0,
105
        modified_fields => 0,
Lines 125-130 sub process { Link Here
125
    $data->{report} = $report;
127
    $data->{report} = $report;
126
128
127
    $self->finish($data);
129
    $self->finish($data);
130
    $self->after_batch_action_hooks();
128
}
131
}
129
132
130
=head3 enqueue
133
=head3 enqueue
(-)a/authorities/merge.pl (+3 lines)
Lines 27-32 use C4::Biblio qw( TransformHtmlToMarc ); Link Here
27
use Koha::Authority::MergeRequests;
27
use Koha::Authority::MergeRequests;
28
use Koha::Authority::Types;
28
use Koha::Authority::Types;
29
use Koha::MetadataRecord::Authority;
29
use Koha::MetadataRecord::Authority;
30
use Koha::BackgroundJob;
30
31
31
my $input  = CGI->new;
32
my $input  = CGI->new;
32
my @authid = $input->multi_param('authid');
33
my @authid = $input->multi_param('authid');
Lines 47-52 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
47
# Merging
48
# Merging
48
#------------------------
49
#------------------------
49
if ( $op eq 'cud-merge' ) {
50
if ( $op eq 'cud-merge' ) {
51
    Koha::BackgroundJob->before_batch_action_hooks();
50
52
51
    # Creating a new record from the html code
53
    # Creating a new record from the html code
52
    my $record    = TransformHtmlToMarc( $input, 0 );
54
    my $record    = TransformHtmlToMarc( $input, 0 );
Lines 83-88 if ( $op eq 'cud-merge' ) { Link Here
83
85
84
    # Delete the other record. No need to merge.
86
    # Delete the other record. No need to merge.
85
    DelAuthority( { authid => $recordid2, skip_merge => 1 } );
87
    DelAuthority( { authid => $recordid2, skip_merge => 1 } );
88
    Koha::BackgroundJob->after_batch_action_hooks();
86
89
87
    # Parameters
90
    # Parameters
88
    $template->param(
91
    $template->param(
(-)a/cataloguing/additem.pl (+5 lines)
Lines 42-47 use Koha::Patrons; Link Here
42
use Koha::SearchEngine::Indexer;
42
use Koha::SearchEngine::Indexer;
43
use Koha::UI::Form::Builder::Item;
43
use Koha::UI::Form::Builder::Item;
44
use Koha::Result::Boolean;
44
use Koha::Result::Boolean;
45
use Koha::BackgroundJob;
45
46
46
use Encode          qw( encode_utf8 );
47
use Encode          qw( encode_utf8 );
47
use List::MoreUtils qw( any uniq );
48
use List::MoreUtils qw( any uniq );
Lines 407-412 if ( $op eq "cud-additem" ) { Link Here
407
        my $testbarcode;
408
        my $testbarcode;
408
        my $barcodeobj = C4::Barcodes->new;
409
        my $barcodeobj = C4::Barcodes->new;
409
        $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
410
        $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
411
        Koha::BackgroundJob->before_batch_action_hooks();
410
        if ( $oldbarcode && !$testbarcode ) {
412
        if ( $oldbarcode && !$testbarcode ) {
411
413
412
            push @errors, "no_next_barcode";
414
            push @errors, "no_next_barcode";
Lines 484-489 if ( $op eq "cud-additem" ) { Link Here
484
486
485
            undef($current_item);
487
            undef($current_item);
486
        }
488
        }
489
        Koha::BackgroundJob->after_batch_action_hooks();
487
    }
490
    }
488
    if ( $frameworkcode eq 'FA' && $fa_circborrowernumber ) {
491
    if ( $frameworkcode eq 'FA' && $fa_circborrowernumber ) {
489
        print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?'
492
        print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?'
Lines 546-555 if ( $op eq "cud-additem" ) { Link Here
546
549
547
    #-------------------------------------------------------------------------------
550
    #-------------------------------------------------------------------------------
548
    my $items = Koha::Items->search( { biblionumber => $biblionumber } );
551
    my $items = Koha::Items->search( { biblionumber => $biblionumber } );
552
    Koha::BackgroundJob->before_batch_action_hooks();
549
    while ( my $item = $items->next ) {
553
    while ( my $item = $items->next ) {
550
        my $deleted = $item->safe_delete( { skip_record_index => 1 } );
554
        my $deleted = $item->safe_delete( { skip_record_index => 1 } );
551
        push @errors, @{ $deleted->messages }[0]->message unless $deleted;
555
        push @errors, @{ $deleted->messages }[0]->message unless $deleted;
552
    }
556
    }
557
    Koha::BackgroundJob->after_batch_action_hooks();
553
    my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
558
    my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
554
    $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
559
    $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
555
    if (@errors) {
560
    if (@errors) {
(-)a/misc/migration_tools/bulkmarcimport.pl (-1 / +3 lines)
Lines 42-47 use Koha::Logger; Link Here
42
use Koha::Biblios;
42
use Koha::Biblios;
43
use Koha::SearchEngine;
43
use Koha::SearchEngine;
44
use Koha::SearchEngine::Search;
44
use Koha::SearchEngine::Search;
45
use Koha::BackgroundJob;
45
46
46
use open qw( :std :encoding(UTF-8) );
47
use open qw( :std :encoding(UTF-8) );
47
binmode( STDOUT, ":encoding(UTF-8)" );
48
binmode( STDOUT, ":encoding(UTF-8)" );
Lines 325-330 my $logger = Koha::Logger->get; Link Here
325
my $schema            = Koha::Database->schema;
326
my $schema            = Koha::Database->schema;
326
my $lint              = MARC::Lint->new;
327
my $lint              = MARC::Lint->new;
327
328
329
Koha::BackgroundJob->before_batch_action_hooks();
328
$schema->txn_begin;
330
$schema->txn_begin;
329
RECORD: while () {
331
RECORD: while () {
330
332
Lines 739-744 RECORD: while () { Link Here
739
if ( !$test_parameter ) {
741
if ( !$test_parameter ) {
740
    $schema->txn_commit;
742
    $schema->txn_commit;
741
}
743
}
744
Koha::BackgroundJob->after_batch_action_hooks();
742
745
743
if ($fk_off) {
746
if ($fk_off) {
744
    $dbh->do("SET FOREIGN_KEY_CHECKS = 1");
747
    $dbh->do("SET FOREIGN_KEY_CHECKS = 1");
745
- 

Return to bug 39156