]> git.koha-community.org Git - koha.git/commit
Bug 25440: Fix for "uninitialized value in hash" warning in smart-rules.pl
authorAndrew Nugged <nugged@gmail.com>
Sun, 10 May 2020 15:18:35 +0000 (18:18 +0300)
committerLucas Gass <lucas@bywatersolutions.com>
Mon, 13 Jul 2020 17:05:07 +0000 (17:05 +0000)
commitcf93d673a0bcc17e26299f006da1faf00b24fe52
tree30a25263beddb18d75f8f3967d633d8a855636cb
parentb59c5fc63a14013bcb8b43cce093b5d1866db96e
Bug 25440: Fix for "uninitialized value in hash" warning in smart-rules.pl

This warning emitted:

Use of uninitialized value in hash element
at /admin/smart-rules.pl line 569.

that happened because we have NULLs in SQL results for 'categorycode'
and 'itemtype' which later used as 'any' kind of category/item in the
template, so for the template it passed this way:

    $rules->{ $r->{categorycode} }->{ $r->{itemtype} }->...

but undef will stringify as "" to become a hash key ("Hashes are
unordered collections of scalar values indexed by their associated
string key" https://perldoc.perl.org/perldata.html),

that's why "undef warning". To prevent warning here is the simple fix:

    $rules->{ $r->{categorycode} // '' }->{ $r->{itemtype} // '' }->...

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit b48162f1be1853a89e0ffc898bc0927edef93f95)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
admin/smart-rules.pl