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

(-)a/tools/batch_delete_records.pl (-12 / +10 lines)
Lines 29-35 use C4::AuthoritiesMarc; Link Here
29
use C4::Biblio;
29
use C4::Biblio;
30
30
31
my $input = new CGI;
31
my $input = new CGI;
32
my $dbh = C4::Context->dbh;
33
my $op = $input->param('op') // q|form|;
32
my $op = $input->param('op') // q|form|;
34
my $recordtype = $input->param('recordtype') // 'biblio';
33
my $recordtype = $input->param('recordtype') // 'biblio';
35
34
Lines 110-118 if ( $op eq 'form' ) { Link Here
110
} elsif ( $op eq 'delete' ) {
109
} elsif ( $op eq 'delete' ) {
111
    # We want to delete selected records!
110
    # We want to delete selected records!
112
    my @record_ids = $input->multi_param('record_id');
111
    my @record_ids = $input->multi_param('record_id');
113
    my $dbh = C4::Context->dbh;
112
    my $schema = Koha::Database->new->schema;
114
    $dbh->{AutoCommit} = 0;
115
    $dbh->{RaiseError} = 1;
116
113
117
    my $error;
114
    my $error;
118
    my $report = {
115
    my $report = {
Lines 122-127 if ( $op eq 'form' ) { Link Here
122
    RECORD_IDS: for my $record_id ( sort { $a <=> $b } @record_ids ) {
119
    RECORD_IDS: for my $record_id ( sort { $a <=> $b } @record_ids ) {
123
        $report->{total_records}++;
120
        $report->{total_records}++;
124
        next unless $record_id;
121
        next unless $record_id;
122
        $schema->storage->txn_begin;
123
125
        if ( $recordtype eq 'biblio' ) {
124
        if ( $recordtype eq 'biblio' ) {
126
            # Biblios
125
            # Biblios
127
            my $biblionumber = $record_id;
126
            my $biblionumber = $record_id;
Lines 133-139 if ( $op eq 'form' ) { Link Here
133
                    code => 'item_issued',
132
                    code => 'item_issued',
134
                    biblionumber => $biblionumber,
133
                    biblionumber => $biblionumber,
135
                };
134
                };
136
                $dbh->rollback;
135
                $schema->storage->txn_rollback;
137
                next;
136
                next;
138
            }
137
            }
139
138
Lines 151-157 if ( $op eq 'form' ) { Link Here
151
                        reserve_id => $reserve->{reserve_id},
150
                        reserve_id => $reserve->{reserve_id},
152
                        error => $@,
151
                        error => $@,
153
                    };
152
                    };
154
                    $dbh->rollback;
153
                    $schema->storage->txn_rollback;
155
                    next RECORD_IDS;
154
                    next RECORD_IDS;
156
                }
155
                }
157
            }
156
            }
Lines 168-174 if ( $op eq 'form' ) { Link Here
168
                        itemnumber => $itemnumber,
167
                        itemnumber => $itemnumber,
169
                        error => ($@ ? $@ : $error),
168
                        error => ($@ ? $@ : $error),
170
                    };
169
                    };
171
                    $dbh->rollback;
170
                    $schema->storage->txn_rollback;
172
                    next RECORD_IDS;
171
                    next RECORD_IDS;
173
                }
172
                }
174
            }
173
            }
Lines 184-190 if ( $op eq 'form' ) { Link Here
184
                    biblionumber => $biblionumber,
183
                    biblionumber => $biblionumber,
185
                    error => ($@ ? $@ : $error),
184
                    error => ($@ ? $@ : $error),
186
                };
185
                };
187
                $dbh->rollback;
186
                $schema->storage->txn_rollback;
188
                next;
187
                next;
189
            }
188
            }
190
189
Lines 194-200 if ( $op eq 'form' ) { Link Here
194
                biblionumber => $biblionumber,
193
                biblionumber => $biblionumber,
195
            };
194
            };
196
            $report->{total_success}++;
195
            $report->{total_success}++;
197
            $dbh->commit;
196
            $schema->storage->txn_commit;
198
        } else {
197
        } else {
199
            # Authorities
198
            # Authorities
200
            my $authid = $record_id;
199
            my $authid = $record_id;
Lines 206-212 if ( $op eq 'form' ) { Link Here
206
                    authid => $authid,
205
                    authid => $authid,
207
                    error => ($@ ? $@ : 0),
206
                    error => ($@ ? $@ : 0),
208
                };
207
                };
209
                $dbh->rollback;
208
                $schema->storage->txn_rollback;
210
                next;
209
                next;
211
            } else {
210
            } else {
212
                push @messages, {
211
                push @messages, {
Lines 215-221 if ( $op eq 'form' ) { Link Here
215
                    authid => $authid,
214
                    authid => $authid,
216
                };
215
                };
217
                $report->{total_success}++;
216
                $report->{total_success}++;
218
                $dbh->commit;
217
                $schema->storage->txn_commit;
219
            }
218
            }
220
        }
219
        }
221
    }
220
    }
222
- 

Return to bug 18329