Non-numeric cardnumbers screw up autoMemberNum. Even though autoMemberNum assumes a library is using numeric cardnumbers, it shouldn't go haywire if one ends up in the database. A simple fix is to select only on numeric cardnumbers only when getting the 'max' current cardnumber.
Created attachment 11217 [details] [review] Bug 8533 - Non-numeric cardnumbers screw up autoMemberNum
Test Plan: 1) Enable autoMemberNum 2) Check the value of the automatically generated cardnumber in memberentry.pl 3) Create a borrower with a cardnumber such as 'P13000' 4) Repeat step 2, your next automatic cardnumber should be way out of order. 5) Apply patch 6) Check the value of the automatic cardnumber in memberentry.pl, it should now be a sane value.
Created attachment 11221 [details] [review] Bug 8533 - Non-numeric cardnumbers screw up autoMemberNum
Hi Kyle, I can't reproduce the issue without your patch. I am under the impression, your patch is useless: mysql> SELECT CAST( "P13000" AS SIGNED ); +----------------------------+ | CAST( "P13000" AS SIGNED ) | +----------------------------+ | 0 | +----------------------------+ Indeed, a non-numeric cast as SIGNED is equal to 0 Maybe I missed something ?
However, mysql raises a warning with the previous query: | Warning | 1292 | Truncated incorrect INTEGER value: 'P13000' | Which it does not exist with your patch. Then I will sign off your patch :)
Created attachment 11249 [details] [review] Bug 8533 - Non-numeric cardnumbers screw up autoMemberNum Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> Removes a warning from mysql: Truncated incorrect INTEGER value: 'P13000'
(In reply to comment #6) > Created attachment 11249 [details] [review] > Bug 8533 - Non-numeric cardnumbers screw up autoMemberNum > > Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > Removes a warning from mysql: > Truncated incorrect INTEGER value: 'P13000' patch looks good, passing QA - nice regex Kyle! :) mason@xen1:~/git/head$ koha-qa.pl * 38c7808 Bug 8533 - Non-numeric cardnumbers screw up autoMemberNum C4/Members.pm - perlcritic-progressive tests... OK - perl -c syntax tests... OK - xt/tt_valid.t tests... OK - xt/author/valid-template.t tests... OK
Patch pushed. Please not that the query will be long to execute on a large borrowers table, as it's not well optimized by the SQL parser. (But that was already the case before your patch)
Pushed to 3.8.x will be in 3.8.5