Bug 32663

Summary: Street number should not allow for entering more than 10 characters in OPAC
Product: Koha Reporter: David Nind <david>
Component: OPACAssignee: David Cook <dcook>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P5 - low CC: arthur.suzuki, dcook, lucas, m.de.rooy, wainuiwitikapark
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.04,22.05.11,21.11.19
Attachments: Bug 32663: Limit streetnumber to 10 characters in OPAC
Bug 32663: Limit streetnumber to 10 characters in OPAC
Bug 32663: Limit streetnumber to 10 characters in OPAC
Bug 32663: Limit streetnumber to 10 characters in OPAC

Description David Nind 2023-01-17 23:51:51 UTC
When logged in to the OPAC and editing your personal details, you get an error trace if you enter a reasonable amount of text in the main address street number input field, for example: abcdefghijk.

DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Data too long for column 'streetnumber' at row 1 at /kohadevbox/koha/Koha/Object.pm line 170
 at /usr/share/perl5/DBIx/Class/Exception.pm line 77

    in DBIx::Class::Exception::throw at /usr/share/perl5/DBIx/Class/Exception.pm line 77

       74:     my $self = { msg => $msg };
       75:     bless $self => $class;
       76: 
       77:     die $self;
       78: }
       79: 
       80: =head2 rethrow

    Show function arguments

To replicate:
1. Log in to the OPAC (I used koha and koha with KTD).
2. Go to Your account > Personal details
3. Enter abcdefghijk in the Main address > Street number input field.
4. Error trace occurs.
5. Enter abcdefghij in the Main address > Street number input field.
6. Form submitted.
Comment 1 David Cook 2023-01-18 01:31:36 UTC
Created attachment 145379 [details] [review]
Bug 32663: Limit streetnumber to 10 characters in OPAC

This change harmonizes the patron streetnumber input between
the staff interface and the OPAC, so that you can only enter 10
characters into the streetnumber for the OPAC. Without this change,
a fatal error will be thrown trying to save the too long data.

Test plan:
0. Apply the patch
1. Go to http://localhost:8080/cgi-bin/koha/opac-memberentry.pl
2. Note that you can only enter 10 characters into the "Street number"
field as a self-registration patron
3. Log into Koha
4. Go to http://localhost:8080/cgi-bin/koha/opac-memberentry.pl
5. Note that you can only enter 10 characters into the "Street number"
field when editing logged in patron details too
6. Go to http://localhost:8081/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=S
7. Note that you can only enter 10 characters into the "Street number"
field as a staff member
Comment 2 David Nind 2023-01-18 04:17:33 UTC
Created attachment 145381 [details] [review]
Bug 32663: Limit streetnumber to 10 characters in OPAC

This change harmonizes the patron streetnumber input between
the staff interface and the OPAC, so that you can only enter 10
characters into the streetnumber for the OPAC. Without this change,
a fatal error will be thrown trying to save the too long data.

Test plan:
0. Apply the patch
1. Go to http://localhost:8080/cgi-bin/koha/opac-memberentry.pl
2. Note that you can only enter 10 characters into the "Street number"
field as a self-registration patron
3. Log into Koha
4. Go to http://localhost:8080/cgi-bin/koha/opac-memberentry.pl
5. Note that you can only enter 10 characters into the "Street number"
field when editing logged in patron details too
6. Go to http://localhost:8081/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=S
7. Note that you can only enter 10 characters into the "Street number"
field as a staff member

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 solene.ngamga 2023-01-31 14:36:27 UTC
Created attachment 145879 [details] [review]
Bug 32663: Limit streetnumber to 10 characters in OPAC

This change harmonizes the patron streetnumber input between
the staff interface and the OPAC, so that you can only enter 10
characters into the streetnumber for the OPAC. Without this change,
a fatal error will be thrown trying to save the too long data.

