[Koha-bugs] [Bug 13610] delete_patrons.pl crashes on debian squeeze
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Thu Jan 22 13:25:37 CET 2015
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13610
Jonathan Druart <jonathan.druart at biblibre.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |13084
--- Comment #2 from Jonathan Druart <jonathan.druart at biblibre.com> ---
$ git show b95617ec9eb62d3b4b9b2b97848b3efd7d207fb6
commit b95617ec9eb62d3b4b9b2b97848b3efd7d207fb6
Author: Kyle M Hall <kyle at bywatersolutions.com>
Date: Fri Oct 17 07:52:13 2014 -0400
Bug 13084 [Master] - QA Followup - Use DBIx::Class to simplify logic
Signed-off-by: Kyle M Hall <kyle at bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen at gmail.com>
diff --git a/C4/Members.pm b/C4/Members.pm
index da8dfaf..0978078 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -1814,28 +1814,16 @@ The routine returns 1 for success, undef for failure.
sub MoveMemberToDeleted {
my ($member) = shift or return;
- my $dbh = C4::Context->dbh;
- my $query = qq|SELECT *
- FROM borrowers
- WHERE borrowernumber=?|;
- my $sth = $dbh->prepare($query);
- $sth->execute($member);
- 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;
+
+ my $schema = Koha::Database->new()->schema();
+ my $borrowers_rs = $schema->resultset('Borrower');
+ $borrowers_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
+ my $borrower = $borrowers_rs->find($member);
+ return unless $borrower;
+
+ my $deleted = $schema->resultset('Deletedborrower')->create($borrower);
+
+ return $deleted ? 1 : undef;
}
=head2 DelMember
$ git revert b95617ec9eb62d3b4b9b2b97848b3efd7d207fb6
$ perl mysql_has_gone_away.pl
No error!
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list