Bug 27011 - Warnings in returns.pl
Summary: Warnings in returns.pl
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: master
Hardware: All All
: P5 - low trivial (vote)
Assignee: Amy King
QA Contact: Testopia
URL:
Keywords: Academy
Depends on: 18789
Blocks: 25790
  Show dependency treegraph
 
Reported: 2020-11-13 09:31 UTC by Joonas Kylmälä
Modified: 2021-06-14 21:34 UTC (History)
10 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Text to go in the release notes:
This patch removes a variable ($name) that is no longer used in Circulation > Check in (/cgi-bin/koha/circ/returns.pl), and the resulting warnings (..[WARN] Use of uninitialized value in concatenation (.) or string at..) that were recorded in the error log.
Version(s) released in:
21.05.00,20.11.03,20.05.09,19.11.15


Attachments
Bug 27011 removed $name variable (1.55 KB, patch)
2021-01-19 03:30 UTC, Amy King
Details | Diff | Splinter Review
Bug 27011: Remove unused $name variable (1.95 KB, patch)
2021-01-19 09:20 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27011: Remove unused $name variable (2.02 KB, patch)
2021-01-19 13:34 UTC, Andrew Fuerste-Henry
Details | Diff | Splinter Review
Bug 27011: Remove unused $name variable (2.08 KB, patch)
2021-01-21 10:42 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ä 2020-11-13 09:31:50 UTC
When you check-in some books you get the following warnings to error logs:

> [WARN] Use of uninitialized value in concatenation (.) or string at /usr/share/koha/intranet/cgi-bin/circ/returns.pl line 164.
> [WARN] Use of uninitialized value in concatenation (.) or string at /usr/share/koha/intranet/cgi-bin/circ/returns.pl line 402.

This seems to be due to treating the patron fields as non-null values:

> 164     my $name   = $patron ? $patron->surname . ", " . $patron->title . " " . $patron->firstname : '';

The DB schema allows NULL values (and I think that is okay) so we should check for every one of these whether the value is defined or not before using it.
Comment 1 Jonathan Druart 2020-12-21 09:52:23 UTC
The variable is no longer used in the template, it has been removed by:

  commit 76eb3a0549efe4c1f1557071a6cb4b33d4bd3e4d
  Bug 18789: (follow-up) Pass a Koha::Patron object from returns.pl

-            <td>[% name %]</td>
+            <td>[% INCLUDE 'patron-title.inc' patron=patron %]</td>

We can simply remove the $name variable from the controller script.
Comment 2 Amy King 2021-01-19 03:30:45 UTC
Created attachment 115291 [details] [review]
Bug 27011 removed $name variable

Test Plan
1. Check out a book
2. Check in a book
3. Note what happens
4. Apply patch
5. Repeat step 1-2
6. Note that it doesn't break and everything still works
Comment 3 Jonathan Druart 2021-01-19 09:20:04 UTC
Created attachment 115301 [details] [review]
Bug 27011: Remove unused $name variable

The variable is no longer used in the template, it has been removed by:

  commit 76eb3a0549efe4c1f1557071a6cb4b33d4bd3e4d
  Bug 18789: (follow-up) Pass a Koha::Patron object from returns.pl

-            <td>[% name %]</td>
+            <td>[% INCLUDE 'patron-title.inc' patron=patron %]</td>

We can simply remove the $name variable from the controller script.

Test Plan:
1. Check out a book
2. Check in a book
3. Note what happens
4. Apply patch
5. Repeat step 1-2
6. Note that it doesn't break and everything still works

JD Amended patch: fix commit message
Comment 4 David Nind 2021-01-19 11:02:54 UTC
I may be testing the wrong way, but I don't see the errors in any of the logs when checking out and checking in a book (using koha-testing-docker).

Everything works as expected without or with the patch applied.
Comment 5 Joonas Kylmälä 2021-01-19 12:57:37 UTC
(In reply to David Nind from comment #4)
> I may be testing the wrong way, but I don't see the errors in any of the
> logs when checking out and checking in a book (using koha-testing-docker).
> 
> Everything works as expected without or with the patch applied.

Based on the code I think the warning only triggers when there is reserve attached to the item.
Comment 6 Andrew Fuerste-Henry 2021-01-19 13:34:24 UTC
Created attachment 115319 [details] [review]
Bug 27011: Remove unused $name variable

The variable is no longer used in the template, it has been removed by:

  commit 76eb3a0549efe4c1f1557071a6cb4b33d4bd3e4d
  Bug 18789: (follow-up) Pass a Koha::Patron object from returns.pl

-            <td>[% name %]</td>
+            <td>[% INCLUDE 'patron-title.inc' patron=patron %]</td>

We can simply remove the $name variable from the controller script.

Test Plan:
1. Check out a book
2. Check in a book
3. Note what happens
4. Apply patch
5. Repeat step 1-2
6. Note that it doesn't break and everything still works

JD Amended patch: fix commit message

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 7 Andrew Fuerste-Henry 2021-01-19 13:35:03 UTC
Slightly updated test plan: 

1 - have a patron without a title
2 - place a hold on an item for that patron
3 - check item in
4 - see message in error log
5 - apply patch, restart services
6 - repeat 1-3, no error generated
Comment 8 David Nind 2021-01-19 18:46:28 UTC
(In reply to Joonas Kylmälä from comment #5)

> Based on the code I think the warning only triggers when there is reserve
> attached to the item.

Thanks Joonas for clarifying!
Comment 9 Martin Renvoize 2021-01-21 10:42:51 UTC
Created attachment 115523 [details] [review]
Bug 27011: Remove unused $name variable

The variable is no longer used in the template, it has been removed by:

  commit 76eb3a0549efe4c1f1557071a6cb4b33d4bd3e4d
  Bug 18789: (follow-up) Pass a Koha::Patron object from returns.pl

-            <td>[% name %]</td>
+            <td>[% INCLUDE 'patron-title.inc' patron=patron %]</td>

We can simply remove the $name variable from the controller script.

Test Plan:
1. Check out a book
2. Check in a book
3. Note what happens
4. Apply patch
5. Repeat step 1-2
6. Note that it doesn't break and everything still works

JD Amended patch: fix commit message

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 10 Martin Renvoize 2021-01-21 10:43:18 UTC
Excellent work, Passing QA
Comment 11 Jonathan Druart 2021-01-21 15:25:20 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 12 Fridolin Somers 2021-01-25 15:28:22 UTC
Pushed to 20.11.x for 20.11.03
Comment 13 Andrew Fuerste-Henry 2021-02-01 21:58:47 UTC
Pushed to 20.05.x for 20.05.09
Comment 14 Victor Grousset/tuxayo 2021-02-02 01:35:09 UTC
Backported: Pushed to 19.11.x branch for 19.11.15