From 91d5ade709536ba27cb87e58ab10bb3386da016b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 28 Oct 2015 10:43:55 +0000 Subject: [PATCH] Bug 14100: Fix Search.t tests So, this one is VERY weird, let me try to explain what I have understood. Bisecting using run prove t/db_dependent/Search.t, I have found that the following commit make the test fail: commit 0f63f89f66e40cc01ef02da3654fcfb404c9001d Bug 14100: Generic solution for language overlay - Item types The error is DBI bind_columns: invalid number of arguments: got handle + 0, expected handle + between 1 and -1 Usage: $h->bind_columns(\$var1 [, \$var2, ...]) at /usr/lib/i386-linux-gnu/perl5/5.20/DBI.pm line 2065. Note that the interface (admin/itemtypes.pl) which calls the same subroutine with the same parameter (style => 'array') works great. The problem comes from the change in C4::Search::searchResults, if I only apply the change done to this subroutine on 0f63f89f^1, I reproduce the issue. Looking closely at how %itemtypes is built, we could actually call GetItemTypes with the style => 'hash' to get exactly what we want. The following piece prove it for you: use Test::More; use C4::Koha; my $i = GetItemTypes; my $j = GetItemTypes(style => 'array'); my %itemtypes; for my $itemtype ( @$j ) { $itemtypes{ $itemtype->{itemtype} } = $itemtype; } is_deeply( \%itemtypes, $i); So changing the code accordingly and just forget this last hour... --- C4/Search.pm | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 5c11862..a871586 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1870,13 +1870,8 @@ sub searchResults { # get notforloan authorised value list (see $shelflocations FIXME) my $notforloan_authorised_value = GetAuthValCode('items.notforloan',''); - #Build itemtype hash - #find itemtype & itemtype image - my %itemtypes; - my $itemtypes = GetItemTypes( style => 'array' ); - for my $itemtype ( @$itemtypes ) { - $itemtypes{ $itemtype->{itemtype} } = $itemtype; - } + #Get itemtype hash + my %itemtypes = %{ GetItemTypes() }; #search item field code my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber", "" ); -- 2.1.0