From 700eea96e6ed6ba48a3460bb2d831dc0a5eb05ca Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 15 Mar 2012 16:27:07 -0400 Subject: [PATCH] Bug 7722 - Insidious problem with searching I cannot find the root cause of this issue, but multiple libraries that I am aware of have problems searching on particular search terms ( and never the same terms at the same library ). The error they get when they trigger this problem is: Tag "" is not a valid tag. at /home/koha/kohaclone/C4/Biblio.pm line 1849 Something somewhere is adding empty keys to C4::Context->marcfromkohafield, I think it may have something to do with the analytics feature that was added. In the while loop for TransformKohaToMarc, there is a line next unless my $dtm = $db_to_marc->{''}->{$name}; I don't think it's working. If I dump $dtm, for each search, I see the dump twice. It looks like this: $VAR1 = [ '952', 'w' ]; $VAR1 = []; I think the second time, when it is empty is what's breaking this. The next never fails because even though it is empty, it is still a valid arrayref. The solution I have some up with is to skip over the elements where the arrayref is empty. --- C4/Biblio.pm | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 81da91b..021dd99 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1973,6 +1973,7 @@ sub TransformKohaToMarc { my $db_to_marc = C4::Context->marcfromkohafield; while ( my ($name, $value) = each %$hash ) { next unless my $dtm = $db_to_marc->{''}->{$name}; + next unless ( scalar( @$dtm ) ); my ($tag, $letter) = @$dtm; foreach my $value ( split(/\s?\|\s?/, $value, -1) ) { if ( my $field = $record->field($tag) ) { -- 1.7.2.5