Bug 41864

Summary: (Bug 40966 follow-up) Simple OPAC search generates warnings: Odd number of elements in anonymous hash
Product: Koha Reporter: Janusz Kaczmarek <januszop>
Component: Architecture, internals, and plumbingAssignee: Bugs List <koha-bugs>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: tomascohen
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: Sponsored Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 40966    
Bug Blocks:    
Attachments: Bug 41864: (Bug 40966 follow-up) Simple OPAC search generates warnings: Odd number of elements in anonymous hash
Bug 41864: (Bug 40966 follow-up) Simple OPAC search generates warnings: Odd number of elements in anonymous hash

Description Janusz Kaczmarek 2026-02-17 14:17:52 UTC
After introducing Bug 40966 opac-search.pl, when invoked in the 
simple form (not as advanced search) generates warnings like:

[WARN] Odd number of elements in anonymous hash at /kohadevbox/koha/opac/opac-search.pl line 529.

This is because 'weight_search_submitted' is not initialized for 
this search.

You get the same effect with this simple test:

#!/usr/bin/perl
use Modern::Perl;
use Data::Dumper;

say Dumper(
    {
        one => 1,
        two => &und
    }
);

sub und {

    #return undef;
}


But if you uncomment 'return undef', there is no warning.

So most probably, in this case, $cgi->param('weight_search_submitted') 
returns an empty list, not an undef.
Comment 1 Janusz Kaczmarek 2026-02-18 11:31:31 UTC
Created attachment 193341 [details] [review]
Bug 41864: (Bug 40966 follow-up) Simple OPAC search generates warnings: Odd number of elements in anonymous hash

After introducing Bug 40966 opac-search.pl, when invoked in the
simple form (not as advanced search) generates warnings like:

[WARN] Odd number of elements in anonymous hash at /kohadevbox/koha/opac/opac-search.pl line 529.

Test plan:
==========
1. Perform a simple search from main OPAC page.
2. Check the content of plack-opac-error.log. You should see a
   warning like:
   [WARN] Odd number of elements in anonymous hash at /kohadevbox/koha/opac/opac-search.pl line 529.
3. Apply the patch ; restart_all.
4. Repeat p. 1. There should be no new warning now.

Sponsored-by: Ignatianum University in Cracow
Comment 2 Roman Dolny 2026-02-18 17:32:15 UTC
Created attachment 193362 [details] [review]
Bug 41864: (Bug 40966 follow-up) Simple OPAC search generates warnings: Odd number of elements in anonymous hash

After introducing Bug 40966 opac-search.pl, when invoked in the
simple form (not as advanced search) generates warnings like:

[WARN] Odd number of elements in anonymous hash at /kohadevbox/koha/opac/opac-search.pl line 529.

Test plan:
==========
1. Perform a simple search from main OPAC page.
2. Check the content of plack-opac-error.log. You should see a
   warning like:
   [WARN] Odd number of elements in anonymous hash at /kohadevbox/koha/opac/opac-search.pl line 529.
3. Apply the patch ; restart_all.
4. Repeat p. 1. There should be no new warning now.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>