From 966b92a803f79082a10a9d84553f1f0b2d868024 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Mon, 26 Jun 2017 10:25:44 +0000 Subject: [PATCH] Bug 13178: Correct Max cardnumberlength MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ($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 Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- C4/Members.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 07cb08a602..2031485629 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -896,7 +896,9 @@ database column. =cut sub get_cardnumber_length { - my ( $min, $max ) = ( 0, 32 ); # borrowers.cardnumber is a nullable varchar(20) + my $borrower = Koha::Schema->resultset('Borrower'); + my $field_size = $borrower->result_source->column_info('cardnumber')->{size}; + my ( $min, $max ) = ( 0, $field_size ); # borrowers.cardnumber is a nullable varchar(20) $min = 1 if C4::Context->preference('BorrowerMandatoryField') =~ /cardnumber/; if ( my $cardnumber_length = C4::Context->preference('CardnumberLength') ) { # Is integer and length match @@ -912,9 +914,7 @@ sub get_cardnumber_length { } } - my $borrower = Koha::Schema->resultset('Borrower'); - my $field_size = $borrower->result_source->column_info('cardnumber')->{size}; - $min = $field_size if $min > $field_size; + $min = $max if $min > $max; return ( $min, $max ); } -- 2.39.5