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 553-556 sub _type { Link Here
553
    return 'BackgroundJob';
554
    return 'BackgroundJob';
554
}
555
}
555
556
557
558
=head3 after_batch_action_hooks
559
560
Helper method that takes care of calling all plugin hooks
561
562
=cut
563
564
sub after_batch_action_hooks {
565
    my ( $self, $args ) = @_;
566
    Koha::Plugins->call( 'after_batch_action', {} );
567
}
568
569
=head3 before_batch_action_hooks
570
571
Helper method that takes care of calling all plugin hooks
572
573
=cut
574
575
sub before_batch_action_hooks {
576
    my ( $self, $args ) = @_;
577
    Koha::Plugins->call('before_batch_action', {} );
578
}
579
556
1;
580
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 85-90 sub process { Link Here
85
    my $delete_biblios       = $args->{delete_biblios};
85
    my $delete_biblios       = $args->{delete_biblios};
86
    my $delete_serial_issues = $args->{delete_serial_issues};
86
    my $delete_serial_issues = $args->{delete_serial_issues};
87
87
88
    $self->before_batch_action_hooks();
89
88
    my $report = {
90
    my $report = {
89
        total_records => scalar @record_ids,
91
        total_records => scalar @record_ids,
90
        total_success => 0,
92
        total_success => 0,
Lines 206-211 sub process { Link Here
206
    $data->{report}   = $report;
208
    $data->{report}   = $report;
207
209
208
    $self->finish($data);
210
    $self->finish($data);
211
    $self->after_batch_action_hooks();
209
}
212
}
210
213
211
=head3 enqueue
214
=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
    my $data = $self->decoded_data;
127
    my $data = $self->decoded_data;
126
    $data->{report} = $report;
128
    $data->{report} = $report;
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 408-413 if ( $op eq "cud-additem" ) { Link Here
408
        my $testbarcode;
409
        my $testbarcode;
409
        my $barcodeobj = C4::Barcodes->new;
410
        my $barcodeobj = C4::Barcodes->new;
410
        $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
411
        $testbarcode = $barcodeobj->next_value($oldbarcode) if $barcodeobj;
412
        Koha::BackgroundJob->before_batch_action_hooks();
411
        if ( $oldbarcode && !$testbarcode ) {
413
        if ( $oldbarcode && !$testbarcode ) {
412
414
413
            push @errors, "no_next_barcode";
415
            push @errors, "no_next_barcode";
Lines 485-490 if ( $op eq "cud-additem" ) { Link Here
485
487
486
            undef($current_item);
488
            undef($current_item);
487
        }
489
        }
490
        Koha::BackgroundJob->after_batch_action_hooks();
488
    }
491
    }
489
    if ( $frameworkcode eq 'FA' && $fa_circborrowernumber ) {
492
    if ( $frameworkcode eq 'FA' && $fa_circborrowernumber ) {
490
        print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?'
493
        print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?'
Lines 548-557 if ( $op eq "cud-additem" ) { Link Here
548
551
549
    #-------------------------------------------------------------------------------
552
    #-------------------------------------------------------------------------------
550
    my $items = Koha::Items->search( { biblionumber => $biblionumber } );
553
    my $items = Koha::Items->search( { biblionumber => $biblionumber } );
554
    Koha::BackgroundJob->before_batch_action_hooks();
551
    while ( my $item = $items->next ) {
555
    while ( my $item = $items->next ) {
552
        my $deleted = $item->safe_delete( { skip_record_index => 1 } );
556
        my $deleted = $item->safe_delete( { skip_record_index => 1 } );
553
        push @errors, @{ $deleted->messages }[0]->message unless $deleted;
557
        push @errors, @{ $deleted->messages }[0]->message unless $deleted;
554
    }
558
    }
559
    Koha::BackgroundJob->after_batch_action_hooks();
555
    my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
560
    my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
556
    $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
561
    $indexer->index_records( $biblionumber, "specialUpdate", "biblioserver" );
557
    if (@errors) {
562
    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