Bug 13522

Summary: tools/viewlog.pl does not compile in older perls
Product: Koha Reporter: Colin Campbell <colin.campbell>
Component: ToolsAssignee: Colin Campbell <colin.campbell>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: chris, fridolin.somers, jonathan.druart, mtj, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13544
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 11331    
Bug Blocks:    
Attachments: Proposed patch
Bug 13522: Make it explicit that scalar containd a hash ref
[PASSED QA] Bug 13522: Make it explicit that scalar containd a hash ref

Description Colin Campbell 2015-01-06 10:50:47 UTC
Attempting to view logs on a system with a perl older than 5.12 gives the following compile time error:
Type of arg 1 to keys must be hash (not array element) at viewlog.pl line 214, near "];"

Prior to 5.12 keys could only be called on a hash sites using 5.10 cannot use viewlog as a result
Comment 1 Colin Campbell 2015-01-06 11:51:53 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2015-01-08 12:15:49 UTC
*** Bug 13538 has been marked as a duplicate of this bug. ***
Comment 3 Jonathan Druart 2015-01-08 12:19:53 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2015-01-08 12:20:37 UTC
I had exactly the same patch.
I consider this as major since the page is not accessible at all.
Comment 5 Jonathan Druart 2015-01-08 12:21:17 UTC
I tested it on a sandbox (perl 5.10.1).
Comment 6 Kyle M Hall 2015-01-09 11:55:07 UTC
Created attachment 35041 [details] [review]
[PASSED QA] Bug 13522: Make it explicit that scalar containd a hash ref

Prior to perl 5.12 keys can only operate on a hash. So although
$data[0] ( thats an abysmal variable name! ) will contain a hash ref
the perl compiler cannot deduce that from the context and gives
a syntax error. Add the hash sigil to make the context explicit and
the compiler can generate the correct code.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 7 Fridolin Somers 2015-01-09 14:39:35 UTC
Sorry for this bug.

In the same context, have a look at admin/auth_subfields_structure.pl, Line 102 :
  my @authtypes = (sort keys getauthtypes);
getauthtypes return a harsh ref, not a hash.
Is it also a dangerous code ?
Comment 8 Jonathan Druart 2015-01-09 14:53:49 UTC
(In reply to Fridolin SOMERS from comment #7)
> Sorry for this bug.
> 
> In the same context, have a look at admin/auth_subfields_structure.pl, Line
> 102 :
>   my @authtypes = (sort keys getauthtypes);
> getauthtypes return a harsh ref, not a hash.
> Is it also a dangerous code ?

Good catch, I have opened bug 13544.
Comment 9 Tomás Cohen Arazi 2015-01-10 19:19:27 UTC
Patch pushed to master.

Thanks Colin!
Comment 10 Chris Cormack 2015-01-14 23:43:38 UTC
Pushed to 3.18.x, will be in 3.18.3
Comment 11 Mason James 2015-01-16 23:36:28 UTC
Pushed to 3.16.x, will be in 3.16.7