Bug 11058 - Compile time warning issued by C4/Record.pm
Summary: Compile time warning issued by C4/Record.pm
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Colin Campbell
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-16 09:07 UTC by Colin Campbell
Modified: 2015-06-04 23:23 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Proposed Patch (1.12 KB, patch)
2013-10-16 09:16 UTC, Colin Campbell
Details | Diff | Splinter Review
[SIGNED OFF] Bug 11058: make variable name unique within its scope (1.19 KB, patch)
2013-10-16 10:25 UTC, Mark Tompsett
Details | Diff | Splinter Review
Bug 11058: make variable name unique within its scope (1.27 KB, patch)
2013-10-21 23:15 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Campbell 2013-10-16 09:07:12 UTC
Compile time warning in C4/Record.pm:
perl -wc C4/Record.pm 
"my" variable $stylesheet masks earlier declaration in same scope at C4/Record.pm line 313.

similar with anything using C4::Record

there are two lexical variable $stylesheet in the same sub.
Comment 1 Colin Campbell 2013-10-16 09:16:40 UTC Comment hidden (obsolete)
Comment 2 Mark Tompsett 2013-10-16 10:25:47 UTC Comment hidden (obsolete)
Comment 3 Mark Tompsett 2013-10-16 10:31:55 UTC
Comment on attachment 22010 [details] [review]
Proposed Patch

This is now obsolete.

mtompset@ubuntu:~/kohaclone$ git checkout -b bug_11058 origin/master
Branch bug_11058 set up to track remote branch master from origin.
Switched to a new branch 'bug_11058'

1) Confirmed Problem.
mtompset@ubuntu:~/kohaclone$ perl -wc C4/Record.pm
"my" variable $stylesheet masks earlier declaration in same scope at C4/Record.p                                                                             m line 313.
C4/Record.pm syntax OK

2) Looked at code:
mtompset@ubuntu:~/kohaclone$ vi C4/Record.pm
The code has a parameter passed named stylesheet, and a variable declared stylesheet. The parameter is used to set other variables which feed into this secondary declaration. So, renaming this variable is a good solution and should not cause any problems.

3) Applied patch
mtompset@ubuntu:~/kohaclone$ git bz apply 11058
Bug 11058 - Compile time warning issued by C4/Record.pm

22010 - Proposed Patch

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 11058: make variable name unique within its scope

4) Confirmed problem solved.
mtompset@ubuntu:~/kohaclone$ perl -wc C4/Record.pm
C4/Record.pm syntax OK

5) Decided to run koha-qa.pl on it for kicks.
mtompset@ubuntu:~/kohaclone$ ~/qa-test-tools/koha-qa.pl -v 2 -c 1
testing 1 commit(s) (applied to 0f5dc60 'Bug 10309: (follow-up) restore settin')

 OK     C4/Record.pm
   OK     pod
   OK     forbidden patterns
   OK     valid
                0
   OK     critic

6) Signed it off.
mtompset@ubuntu:~/kohaclone$ git so 1
Rewrite f1111fff1071b4a14251d5ecd80bfad07f567e4b (1/1)
Ref 'refs/heads/bug_11058' was rewritten
mtompset@ubuntu:~/kohaclone$ git commit --amend
[bug_11058 72c273c] [SIGNED OFF] Bug 11058: make variable name unique within its                                                                              scope
 Author: Colin Campbell <colin.campbell@ptfs-europe.com>
 1 file changed, 3 insertions(+), 3 deletions(-)

7) Attached it.
mtompset@ubuntu:~/kohaclone$ git bz attach 11058 HEAD
Bug 11058 - Compile time warning issued by C4/Record.pm

72c273c [SIGNED OFF] Bug 11058: make variable name unique within its scope

Attach? [yn] y
Attached SIGNED-OFF-Bug-11058-make-variable-name-unique-wit.patch

8) And now obsolete the old one, and make sure the status is right.
Comment 4 Kyle M Hall (khall) 2013-10-21 23:15:28 UTC
Created attachment 22227 [details] [review]
Bug 11058: make variable name unique within its scope

routine declares two lexical variables named $stylesheet
rename the second to keep code clearer and
avoid propagating compile time warnings

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Passes koha-qa.pl, works as advertised!
Comment 5 Galen Charlton 2013-10-22 01:22:33 UTC
Pushed to master.  Thanks, Colin!
Comment 6 Tomás Cohen Arazi (tcohen) 2013-12-05 14:21:04 UTC
This patch has been pushed to 3.12.x, will be in 3.12.8.

Thanks Colin!