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

(-)a/tools/stage-marc-import.pl (-11 / +8 lines)
Lines 106-112 if ($completedJobID) { Link Here
106
        # BatchStageMarcRecords can handle that
106
        # BatchStageMarcRecords can handle that
107
107
108
    my $job = undef;
108
    my $job = undef;
109
    my $dbh;
110
    if ($runinbackground) {
109
    if ($runinbackground) {
111
        my $job_size = scalar(@$marcrecords);
110
        my $job_size = scalar(@$marcrecords);
112
        # if we're matching, job size is doubled
111
        # if we're matching, job size is doubled
Lines 139-147 if ($completedJobID) { Link Here
139
138
140
    }
139
    }
141
140
142
    # New handle, as we're a child.
141
    my $schema = Koha::Database->new->schema;
143
    $dbh = C4::Context->dbh({new => 1});
142
    $schema->storage->txn_begin;
144
    $dbh->{AutoCommit} = 0;
143
145
    # FIXME branch code
144
    # FIXME branch code
146
    my ( $batch_id, $num_valid, $num_items, @import_errors ) =
145
    my ( $batch_id, $num_valid, $num_items, @import_errors ) =
147
      BatchStageMarcRecords(
146
      BatchStageMarcRecords(
Lines 150-156 if ($completedJobID) { Link Here
150
        $marc_modification_template,
149
        $marc_modification_template,
151
        $comments,       '',
150
        $comments,       '',
152
        $parse_items,    0,
151
        $parse_items,    0,
153
        50, staging_progress_callback( $job, $dbh )
152
        50, staging_progress_callback( $job )
154
      );
153
      );
155
154
156
    if($profile_id) {
155
    if($profile_id) {
Lines 169-185 if ($completedJobID) { Link Here
169
            $matcher_code = $matcher->code();
168
            $matcher_code = $matcher->code();
170
            $num_with_matches =
169
            $num_with_matches =
171
              BatchFindDuplicates( $batch_id, $matcher, 10, 50,
170
              BatchFindDuplicates( $batch_id, $matcher, 10, 50,
172
                matching_progress_callback( $job, $dbh ) );
171
                matching_progress_callback($job) );
173
            SetImportBatchMatcher($batch_id, $matcher_id);
172
            SetImportBatchMatcher($batch_id, $matcher_id);
174
            SetImportBatchOverlayAction($batch_id, $overlay_action);
173
            SetImportBatchOverlayAction($batch_id, $overlay_action);
175
            SetImportBatchNoMatchAction($batch_id, $nomatch_action);
174
            SetImportBatchNoMatchAction($batch_id, $nomatch_action);
176
            SetImportBatchItemAction($batch_id, $item_action);
175
            SetImportBatchItemAction($batch_id, $item_action);
177
            $dbh->commit();
176
            $schema->storage->txn_commit;
178
        } else {
177
        } else {
179
            $matcher_failed = 1;
178
            $matcher_failed = 1;
179
            $schema->storage->txn_rollback;
180
        }
180
        }
181
    } else {
181
    } else {
182
        $dbh->commit();
182
        $schema->storage->txn_commit;
183
    }
183
    }
184
184
185
    my $results = {
185
    my $results = {
Lines 239-245 exit 0; Link Here
239
239
240
sub staging_progress_callback {
240
sub staging_progress_callback {
241
    my $job = shift;
241
    my $job = shift;
242
    my $dbh = shift;
243
    return sub {
242
    return sub {
244
        my $progress = shift;
243
        my $progress = shift;
245
        $job->progress($progress);
244
        $job->progress($progress);
Lines 248-254 sub staging_progress_callback { Link Here
248
247
249
sub matching_progress_callback {
248
sub matching_progress_callback {
250
    my $job = shift;
249
    my $job = shift;
251
    my $dbh = shift;
252
    my $start_progress = $job->progress();
250
    my $start_progress = $job->progress();
253
    return sub {
251
    return sub {
254
        my $progress = shift;
252
        my $progress = shift;
255
- 

Return to bug 21818