Bug 13150 - C4::Search::searchResults triggers software error by passing incorrect values to GetAuthorisedValueDesc
Summary: C4::Search::searchResults triggers software error by passing incorrect values...
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Galen Charlton
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-27 15:13 UTC by Barton Chittenden
Modified: 2015-06-04 23:23 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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" ) {