Bugzilla – Attachment 32344 Details for
Bug 13084
Prevent mixup of columns in deletedborrowers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13084: Mixup of columns in deletedborrowers (MASTER)
Bug-13084-Mixup-of-columns-in-deletedborrowers-MAS.patch (text/plain), 2.35 KB, created by
Marcel de Rooy
on 2014-10-15 14:49:48 UTC
(
hide
)
Description:
Bug 13084: Mixup of columns in deletedborrowers (MASTER)
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2014-10-15 14:49:48 UTC
Size:
2.35 KB
patch
obsolete
>From 64c47ccf9daa11e1a86cb7adc2350b3d2acbd050 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 15 Oct 2014 16:35:58 +0200 >Subject: [PATCH] Bug 13084: Mixup of columns in deletedborrowers (MASTER) >Content-Type: text/plain; charset=utf-8 > >I could reproduce this problem in 3.14.4 where I wrote the patch. >Fields shifted like branchcode moved to B_phone. >Could not reproduce it for master. >But this code change seems to improve things on master too. > >Test plan: >Edit a borrower. Fill all fields if possible. >Delete the borrower. >Check that the table deletedborrower contains the data in the correct fields. >--- > C4/Members.pm | 27 +++++++++++++++++---------- > 1 files changed, 17 insertions(+), 10 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index e3a5538..c243f69 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -1807,12 +1807,10 @@ sub GetSortDetails { > $result = &MoveMemberToDeleted($borrowernumber); > > Copy the record from borrowers to deletedborrowers table. >+The routine returns 1 for success, undef for failure. > > =cut > >-# FIXME: should do it in one SQL statement w/ subquery >-# Otherwise, we should return the @data on success >- > sub MoveMemberToDeleted { > my ($member) = shift or return; > my $dbh = C4::Context->dbh; >@@ -1821,13 +1819,22 @@ sub MoveMemberToDeleted { > WHERE borrowernumber=?|; > my $sth = $dbh->prepare($query); > $sth->execute($member); >- my @data = $sth->fetchrow_array; >- (@data) or return; # if we got a bad borrowernumber, there's nothing to insert >- $sth = >- $dbh->prepare( "INSERT INTO deletedborrowers VALUES (" >- . ( "?," x ( scalar(@data) - 1 ) ) >- . "?)" ); >- $sth->execute(@data); >+ my $data = $sth->fetchrow_hashref; >+ return if !$data; # probably bad borrowernumber >+ >+ #now construct a insert query that does not depend on the same order of >+ #columns in borrowers and deletedborrowers (see BZ 13084) >+ my $insertq = "INSERT INTO deletedborrowers ("; >+ my @values; >+ foreach my $key ( keys %$data ) { >+ $insertq.= $key.","; >+ push @values, $data->{$key}; >+ } >+ $insertq =~ s/,$//; #remove last comma >+ $insertq .= ") VALUES (" . ( "?," x ( scalar(@values) - 1 ) ) . "?)"; >+ $sth = $dbh->prepare( $insertq ); >+ $sth->execute(@values); >+ return $sth->err? undef: 1; > } > > =head2 DelMember >-- >1.7.7.6
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 13084
:
32343
|
32344
|
32378
|
32379
|
32380
|
32381
|
32394
|
32395
|
32396
|
32397
|
32490
|
32491
|
32492
|
32493
|
32494
|
32495
|
32496
|
32497
|
32500
|
32501
|
32502