Bug 27861

Summary: Warning in C4/XSLT.pm - use of uninitialized value in numeric eq (==)
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: TemplatesAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: andrewfh, jonathan.druart, martin.renvoize, victor
Version: Main   
Hardware: All   
OS: All   
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.06,20.05.12
Bug Depends on:    
Bug Blocks: 25790    
Attachments: Bug 27861: Warning in C4/XSLT.pm - use of uninitialized value in numeric eq (==)
Bug 27861: Warning in C4/XSLT.pm - use of uninitialized value in numeric eq (==)
Bug 27861: Warning in C4/XSLT.pm - use of uninitialized value in numeric eq (==)

Description Fridolin Somers 2021-03-04 14:46:53 UTC
In C4/XSLT.pm :
 elsif ( exists $itemtypes->{ $item->effective_itemtype }
            && $itemtypes->{ $item->effective_itemtype }->{notforloan} == 1 )

itemtype.notforloan is null by default, its generated a warning in logs.
Comment 1 Fridolin Somers 2021-03-04 16:34:07 UTC
Created attachment 117752 [details] [review]
Bug 27861: Warning in C4/XSLT.pm - use of uninitialized value in numeric eq (==)

In C4/XSLT.pm :
 elsif ( exists $itemtypes->{ $item->effective_itemtype }
            && $itemtypes->{ $item->effective_itemtype }->{notforloan} == 1 )

itemtype.notforloan is null by default, its generated a warning in logs.

Test plan :
1) Choose a record with itemtype.notforloan = NULL
2) Display the record using XSLT
3) See patch removed warning
Comment 2 Owen Leonard 2021-04-15 12:37:51 UTC
I couldn't reproduce this error. The data in my test system didn't have NULL in itemtypes.notforloan, it had zero. But I tested both ways.
Comment 3 Fridolin Somers 2021-04-16 11:50:42 UTC
(In reply to Owen Leonard from comment #2)
> I couldn't reproduce this error. The data in my test system didn't have NULL
> in itemtypes.notforloan, it had zero. But I tested both ways.

Ahhh I found it :
You need to perform a search (with XSLT display) at OPAC.
Staff interface does not call this code.

Please retry.
Comment 4 Owen Leonard 2021-04-16 12:47:10 UTC
Created attachment 119731 [details] [review]
Bug 27861: Warning in C4/XSLT.pm - use of uninitialized value in numeric eq (==)

In C4/XSLT.pm :
 elsif ( exists $itemtypes->{ $item->effective_itemtype }
            && $itemtypes->{ $item->effective_itemtype }->{notforloan} == 1 )

itemtype.notforloan is null by default, its generated a warning in logs.

Test plan :
1) Choose a record with itemtype.notforloan = NULL
2) Perform a search in the OPAC which will return results which
   include the record using XSLT
3) See patch removed warning

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 5 Owen Leonard 2021-04-16 12:47:48 UTC
(In reply to Fridolin Somers from comment #3)

> You need to perform a search (with XSLT display) at OPAC.

That was it! I modified the test plan in the commit message.
Comment 6 Martin Renvoize 2021-04-19 13:06:22 UTC
Created attachment 119852 [details] [review]
Bug 27861: Warning in C4/XSLT.pm - use of uninitialized value in numeric eq (==)

In C4/XSLT.pm :
 elsif ( exists $itemtypes->{ $item->effective_itemtype }
            && $itemtypes->{ $item->effective_itemtype }->{notforloan} == 1 )

itemtype.notforloan is null by default, its generated a warning in logs.

Test plan :
1) Choose a record with itemtype.notforloan = NULL
2) Perform a search in the OPAC which will return results which
   include the record using XSLT
3) See patch removed warning

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 7 Jonathan Druart 2021-04-21 08:47:04 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 8 Fridolin Somers 2021-04-29 09:41:50 UTC
Pushed to 20.11.x for 20.11.06
Comment 9 Andrew Fuerste-Henry 2021-05-24 15:24:21 UTC
Pushed to 20.05.x for 20.05.12
Comment 10 Victor Grousset/tuxayo 2021-05-24 16:56:50 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.