From 54f2f6dc89812c92f7581bbc1d1a83adcc88f681 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 12 Oct 2016 13:48:09 +0100 Subject: [PATCH] Bug 17250: Do not retrieve marc subfield structure when the authorised value is not defined GetAuthValCode did not return anything if the authorised_value column was not defined. Our new calls to Koha::MarcSubfieldStructures->search should behave the same --- C4/Search.pm | 2 +- catalogue/detail.pl | 6 +++--- catalogue/itemsearch.pl | 6 +++--- catalogue/moredetail.pl | 12 ++++++------ circ/circulation.pl | 4 ++-- tools/inventory.pl | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 2583f90..829d950 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1852,7 +1852,7 @@ sub searchResults { my $shelflocations =GetKohaAuthorisedValues('items.location',''); # get notforloan authorised value list (see $shelflocations FIXME) - my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' }); + my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } }); my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef; #Get itemtype hash diff --git a/catalogue/detail.pl b/catalogue/detail.pl index b022c56..46387a9 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -195,16 +195,16 @@ my $copynumbers = GetKohaAuthorisedValues('items.copynumber', $fw); my (@itemloop, @otheritemloop, %itemfields); my $norequests = 1; -my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' }); +my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } }); if ( $mss->count ) { $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) ); } -$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' }); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } }); if ( $mss->count ) { $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) ); } -$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials' }); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.materials', authorised_value => { not => undef } }); my %materials_map; if ($mss->count) { my $materials_authvals = GetAuthorisedValues($mss->next->authorised_value); diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index 001cf28..a2f0e41 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -88,10 +88,10 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user({ flagsrequired => { catalogue => 1 }, }); -my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan' }); +my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } }); my $notforloan_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : []; -$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.location' }); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.location', authorised_value => { not => undef } }); my $location_values = $mss->count ? GetAuthorisedValues($mss->next->authorised_value) : []; if (scalar keys %params > 0) { @@ -264,7 +264,7 @@ if ($format eq 'html') { }; } - my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.ccode' }); + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.ccode', authorised_value => { not => undef } }); my $ccode_avcode = $mss->count ? $mss->next->authorised_value : 'CCODE'; my $ccodes = GetAuthorisedValues($ccode_avcode); my @ccodes; diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index b18d857..1a1adec 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -194,17 +194,17 @@ foreach my $item (@items){ } -my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost' }); +my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.itemlost', authorised_value => { not => undef } }); if ( $mss->count ) { - $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorisedvalue ) ); + $template->param( itemlostloop => GetAuthorisedValues( $mss->next->authorised_value ) ); } -$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged' }); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.damaged', authorised_value => { not => undef } }); if ( $mss->count ) { - $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorisedvalue ) ); + $template->param( itemdamagedloop => GetAuthorisedValues( $mss->next->authorised_value ) ); } -$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn' }); +$mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fw, kohafield => 'items.withdrawn', authorised_value => { not => undef } }); if ( $mss->count ) { - $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorisedvalue) ); + $template->param( itemwithdrawnloop => GetAuthorisedValues( $mss->next->authorised_value) ); } $template->param(count => $data->{'count'}, diff --git a/circ/circulation.pl b/circ/circulation.pl index 787d501..1501433 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -341,8 +341,8 @@ if (@$barcodes) { # Get the item title for more information my $getmessageiteminfo = GetBiblioFromItemNumber(undef,$barcode); - my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.notforloan' }); - $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorisedvalue : undef; + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $getmessageiteminfo->{frameworkcode}, kohafield => 'items.notforloan', authorised_value => { not => undef } }); + $template_params->{authvalcode_notforloan} = $mss->count ? $mss->next->authorised_value : undef; # Fix for bug 7494: optional checkout-time fallback search for a book diff --git a/tools/inventory.pl b/tools/inventory.pl index 1ad8116..ef59268 100755 --- a/tools/inventory.pl +++ b/tools/inventory.pl @@ -72,7 +72,7 @@ $frameworks->{''} = {frameworkcode => ''}; # Add the default framework for my $fwk (keys %$frameworks){ my $fwkcode = $frameworks->{$fwk}->{'frameworkcode'}; - my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fwkcode, kohafield => 'items.location' }); + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => $fwkcode, kohafield => 'items.location', authorised_value => { not => undef } }); my $authcode = $mss->count ? $mss->next->authorised_value : undef; if ($authcode && $authorisedvalue_categories!~/\b$authcode\W/){ $authorisedvalue_categories.="$authcode "; @@ -88,7 +88,7 @@ my $statuses = []; for my $statfield (qw/items.notforloan items.itemlost items.withdrawn items.damaged/){ my $hash = {}; $hash->{fieldname} = $statfield; - my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => $statfield }); + my $mss = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => $statfield, authorised_value => { not => undef } }); $hash->{authcode} = $mss->count ? $mss->next->authorised_value : undef; if ($hash->{authcode}){ my $arr = GetAuthorisedValues($hash->{authcode}); -- 2.8.1