Bug 26946 - Limit size of cash register's name on the UI
Summary: Limit size of cash register's name on the UI
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Martin Renvoize (ashimema)
QA Contact: Victor Grousset/tuxayo
URL:
Keywords:
Depends on: 23321
Blocks:
  Show dependency treegraph
 
Reported: 2020-11-06 09:58 UTC by Jonathan Druart
Modified: 2021-12-13 21:09 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.01,20.05.07
Circulation function:


Attachments
Bug 26946: Set maxlength for cash register name (2.78 KB, patch)
2020-11-09 13:00 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 26946: Set maxlength for cash register name (2.85 KB, patch)
2020-11-10 10:51 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 26946: Set maxlength for cash register name (2.90 KB, patch)
2020-12-08 20:20 UTC, Victor Grousset/tuxayo
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2020-11-06 09:58:37 UTC
If you create a new cash register with a "long" (not that long actually) name, the submit form fails with:

2020/11/06 09:56:19] [WARN] DBD::mysql::st execute failed: Data too long for column 'name' at row 1 [for Statement "INSERT INTO `cash_registers` ( `branch`, `description`, `name`, `starting_float`) VALUES ( ?,
?, ?, ? )" with ParamValues: 0="CPL", 1="<script>alert("â¤");</script>", 2="<script>alert("â¤");</script>", 3="0.00"] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1836.
Comment 1 Martin Renvoize (ashimema) 2020-11-06 10:02:03 UTC
Good catch, I'll take a look now
Comment 2 Martin Renvoize (ashimema) 2020-11-09 13:00:05 UTC
Created attachment 113310 [details] [review]
Bug 26946: Set maxlength for cash register name

The cash register names is limited to 24 characters at the database
level and so that restriction should also be reflected in the UI.

Test plan
1/ Add or Edit a cash register ( admin > accounts > cash registers )
2/ Note that you can enter a cash register name longer than 24
characters, but upon save the value is truncated.
3/ Apply patch
4/ Note you can not longer enter a cash register name longer than 24
characters.
5/ Signoff
Comment 3 ByWater Sandboxes 2020-11-10 10:51:12 UTC
Created attachment 113338 [details] [review]
Bug 26946: Set maxlength for cash register name

The cash register names is limited to 24 characters at the database
level and so that restriction should also be reflected in the UI.

Test plan
1/ Add or Edit a cash register ( admin > accounts > cash registers )
2/ Note that you can enter a cash register name longer than 24
characters, but upon save the value is truncated.
3/ Apply patch
4/ Note you can not longer enter a cash register name longer than 24
characters.
5/ Signoff

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 4 Sally 2020-11-10 10:51:57 UTC
Works perfectly, signed off.
Comment 5 Victor Grousset/tuxayo 2020-11-28 11:56:19 UTC Comment hidden (obsolete)
Comment 6 Victor Grousset/tuxayo 2020-11-28 17:52:27 UTC
Is there a reason to limit the size of the description? The database type is a LONGTEXT (2147483647). And also, the initial float limit is actually 22 before the decimal (number (28,6))
Comment 7 Martin Renvoize (ashimema) 2020-12-07 16:49:05 UTC
(In reply to Victor Grousset/tuxayo from comment #6)
> Is there a reason to limit the size of the description? The database type is
> a LONGTEXT (2147483647). And also, the initial float limit is actually 22
> before the decimal (number (28,6))

We're only setting 'length' and not 'maxlength' for description.. it's purely a styleing thing to keep the two text boxes lined up, it doesn't actually limit the input in the description case.
Comment 8 Victor Grousset/tuxayo 2020-12-08 20:20:56 UTC
Created attachment 114269 [details] [review]
Bug 26946: Set maxlength for cash register name

The cash register names is limited to 24 characters at the database
level and so that restriction should also be reflected in the UI.

Test plan
1/ Add or Edit a cash register ( admin > accounts > cash registers )
2/ Note that you can enter a cash register name longer than 24
characters, but upon save the value is truncated.
3/ Apply patch
4/ Note you can not longer enter a cash register name longer than 24
characters.
5/ Signoff

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Comment 9 Victor Grousset/tuxayo 2020-12-08 20:23:36 UTC
(In reply to Martin Renvoize from comment #7)
> We're only setting 'length' and not 'maxlength' for description..

Indeed! I forgot about that one, thanks. So, works as expected and no QA issue ^^
Comment 10 Jonathan Druart 2020-12-09 10:53:23 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 11 Fridolin Somers 2020-12-10 10:30:32 UTC
Pushed to 20.11.x for 20.11.01
Comment 12 Andrew Fuerste-Henry 2020-12-17 14:41:39 UTC
Pushed to 20.05.x for 20.05.07
Comment 13 Victor Grousset/tuxayo 2020-12-17 16:35:59 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.