Bug 8772

Summary: Uninitialized variable triggers error log entry in smart_rules.pl
Product: Koha Reporter: Mark Tompsett <mtompset>
Component: CirculationAssignee: Mark Tompsett <mtompset>
Status: CLOSED FIXED QA Contact:
Severity: trivial    
Priority: P5 - low CC: chris, gmcharlt, kyle.m.hall, paul.poulain, veron
Version: 3.8   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Added "|| q{}" into variable declaration/initialization
[SIGNED-OFF] Bug 8772 - Uninitialized variable triggers error log entry in smart_rules.pl

Description Mark Tompsett 2012-09-14 17:17:11 UTC
Test
----
1) Login
2) Go to administration
3) Circulations and Fines
4) tail /var/log/koha/...
There's now several uninitialized $op variables.
5) apply a patch that changes line 47 (where the my $op) is to have "|| q{}"
6) retest no errors.

Sorry, it's late. No time for a patch.
Comment 1 Mark Tompsett 2012-09-18 16:16:14 UTC Comment hidden (obsolete)
Comment 2 Marc VĂ©ron 2012-09-18 18:06:02 UTC
Created attachment 12320 [details] [review]
[SIGNED-OFF] Bug 8772 - Uninitialized variable triggers error log entry in smart_rules.pl

Changed declartion from:
  my $op = $input->param('op');
to
  my $op = $input->param('op') || q{};
in order to give an empty string default preventing error
logs from filling needlessly.

Signed-off-by: Marc Veron <veron@veron.ch>

The patch removes warnings like:
Use of uninitialized value $op in string eq at...

However there is one more warning, but it is not related to $op (addressed by this patch):
smart-rules.pl: Use of uninitialized value in string ne at .../admin/smart-rules.pl line 388.
Comment 3 Paul Poulain 2012-10-09 09:52:42 UTC
QA comment:
 * tiny & trivial patch, that just silence a warn
 * passes koha-qa.pl

passed QA
Comment 4 Paul Poulain 2012-10-09 09:55:22 UTC
Patch pushed to master.

Still 2 warns, but not related to this patch:

Use of uninitialized value in string ne at /home/paul/koha.dev/koha-community/admin/smart-rules.pl line 388.
Use of uninitialized value in sprintf at /home/paul/koha.dev/koha-community/admin/smart-rules.pl line 387.
Comment 5 Chris Cormack 2012-10-09 21:37:01 UTC
Pushed to 3.8.x, will be in 3.8.6