Bug 8458

Summary: $stemmed_operand in C4::Search _build_stemmed_operand is not initialized.
Product: Koha Reporter: Mark Tompsett <mtompset>
Component: SearchingAssignee: Mark Tompsett <mtompset>
Status: CLOSED FIXED QA Contact: Mason James <mtj>
Severity: normal    
Priority: P5 - low CC: chris, kyle, mtj, paul.poulain
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: Initialized $stemmed_operand to q{} (perl critic friendly empty string)
Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not initialized. Added =q{} to initialize it to the empty string at declaration time.

Description Mark Tompsett 2012-07-17 12:42:56 UTC
Summary says it all.
Found this while reading my git clone's code.
Comment 1 Mark Tompsett 2012-07-17 12:59:18 UTC Comment hidden (obsolete)
Comment 2 Kyle M Hall 2012-07-17 14:02:10 UTC
perlcritic does not report this as a PBP violation. Running perlcritic on C4/Search.pm in master results in:
C4/Search.pm source OK

PBP does recommend using
    my $string = q{};
instead of 
    my $string = "";
or
    my $string = '';

but does not make a judgement on
    my $string;

I believe this rule applies to re-initializing a previously used variable to an empty string, no initializing it to begin with.
Comment 3 Jared Camins-Esakov 2012-07-17 14:04:30 UTC
This is a valid bug. The perlcritic friendly bit is using q{} instead of ''.
Comment 4 Kyle M Hall 2012-07-17 17:45:26 UTC
I'm guessing that the point of this bug is that the variable is concatenated with itself, even though it is undef, which will result in a warning. In that case, I see how this is a valid bug, but the description of the bug did not describe that.
Comment 5 Kyle M Hall 2012-07-17 17:46:43 UTC
Created attachment 10910 [details] [review]
Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not initialized. Added =q{} to initialize it to the empty string at declaration time.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 6 Mason James 2012-07-18 02:19:56 UTC
(In reply to comment #5)
> Created attachment 10910 [details] [review]
> Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not
> initialized. Added =q{} to initialize it to the empty string at declaration
> time.
> 
> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

passing QA, nice spotting!

------------
$ koha-qa.pl
- d0ec5cf Bug 8458 - $stemmed_operand in C4::Search _build_stemmed_operand is not initialized. Added =q{} to initialize it to the empty string at declaration time.
        C4/Search.pm
- perlcritic-progressive tests... OK
- perl -c syntax tests... OK
Comment 7 Chris Cormack 2012-07-24 01:36:45 UTC
Pushed to 3.8.x will be in 3.8.4