| Summary: | Correct compile time warnings in C4::Circulation | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Colin Campbell <colin.campbell> |
| Component: | Architecture, internals, and plumbing | Assignee: | Colin Campbell <colin.campbell> |
| Status: | CLOSED FIXED | QA Contact: | Jonathan Druart <jonathan.druart> |
| Severity: | minor | ||
| Priority: | P5 - low | CC: | chris, jonathan.druart, paul.poulain |
| Version: | 3.8 | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | --- |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: | Version(s) released in: | ||
| Circulation function: | |||
| Attachments: |
Proposed Patch
Bug 8761 Dont inadvertantly use slices |
||
Created attachment 12144 [details] [review] Proposed Patch Doc is perldiag not perlwarn The warns are the same with 5.14 too. I can confirm the patch makes the error goes away, and circ still works fine. 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> I proposed exactly the same patch in Bug 7621 (which introduces these warnings). So I mark it as Passed QA Patch pushed to master +1 to karma colin ;-) Chris_c = not sure this is needed or applying on 3.8 though Released in 3.10.0 |
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.