Bug 35414 - Silence warn related to number_of_copies
Summary: Silence warn related to number_of_copies
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial (vote)
Assignee: Magnus Enger
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-28 12:58 UTC by Magnus Enger
Modified: 2023-12-14 21:17 UTC (History)
4 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:
24.05.00,23.11.01,23.05.07


Attachments
Bug 35414: Silence warn related to number_of_copies (1.51 KB, patch)
2023-11-29 14:02 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 35414: Silence warn related to number_of_copies (1.56 KB, patch)
2023-11-29 18:46 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 35414: Silence warn related to number_of_copies (1.65 KB, patch)
2023-12-01 07:26 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2023-11-28 12:58:26 UTC
cataloguing/additem.pl has this code: 

my $number_of_copies           = min( scalar $input->param('number_of_copies'), 1000 ); # TODO refine hardcoded maximum?

"number_of_copies" comes from the "Add multiple copies of this item" feature. The field for entering the number of copies defaults to empty, and this results in this warning, from the code above: 

[WARN] Argument "" isn't numeric in subroutine entry at /usr/share/koha/intranet/cgi-bin/cataloguing/additem.pl line 233.

We could fix this a couple of ways: 

- Make the number_of_copies field default to 1
- Fix the code, so 1 is used for number_of_copies, if the input is empty
Comment 1 Jonathan Druart 2023-11-29 12:58:44 UTC
I would do this:

-    my $number_of_copies           = min( scalar $input->param('number_of_copies'), 1000 ); # TODO refine hardcoded maximum?
+    my $number_of_copies           = min( $input->param('number_of_copies') || 0, 1000 ); # TODO refine hardcoded maximum?
Comment 2 Magnus Enger 2023-11-29 14:02:23 UTC Comment hidden (obsolete)
Comment 3 Owen Leonard 2023-11-29 18:46:11 UTC Comment hidden (obsolete)
Comment 4 Marcel de Rooy 2023-12-01 07:26:37 UTC
Created attachment 159425 [details] [review]
Bug 35414: Silence warn related to number_of_copies

To test in ktd:
- Tail the logs with "sudo tail -f /var/log/koha/kohadev/plack*.log"
- Find a record in the staff client
- Add an item to the record
- Observe "[WARN] Argument "" isn't numeric in subroutine entry ..."
  in /var/log/koha/kohadev/plack-intranet-error.log
- Apply this patch
- restart_all
- Tail the logs again
- Add another item
- Observe the absence of the earlier warning

Thanks to Jonathan Druart for suggesting this particular solution!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 5 Katrin Fischer 2023-12-11 18:47:05 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 6 Fridolin Somers 2023-12-12 07:38:20 UTC
Pushed to 23.11.x for 23.11.01
Comment 7 Lucas Gass 2023-12-14 21:17:27 UTC
Backported to 23.05.x for upcoming 23.05.07