Lines 260-282
sub merge {
Link Here
|
260 |
|
260 |
|
261 |
my $results; |
261 |
my $results; |
262 |
|
262 |
|
263 |
foreach my $borrowernumber (@borrowernumbers) { |
263 |
$self->_resultset->result_source->schema->txn_do( sub { |
264 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
264 |
foreach my $borrowernumber (@borrowernumbers) { |
|
|
265 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
265 |
|
266 |
|
266 |
next unless $patron; |
267 |
next unless $patron; |
267 |
|
268 |
|
268 |
# Unbless for safety, the patron will end up being deleted |
269 |
# Unbless for safety, the patron will end up being deleted |
269 |
$results->{merged}->{$borrowernumber}->{patron} = $patron->unblessed; |
270 |
$results->{merged}->{$borrowernumber}->{patron} = $patron->unblessed; |
270 |
|
271 |
|
271 |
while (my ($r, $field) = each(%$RESULTSET_PATRON_ID_MAPPING)) { |
272 |
while (my ($r, $field) = each(%$RESULTSET_PATRON_ID_MAPPING)) { |
272 |
my $rs = $schema->resultset($r)->search({ $field => $borrowernumber} ); |
273 |
my $rs = $schema->resultset($r)->search({ $field => $borrowernumber} ); |
273 |
$results->{merged}->{ $borrowernumber }->{updated}->{$r} = $rs->count(); |
274 |
$results->{merged}->{ $borrowernumber }->{updated}->{$r} = $rs->count(); |
274 |
$rs->update( { $field => $keeper }); |
275 |
$rs->update( { $field => $keeper }); |
275 |
} |
276 |
} |
276 |
|
277 |
|
277 |
$patron->move_to_deleted(); |
278 |
$patron->move_to_deleted(); |
278 |
$patron->delete(); |
279 |
$patron->delete(); |
279 |
} |
280 |
} |
|
|
281 |
}); |
280 |
|
282 |
|
281 |
$results->{keeper} = $patron_to_keep; |
283 |
$results->{keeper} = $patron_to_keep; |
282 |
|
284 |
|