Bug 29898

Summary: Overdues.pm line 663, Use of uninitialized value in string eq
Product: Koha Reporter: Elias <elias.dehler>
Component: ToolsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: anke.bruns, fridolin.somers, michaela.sieber
Version: MainKeywords: Academy
Hardware: PC   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 25790    

Description Elias 2022-01-18 14:57:17 UTC
After migrating 37 instances from v19.11 to v20.11.13 the /etc/cron.daily/koha-common logs the following on 7 instances:

"Use of uninitialized value in string eq at /usr/share/koha/lib/C4/Overdues.pm line 663."

We've checked the settings across the instances and the database.
We can't find the root of this warning/error.
Comment 1 Fridolin Somers 2022-01-21 21:15:57 UTC
Ah indeed code looks weak :
https://git.koha-community.org/Koha-community/Koha/src/branch/20.11.x/C4/Overdues.pm#L663

It fetches first row but they may be no rows.

Code is from Bug 9180
Comment 2 Anke Bruns 2022-04-14 11:04:12 UTC
(In reply to Elias from comment #0)
> After migrating 37 instances from v19.11 to v20.11.13 the
> /etc/cron.daily/koha-common logs the following on 7 instances:
> 
> "Use of uninitialized value in string eq at
> /usr/share/koha/lib/C4/Overdues.pm line 663."
> 
> We've checked the settings across the instances and the database.
> We can't find the root of this warning/error.

Do you mean to say that in the other 30 instances the error doesn't occur and the overdues are processed correctly?
Comment 3 Anke Bruns 2022-04-21 10:14:43 UTC
We implemented a solution, replacing line 663 in /usr/share/koha/lib/C4/Overdues.pm, which originally reads:   

    if ( $branchcodes->[0] eq '' ) {

by:

  if ( !defined ($branchcodes->[0]) || $branchcodes->[0] eq '' ) {

Hope this is useful.
Comment 4 Anke Bruns 2022-04-21 10:51:07 UTC
My colleague just sent me this update to (In reply to Anke from comment #3)
> We implemented a solution, replacing line 663 in
> /usr/share/koha/lib/C4/Overdues.pm, which originally reads:   
> 
>     if ( $branchcodes->[0] eq '' ) {
> 
> by:
> 
>   if ( !defined ($branchcodes->[0]) || $branchcodes->[0] eq '' ) {
> 
> Hope this is useful.


I just received this enhancement:

  if ( @$branchcodes >= 1 && ( !defined ($branchcodes->[0]) || $branchcodes->[0] eq '' ) ) {

This prevents the routine from returning libraries if there are no overdue rules.
Comment 5 Fridolin Somers 2022-04-21 22:51:45 UTC
Pb still exists in actual master 21.12
Comment 6 Anke Bruns 2022-11-24 08:42:25 UTC
This bug is present also in 22.05, where the line in question is 675 instead of 663.

Could this be fixed for future versions, so we won't have to change Overdues.pm manually after every update?