Bug 28167 - A warning when setting which library to use in intranet and UseCashRegisters is disabled
Summary: A warning when setting which library to use in intranet and UseCashRegisters ...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Joonas Kylmälä
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on: 24786
Blocks: 27126
  Show dependency treegraph
 
Reported: 2021-04-19 05:14 UTC by Joonas Kylmälä
Modified: 2023-12-28 20:42 UTC (History)
6 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:
22.11.00, 22.05.07, 21.11.14


Attachments
Bug 28167: Remove uninitialized variable warnings from circ/set-library.pl (2.09 KB, patch)
2022-08-29 20:44 UTC, Joonas Kylmälä
Details | Diff | Splinter Review
Bug 28167: Remove uninitialized variable warnings from circ/set-library.pl (2.14 KB, patch)
2022-09-12 19:58 UTC, David Nind
Details | Diff | Splinter Review
Bug 28167: Remove uninitialized variable warnings from circ/set-library.pl (2.20 KB, patch)
2022-09-13 12:45 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Joonas Kylmälä 2021-04-19 05:14:51 UTC
If you have  UseCashRegisters set to "Don't use" and in intranet try to change a library you are currently logged in at (/cgi-bin/koha/circ/set-library.pl) then you get the following warning in the logs:

plack-intranet-error.log:
> Use of uninitialized value $register_id in string ne at /usr/share/koha/intranet/cgi-bin/circ/set-library.pl line 81.
Comment 1 Joonas Kylmälä 2022-08-29 20:44:05 UTC
Created attachment 139966 [details] [review]
Bug 28167: Remove uninitialized variable warnings from circ/set-library.pl

With UseCashRegisters syspref disabled going to the page
/cgi-bin/koha/circ/set-library.pl in staff interface and setting a
library gives the following errors in plack-intranet-error.log:

Use of uninitialized value $register_id in string ne at /kohadevbox/koha/circ/set-library.pl line 79.
Use of uninitialized value $referer in pattern match (m//) at /kohadevbox/koha/circ/set-library.pl line 114.

In the if clause $userenv_register_id appears to be typoed, it should have
been $register_id as $userenv_register_id is always defined. As for the
$referer variable, it is undef if there is no referer so let's just initialize
it to an empty string for the regex so it doesn't give the warning.

To test:
 1) Go directly to /cgi-bin/koha/circ/set-library.pl by typing it in
    the URL bar and set a library
 2) Make sure plack-intranet-error.log doesn't contain the above mentioned errors
    after applying this patch
Comment 2 David Nind 2022-09-12 19:58:44 UTC
Created attachment 140505 [details] [review]
Bug 28167: Remove uninitialized variable warnings from circ/set-library.pl

With UseCashRegisters syspref disabled going to the page
/cgi-bin/koha/circ/set-library.pl in staff interface and setting a
library gives the following errors in plack-intranet-error.log:

Use of uninitialized value $register_id in string ne at /kohadevbox/koha/circ/set-library.pl line 79.
Use of uninitialized value $referer in pattern match (m//) at /kohadevbox/koha/circ/set-library.pl line 114.

In the if clause $userenv_register_id appears to be typoed, it should have
been $register_id as $userenv_register_id is always defined. As for the
$referer variable, it is undef if there is no referer so let's just initialize
it to an empty string for the regex so it doesn't give the warning.

To test:
 1) Go directly to /cgi-bin/koha/circ/set-library.pl by typing it in
    the URL bar and set a library
 2) Make sure plack-intranet-error.log doesn't contain the above mentioned errors
    after applying this patch

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Martin Renvoize 2022-09-13 12:45:56 UTC
Created attachment 140569 [details] [review]
Bug 28167: Remove uninitialized variable warnings from circ/set-library.pl

With UseCashRegisters syspref disabled going to the page
/cgi-bin/koha/circ/set-library.pl in staff interface and setting a
library gives the following errors in plack-intranet-error.log:

Use of uninitialized value $register_id in string ne at /kohadevbox/koha/circ/set-library.pl line 79.
Use of uninitialized value $referer in pattern match (m//) at /kohadevbox/koha/circ/set-library.pl line 114.

In the if clause $userenv_register_id appears to be typoed, it should have
been $register_id as $userenv_register_id is always defined. As for the
$referer variable, it is undef if there is no referer so let's just initialize
it to an empty string for the regex so it doesn't give the warning.

To test:
 1) Go directly to /cgi-bin/koha/circ/set-library.pl by typing it in
    the URL bar and set a library
 2) Make sure plack-intranet-error.log doesn't contain the above mentioned errors
    after applying this patch

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2022-09-13 12:47:41 UTC
Nice catch Joonas, cleans up the warning nicely and no regressions found.

Passing QA
Comment 5 Tomás Cohen Arazi 2022-09-22 11:24:50 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 6 Lucas Gass 2022-10-31 22:43:49 UTC
Backported to 22.05.x for upcoming 22.05.07 release
Comment 7 Arthur Suzuki 2022-11-14 16:48:37 UTC
applied to 21.11 for 21.11.14
Comment 8 Victor Grousset/tuxayo 2022-11-25 00:09:31 UTC
Not backported to oldoldstable (21.05.x). Feel free to ask if it's needed.

Nothing to document it seems, marking resolved.