Bug 14067 - 500 error when deleting patrons
Summary: 500 error when deleting patrons
Status: RESOLVED DUPLICATE of bug 15517
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-27 19:13 UTC by Amy Schapiro
Modified: 2016-06-29 12:51 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
delete patron error msg screen (32.69 KB, image/png)
2015-04-27 19:13 UTC, Amy Schapiro
Details
error when deleting patron (10.08 KB, image/png)
2015-10-15 13:21 UTC, BUWM
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Amy Schapiro 2015-04-27 19:13:39 UTC
Created attachment 38571 [details]
delete patron error msg screen

Partners getting a 500 error (screenshot attached) when attempting to delete patrons.
It may be that as long as all of the required fields are filled in this error does not occur. But if any fields are missing the error is seen.
Comment 1 David Cook 2015-04-27 23:33:52 UTC
If you look in your intranet error logs, you should be able to find the root cause.

From the sound of it, I'm guessing that it's a SQL error. Worth checking to see if MySQL is in strict mode. Koha and MySQL in strict mode don't get along very well.
Comment 2 Barton Chittenden 2015-05-04 12:58:24 UTC
Here's the error as found in intranet-error.log

[Mon May 04 08:52:27 2015] [error] [client xx.xx.xx.xx] [Mon May  4 08:52:27 2015] deletemem.pl: DBD::mysql::st execute failed: Column 'cardnumber' cannot be null at /usr/local/share/perl/5.10.1/DBIx/Class/Storage/DBI.pm line 1834.
[Mon May 04 08:52:27 2015] [error] [client xx.xx.xx.xx] Premature end of script headers: deletemem.pl
Comment 3 Katrin Fischer 2015-05-04 20:41:51 UTC
Hm, is the cardnumber set for the patron they are trying to delete? The cardnumber should never be empty.
Comment 4 David Cook 2015-05-04 23:05:11 UTC
(In reply to Barton Chittenden from comment #2)
> Here's the error as found in intranet-error.log
> 
> [Mon May 04 08:52:27 2015] [error] [client xx.xx.xx.xx] [Mon May  4 08:52:27
> 2015] deletemem.pl: DBD::mysql::st execute failed: Column 'cardnumber'
> cannot be null at /usr/local/share/perl/5.10.1/DBIx/Class/Storage/DBI.pm
> line 1834.
> [Mon May 04 08:52:27 2015] [error] [client xx.xx.xx.xx] Premature end of
> script headers: deletemem.pl

That's an interesting error. When I look at my databases, 'cardnumber' is a nullable column. I'd suggest looking at Koha::Schema::Result::Borrower.pm and seeing if "cardnumber" has "is_nullable" set to 1. I'd also check the actual database to see if it's a nullable column...
Comment 5 Barton Chittenden 2015-05-11 15:48:35 UTC
(In reply to David Cook from comment #4)
> (In reply to Barton Chittenden from comment #2)
> > Here's the error as found in intranet-error.log
> > 
> > [Mon May 04 08:52:27 2015] [error] [client xx.xx.xx.xx] [Mon May  4 08:52:27
> > 2015] deletemem.pl: DBD::mysql::st execute failed: Column 'cardnumber'
> > cannot be null at /usr/local/share/perl/5.10.1/DBIx/Class/Storage/DBI.pm
> > line 1834.
> > [Mon May 04 08:52:27 2015] [error] [client xx.xx.xx.xx] Premature end of
> > script headers: deletemem.pl



> 
> That's an interesting error. When I look at my databases, 'cardnumber' is a
> nullable column. I'd suggest looking at Koha::Schema::Result::Borrower.pm
> and seeing if "cardnumber" has "is_nullable" set to 1. I'd also check the
> actual database to see if it's a nullable column...

Yes, borrowers.cardnumber is nullable in the database in question:

mysql> describe borrowers;
+---------------------+--------------+------+-----+---------+----------------+
| Field               | Type         | Null | Key | Default | Extra          |
+---------------------+--------------+------+-----+---------+----------------+
| borrowernumber      | int(11)      | NO   | PRI | NULL    | auto_increment |
| cardnumber          | varchar(16)  | YES  | UNI | NULL    |                |

and in /usr/share/koha/lib/Koha/Schema/Result/Borrower.pm

=head2 cardnumber

  data_type: 'varchar'
  is_nullable: 1
  size: 16

So... I don't know.
Comment 6 Arturo 2015-05-11 16:02:59 UTC
Our library is experiencing this bug, and to add a little more insight, even though the DB 'cardnumber' field is nullable, we've set our BorrowerMandatoryField sys pref to require a value for the 'cardnumber' field. In our case, we allow self-registrations, and during the self-registration process, a card number is not automatically generated -- we manually add that in later once we review each self-registration. So when we come across a self-registered patron during our workflow whose account we need to delete, we get this error since we are trying to delete the account and it does not have one of the required fields.

In other words, I don't think this bug involves a SQL error -- perhaps it is needlessly running a check on required fields before deleting the account?
Comment 7 David Cook 2015-05-12 01:57:19 UTC
I can't reproduce this one on 3.14.5 or master.

Barton: I'd suggest checking /usr/local/share/perl/5.10.1/DBIx/Class/Storage/DBI.pm line 1834

I use Perl 5.20.1 and that line doesn't seem relevant in my DBIx::Class::Storage::DBI.

Which version of DBIx::Class are you using?

It looks like we're using version 0.082810.
Comment 8 Kyle M Hall 2015-06-26 11:54:21 UTC
When I see this it is because the deletedborrowers table has cardnumber set to NOT NULL despite the fact that it should be NULL DEFAULT NULL.
Comment 9 BUWM 2015-10-15 13:21:12 UTC
Created attachment 43437 [details]
error when deleting patron

We also had problem with deleting patrons.
`borrowers` . `password` was VARCHAR(60), while
`deletedborrowers` . `password` was VARCHAR(30). Setting the latter to 60 resolved this issue in our case (Koha 3.20.01)
Comment 10 Jonathan Druart 2016-01-07 15:29:46 UTC
(In reply to BUWM from comment #9)
> Created attachment 43437 [details]
> error when deleting patron
> 
> We also had problem with deleting patrons.
> `borrowers` . `password` was VARCHAR(60), while
> `deletedborrowers` . `password` was VARCHAR(30). Setting the latter to 60
> resolved this issue in our case (Koha 3.20.01)

This will be fixed by bug 15517.
Comment 11 Barton Chittenden 2016-06-29 12:51:27 UTC
(In reply to Jonathan Druart from comment #10)
> (In reply to BUWM from comment #9)
> > Created attachment 43437 [details]
> > error when deleting patron
> > 
> > We also had problem with deleting patrons.
> > `borrowers` . `password` was VARCHAR(60), while
> > `deletedborrowers` . `password` was VARCHAR(30). Setting the latter to 60
> > resolved this issue in our case (Koha 3.20.01)
> 
> This will be fixed by bug 15517.

*** This bug has been marked as a duplicate of bug 15517 ***