Bug 8761 - Correct compile time warnings in C4::Circulation
Summary: Correct compile time warnings in C4::Circulation
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: 3.8
Hardware: All All
: P5 - low minor (vote)
Assignee: Colin Campbell
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-11 17:49 UTC by Colin Campbell
Modified: 2013-12-05 20:05 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Proposed Patch (1.60 KB, patch)
2012-09-11 17:59 UTC, Colin Campbell
Details | Diff | Splinter Review
Bug 8761 Dont inadvertantly use slices (1.65 KB, patch)
2012-09-12 07:43 UTC, Chris Cormack
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Campbell 2012-09-11 17:49:46 UTC
A recent enhancement to C4::Circulation has introduced some ambiguous constructs which on current perls give compile time warnings with perl 5.16.0 or 5.16.1 
(I've not tested with older)
if you check compilation with perl -wc C4/Circulation.pm you get the following warnings
Scalar value @values[$take] better written as $values[$take] at Circulation.pm line 985.
Scalar value @alloweddate[0] better written as $alloweddate[0] at Circulation.pm line 991.
Scalar value @alloweddate[1] better written as $alloweddate[1] at Circulation.pm line 993.
Scalar value @alloweddate[2] better written as $alloweddate[2] at Circulation.pm line 993.
Scalar value @alloweddate[2] better written as $alloweddate[2] at Circulation.pm line 994.

Heres the doc from perlwarn

          (W syntax) You've used an array slice (indicated by @) to select a single element of an
           array.  Generally it's better to ask for a scalar value (indicated by $).  The difference
           is that $foo[&bar] always behaves like a scalar, both when assigning to it and when
           evaluating its argument, while @foo[&bar] behaves like a list when you assign to it, and
           provides a list context to its subscript, which can do weird things if you're expecting
           only one subscript.

           On the other hand, if you were actually hoping to treat the array element as a list, you
           need to look into how references work, because Perl will not magically convert between
           scalars and lists for you.  See perlref.
Comment 1 Colin Campbell 2012-09-11 17:59:15 UTC Comment hidden (obsolete)
Comment 2 Colin Campbell 2012-09-11 18:00:37 UTC
Doc is perldiag not perlwarn
Comment 3 Chris Cormack 2012-09-12 07:34:50 UTC
The warns are the same with 5.14 too.
Comment 4 Chris Cormack 2012-09-12 07:42:44 UTC
I can confirm the patch makes the error goes away, and circ still works fine.
Comment 5 Chris Cormack 2012-09-12 07:43:09 UTC
Created attachment 12159 [details] [review]
Bug 8761 Dont inadvertantly use slices

Assignment to a single element slice is better written
as a scalar - This generates a compile time warning as it
can lead to odd behaviour see perldiag for details
This corrects some cases which were added in a recent
commit

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 6 Jonathan Druart 2012-09-12 13:35:14 UTC
I proposed exactly the same patch in Bug 7621 (which introduces these warnings). So I mark it as Passed QA
Comment 7 Paul Poulain 2012-09-13 15:57:47 UTC
Patch pushed to master
+1 to karma colin ;-)

Chris_c = not sure this is needed or applying on 3.8 though
Comment 8 Chris Cormack 2013-04-20 22:18:15 UTC
Released in 3.10.0