$ perl misc/cronjobs/delete_patrons.pl -c Failed to delete patron 42, error handling its lists: (DBD::mysql::db do failed: MySQL server has gone away at /home/koha/src/C4/VirtualShelves.pm line 651. ) $ perl -v This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi $ more /etc/debian_version 6.0.10
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.