Summary: | delete_patrons.pl crashes on debian squeeze | ||
---|---|---|---|
Product: | Koha | Reporter: | Jonathan Druart <jonathan.druart> |
Component: | Architecture, internals, and plumbing | Assignee: | Galen Charlton <gmcharlt> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | major | ||
Priority: | P5 - low | CC: | tomascohen |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
See Also: | http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=12472 | ||
GIT URL: | Change sponsored?: | --- | |
Patch complexity: | --- | Documentation contact: | |
Documentation submission: | Text to go in the release notes: | ||
Version(s) released in: | Circulation function: | ||
Bug Depends on: | 13084 | ||
Bug Blocks: | |||
Attachments: |
Simple script to reproduce the issue
Even more simplistic script |
Description
Jonathan Druart
2015-01-22 12:21:35 UTC
Created attachment 35458 [details]
Simple script to reproduce the issue
koha@test1-sandbox:~/src$ perl mysql_has_gone_away.pl
Failed to delete patron 999999999999, error handling its lists: (DBD::mysql::db do failed: MySQL server has gone away at /home/koha/src/C4/VirtualShelves.pm line 651.
) ROLLBACK
DBD::mysql::db rollback failed: MySQL server has gone away at mysql_has_gone_away.pl line 33.
$ git show b95617ec9eb62d3b4b9b2b97848b3efd7d207fb6 commit b95617ec9eb62d3b4b9b2b97848b3efd7d207fb6 Author: Kyle M Hall <kyle@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@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@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! Created attachment 35459 [details]
Even more simplistic script
Tomas, I think this is quite problematic since Koha is supposed to run on squeeze. The patch on bug 12472 fixes the problem (at least for the script I submitted). Can this be closed? Looks good yes. |