Test plan:
0. Apply the patch
1. Go to http://localhost:8080/cgi-bin/koha/opac-memberentry.pl
2. Note that you can only enter 10 characters into the "Street number"
field as a self-registration patron
3. Log into Koha
4. Go to http://localhost:8080/cgi-bin/koha/opac-memberentry.pl
5. Note that you can only enter 10 characters into the "Street number"
field when editing logged in patron details too
6. Go to http://localhost:8081/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=S
7. Note that you can only enter 10 characters into the "Street number"
field as a staff member

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>
Comment 4 Marcel de Rooy 2023-02-03 10:53:25 UTC
  `streetnumber` tinytext DEFAULT NULL COMMENT 'the house number for your patron/borrower''s primary address',

Are we going the right direction here?
Comment 5 David Cook 2023-02-05 22:13:22 UTC
(In reply to Marcel de Rooy from comment #4)
>   `streetnumber` tinytext DEFAULT NULL COMMENT 'the house number for your
> patron/borrower''s primary address',
> 
> Are we going the right direction here?

Perhaps not.

Looks like borrower_modifications is out of sync with borrowers and deletedborrowers.

Looks like many fields in borrower_modifications have the wrong type: streetnumber, streettype, zipcode, mobile, B_streetnumber, B_streettype, B_address, B_zipcode, password, altcontactfirstname, altcontactsurname, altcontactaddress1, altcontactaddress2, altcontactaddress3, altcontactzipcode, altcontactphone
Comment 6 David Cook 2023-02-05 22:13:48 UTC
(In reply to David Cook from comment #5)
> (In reply to Marcel de Rooy from comment #4)
> >   `streetnumber` tinytext DEFAULT NULL COMMENT 'the house number for your
> > patron/borrower''s primary address',
> > 
> > Are we going the right direction here?
> 
> Perhaps not.
> 
> Looks like borrower_modifications is out of sync with borrowers and
> deletedborrowers.
> 
> Looks like many fields in borrower_modifications have the wrong type:
> streetnumber, streettype, zipcode, mobile, B_streetnumber, B_streettype,
> B_address, B_zipcode, password, altcontactfirstname, altcontactsurname,
> altcontactaddress1, altcontactaddress2, altcontactaddress3,
> altcontactzipcode, altcontactphone

At least that's in kohastructure.sql. 

I am not sure about an upgraded database.

Yikes...
Comment 7 Katrin Fischer 2023-02-26 11:31:11 UTC
I believe the discussion about harmonizing the datatypes would be better moved elsewhere so we can proceed with this patch that brings the form in line with the form in the staff interface. A simple change that will help avoid issues for now and add to consistency.
Comment 8 Katrin Fischer 2023-02-26 11:36:00 UTC
Created attachment 147421 [details] [review]
Bug 32663: Limit streetnumber to 10 characters in OPAC

This change harmonizes the patron streetnumber input between
the staff interface and the OPAC, so that you can only enter 10
characters into the streetnumber for the OPAC. Without this change,
a fatal error will be thrown trying to save the too long data.

Test plan:
0. Apply the patch
1. Go to http://localhost:8080/cgi-bin/koha/opac-memberentry.pl
2. Note that you can only enter 10 characters into the "Street number"
field as a self-registration patron
3. Log into Koha
4. Go to http://localhost:8080/cgi-bin/koha/opac-memberentry.pl
5. Note that you can only enter 10 characters into the "Street number"
field when editing logged in patron details too
6. Go to http://localhost:8081/cgi-bin/koha/members/memberentry.pl?op=add&categorycode=S
7. Note that you can only enter 10 characters into the "Street number"
field as a staff member

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Solene Ngamga <solene.ngamga@inLibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 9 Tomás Cohen Arazi 2023-03-02 17:45:59 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 10 Matt Blenkinsop 2023-03-03 12:23:38 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 11 Lucas Gass 2023-03-10 14:57:45 UTC
Backported to 22.05.x for upcoming 22.05.11
Comment 12 Arthur Suzuki 2023-03-29 13:12:33 UTC
applied to 21.11 for 21.11.19
Comment 13 wainuiwitikapark 2023-04-27 05:38:18 UTC
Not backported to 21.05.x