Bugzilla – Attachment 73647 Details for
Bug 9302
Add ability to merge patron records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9302 [QA Followup]: Merge should be a transaction
Bug-9302-QA-Followup-Merge-should-be-a-transaction.patch (text/plain), 2.01 KB, created by
Kyle M Hall (khall)
on 2018-04-04 15:11:18 UTC
(
hide
)
Description:
Bug 9302 [QA Followup]: Merge should be a transaction
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-04-04 15:11:18 UTC
Size:
2.01 KB
patch
obsolete
>From e10c2884d76fa52f3fe3d52daaef50d4df416bf5 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 3 Apr 2018 03:51:51 +0000 >Subject: [PATCH] Bug 9302 [QA Followup]: Merge should be a transaction > >--- > Koha/Patrons.pm | 28 +++++++++++++++------------- > 1 file changed, 15 insertions(+), 13 deletions(-) > >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 1afb440e08..0ef5f4f0b9 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -260,23 +260,25 @@ sub merge { > > my $results; > >- foreach my $borrowernumber (@borrowernumbers) { >- my $patron = Koha::Patrons->find( $borrowernumber ); >+ $self->_resultset->result_source->schema->txn_do( sub { >+ foreach my $borrowernumber (@borrowernumbers) { >+ my $patron = Koha::Patrons->find( $borrowernumber ); > >- next unless $patron; >+ next unless $patron; > >- # Unbless for safety, the patron will end up being deleted >- $results->{merged}->{$borrowernumber}->{patron} = $patron->unblessed; >+ # Unbless for safety, the patron will end up being deleted >+ $results->{merged}->{$borrowernumber}->{patron} = $patron->unblessed; > >- while (my ($r, $field) = each(%$RESULTSET_PATRON_ID_MAPPING)) { >- my $rs = $schema->resultset($r)->search({ $field => $borrowernumber} ); >- $results->{merged}->{ $borrowernumber }->{updated}->{$r} = $rs->count(); >- $rs->update( { $field => $keeper }); >- } >+ while (my ($r, $field) = each(%$RESULTSET_PATRON_ID_MAPPING)) { >+ my $rs = $schema->resultset($r)->search({ $field => $borrowernumber} ); >+ $results->{merged}->{ $borrowernumber }->{updated}->{$r} = $rs->count(); >+ $rs->update( { $field => $keeper }); >+ } > >- $patron->move_to_deleted(); >- $patron->delete(); >- } >+ $patron->move_to_deleted(); >+ $patron->delete(); >+ } >+ }); > > $results->{keeper} = $patron_to_keep; > >-- >2.15.1 (Apple Git-101)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9302
:
66615
|
66617
|
68606
|
70474
|
70477
|
70478
|
70479
|
70482
|
70483
|
72082
|
72083
|
73645
|
73646
|
73647
|
73648
|
73649
|
73660
|
73661
|
73662
|
73663
|
73664
|
73668
|
73679
|
74439
|
74440
|
74441
|
74442
|
74443
|
74444
|
74445
|
74446
|
74447
|
74448
|
74449
|
74450
|
74451
|
74585
|
74653