Bug 13178 - cardnumber field length is too short
Summary: cardnumber field length is too short
Status: Pushed to Master
Alias: None
Product: Koha
Classification: Unclassified
Component: Patrons (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Baptiste
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
: 18338 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-10-31 11:24 UTC by Jeremy Evans
Modified: 2017-10-27 17:12 UTC (History)
12 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 13178: increase max value of CardnumberLength (1.87 KB, patch)
2017-06-19 15:07 UTC, Baptiste
Details | Diff | Splinter Review
Bug 13178: increase max value of CardnumberLength (1.90 KB, patch)
2017-06-21 13:20 UTC, Baptiste
Details | Diff | Splinter Review
Bug 13178: increase max value of CardnumberLength (1.98 KB, patch)
2017-06-26 10:29 UTC, Baptiste
Details | Diff | Splinter Review
Bug 13178: Correct Max cardnumberlength (1.48 KB, patch)
2017-06-26 10:29 UTC, Baptiste
Details | Diff | Splinter Review
Bug 13178: increase max value of CardnumberLength (2.11 KB, patch)
2017-06-26 12:53 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 13178: Correct Max cardnumberlength (1.61 KB, patch)
2017-06-26 12:54 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 13178: increase max value of CardnumberLength (2.16 KB, patch)
2017-10-24 15:10 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 13178: Correct Max cardnumberlength (1.67 KB, patch)
2017-10-24 15:10 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 13178: QA Followup - fix kohastructure and update info in fields (5.50 KB, patch)
2017-10-24 15:10 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 13178: increase max value of CardnumberLength (2.22 KB, patch)
2017-10-25 19:08 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 13178: Correct Max cardnumberlength (1.72 KB, patch)
2017-10-25 19:08 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 13178: QA Followup - fix kohastructure and update info in fields (5.56 KB, patch)
2017-10-25 19:08 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Evans 2014-10-31 11:24:17 UTC
The cardnumber field in the Patron record is currently limited to 16 characters.
We do not use patron cards. We prefer to use the user's email address as the card number as it is unique to that person and they can remember this. 
However the domain section of our work email for one of our sites is 14 characters before prefixing it with firstname.lastname

Therefore when saving the record this truncates after the first 16 characters. We would like the cardnumber field length to be extended, say to 40 characters
Comment 1 Owen Leonard 2014-10-31 12:02:57 UTC
I'm sure there's not any problem with making the field longer (other than finding someone to do the work), but I'm wondering why you don't enter the patron's email address as their username and have Koha auto-generate card numbers? That way Koha handles the card numbers without you having to think about it, and the user can log in to their account using their email address.
Comment 2 Jeremy Evans 2014-10-31 14:10:19 UTC
Owen,

Thanks for your quick reply.
I must admit I hadn't thought of that option. I have just tried it out and I think this would actually work better as it is one less field to worry about when creating a new patron record.  We usually look up the user by surname in the staff client when checking something out.  So this bug can be closed I think.

Also related is this one which would automatically align the username login to the email address field.
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=2237

Jeremy
Comment 3 Brendon Ford 2015-08-12 00:34:34 UTC
We are also having an issue with the 16 digit character limit.

Our card readers output a trailing equals sign and then send a backspace keystroke to remove it when swiping a card. Since our card numbers are 16 digits the equals sign never gets typed into the field and the backspace removes the last digit of the card number. We can't reprogram the card readers because it would leave the equals sign in other fields that we swipe card numbers into.

We are currently using a bit of javascript to extend the maxlength, but it would be great to see the character limit extended.
Comment 4 j.kylmala 2015-08-17 06:32:40 UTC
There is CardnumberLength system preference but it doesn't change the max length of the cardnumber when trying to edit x patron's cardnumber. Does anyone know what is the purpose of this preference, does it change the cardnumber length somewhere else?
Comment 5 Baptiste 2017-06-19 15:03:21 UTC
The code specifies that if the cardnumber length from the system preference is to big, it will consider it as the biggest authorized value
Comment 6 Baptiste 2017-06-19 15:07:07 UTC
Created attachment 64428 [details] [review]
Bug 13178: increase max value of CardnumberLength

testplan
1 - Apply patch
2 - Run updatedatabase.pl
3 - set the value of CardnumberLength to a value between 16 and 20
4 - Check you can enter a propper cardnumber
Comment 7 Baptiste 2017-06-21 13:20:18 UTC
Created attachment 64487 [details] [review]
Bug 13178: increase max value of CardnumberLength

testplan
1 - Apply patch
2 - Run updatedatabase.pl
3 - set the value of CardnumberLength to a value between 16 and 20
4 - Check you can enter a propper cardnumber
(modify to 32 instead 20)
Comment 8 Marc Véron 2017-06-23 19:38:43 UTC
(In reply to Baptiste from comment #7)
> Created attachment 64487 [details] [review] [review]
> Bug 13178: increase max value of CardnumberLength
> 
> testplan
> 1 - Apply patch
> 2 - Run updatedatabase.pl
> 3 - set the value of CardnumberLength to a value between 16 and 20
> 4 - Check you can enter a propper cardnumber
> (modify to 32 instead 20)

I tested by setting CardnumberLength to 20,32
for min 20 and max 32

However in cgi-bin/koha/members/memberentry.pl I get:
"Card number must be between 16 and 32 characters."
...and I can enter an card number inside this range, e.g. a length of 18.

Expected: Correct validation (card number length between 20 and 32).
Comment 9 Baptiste 2017-06-26 10:29:00 UTC
Created attachment 64644 [details] [review]
Bug 13178: increase max value of CardnumberLength

testplan
1 - Apply patch
2 - Run updatedatabase.pl
3 - Update dbix scheme
4 - set the value of CardnumberLength to a value between 16 and 32
5 - Check you can enter a propper cardnumber
(modify to 32 instead 20)

+ max value now depends on the database field value to
Comment 10 Baptiste 2017-06-26 10:29:22 UTC
Created attachment 64645 [details] [review]
Bug 13178: Correct Max cardnumberlength

($max is the value of the max size of a card number)
- $max not hardcoded anymore in C4::Memeber
- $max now correctly adapts to the field of cardnumber in database
Comment 11 Baptiste 2017-06-26 10:39:20 UTC
@Marc Veron

Sorry I didn't write to update the DBix schema, if you do this this should correct your problem

However you discovered another bug: max size should be set to 16 in your case, because you had a wrong max value

Please apply second patch and try again ;)
To test the second patch:
-> set your syspref to (100,200) before applying patch => max shouldn't change
-> do the same after applying patch => max should change
Comment 12 Marc Véron 2017-06-26 12:52:08 UTC
Tested both patches together, will sign off.
Comment 13 Marc Véron 2017-06-26 12:53:41 UTC
Created attachment 64646 [details] [review]
Bug 13178: increase max value of CardnumberLength

testplan
1 - Apply patch
2 - Run updatedatabase.pl
3 - Update dbix scheme
4 - set the value of CardnumberLength to a value between 16 and 32
5 - Check you can enter a propper cardnumber
(modify to 32 instead 20)

+ max value now depends on the database field value to

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 14 Marc Véron 2017-06-26 12:54:40 UTC
Created attachment 64647 [details] [review]
Bug 13178: Correct Max cardnumberlength

($max is the value of the max size of a card number)
- $max not hardcoded anymore in C4::Memeber
- $max now correctly adapts to the field of cardnumber in database

Signed-off-by: Marc Véron <veron@veron.ch>
Comment 15 Jonathan Druart 2017-08-09 18:53:09 UTC
@QAer, take a look at bug 10267 as well.
Comment 16 Josef Moravec 2017-08-18 10:03:44 UTC
*** Bug 18338 has been marked as a duplicate of this bug. ***
Comment 17 Nick Clemens 2017-10-24 15:10:35 UTC
Created attachment 68473 [details] [review]
Bug 13178: increase max value of CardnumberLength

testplan
1 - Apply patch
2 - Run updatedatabase.pl
3 - Update dbix scheme
4 - set the value of CardnumberLength to a value between 16 and 32
5 - Check you can enter a propper cardnumber
(modify to 32 instead 20)

+ max value now depends on the database field value to

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 18 Nick Clemens 2017-10-24 15:10:39 UTC
Created attachment 68474 [details] [review]
Bug 13178: Correct Max cardnumberlength

($max is the value of the max size of a card number)
- $max not hardcoded anymore in C4::Memeber
- $max now correctly adapts to the field of cardnumber in database

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 19 Nick Clemens 2017-10-24 15:10:42 UTC
Created attachment 68475 [details] [review]
Bug 13178: QA Followup - fix kohastructure and update info in fields

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 20 Nick Clemens 2017-10-24 15:11:28 UTC
Looks good here, added the max length to syspref notes so want an opinion on that
Comment 21 Katrin Fischer 2017-10-25 19:08:01 UTC
Created attachment 68553 [details] [review]
Bug 13178: increase max value of CardnumberLength

testplan
1 - Apply patch
2 - Run updatedatabase.pl
3 - Update dbix scheme
4 - set the value of CardnumberLength to a value between 16 and 32
5 - Check you can enter a propper cardnumber
(modify to 32 instead 20)

+ max value now depends on the database field value to

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 22 Katrin Fischer 2017-10-25 19:08:05 UTC
Created attachment 68554 [details] [review]
Bug 13178: Correct Max cardnumberlength

($max is the value of the max size of a card number)
- $max not hardcoded anymore in C4::Memeber
- $max now correctly adapts to the field of cardnumber in database

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 23 Katrin Fischer 2017-10-25 19:08:10 UTC
Created attachment 68555 [details] [review]
Bug 13178: QA Followup - fix kohastructure and update info in fields

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 24 Katrin Fischer 2017-10-25 19:08:36 UTC
Checked Nick's follow-up and liked it :)
Comment 25 Jonathan Druart 2017-10-27 17:12:33 UTC
Pushed to master for 17.11, thanks to everybody involved!