Bug 13150

Summary: C4::Search::searchResults triggers software error by passing incorrect values to GetAuthorisedValueDesc
Product: Koha Reporter: Barton Chittenden <barton>
Component: SearchingAssignee: Galen Charlton <gmcharlt>
Status: CLOSED INVALID QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: kyle
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:

Description Barton Chittenden 2014-10-27 15:13:59 UTC
The following error:

Software error:

Can't use string ("") as a HASH ref while "strict refs" in use at /usr/share/koha/lib/C4/Biblio.pm line 1635.
For help, please send mail to the webmaster (staff@bywatersolutions.com), giving this error message and the time and date of the error.

Is triggered by a catalog search.

In 3.16.03, line 1635 is the 'return' line:


sub GetAuthorisedValueDesc {
    my ( $tag, $subfield, $value, $framework, $tagslib, $category, $opac ) = @_;
    my $dbh = C4::Context->dbh;

    if ( !$category ) {

        return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'};

... $tagslib is passed in as an empty string, which is being dereferenced as a hashref.

The problem is this call in C4/Search.pm:

$other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};


The fifth argument here is '', which should be a hashref.

I have verified that this code exists in 3.14.03 as well as master.

I have not yet determined how this logic is being called.
Comment 1 Kyle M Hall 2014-10-27 17:49:16 UTC
This was caused by memcached needing a restart on this particular server.

However, this could be solved in the code with a bit more testing:

diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index 61e4c3b..17afeaf 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -1616,7 +1616,7 @@ sub GetAuthorisedValueDesc {

     if ( !$category ) {

-        return $value unless defined $tagslib->{$tag}->{$subfield}->{'authorised_value'};
+        return $value unless $tagslib && defined $tagslib->{$tag}->{$subfield}->{'authorised_value'};

         #---- branch
         if ( $tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {