Browse Source

Bug 17642: Do not explode if no authorised value exist

Can't call method "lib" on an undefined value at
/home/vagrant/kohaclone/Koha/AuthorisedValues.pm line 137.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
16.11.x
Jonathan Druart 8 years ago
committed by Kyle M Hall
parent
commit
5f4337a765
  1. 1
      Koha/AuthorisedValues.pm
  2. 7
      t/db_dependent/AuthorisedValues.t

1
Koha/AuthorisedValues.pm

@ -134,6 +134,7 @@ sub get_description_by_koha_field {
return $cached if $cached;
my $av = $self->find_by_koha_field($params);
return {} unless defined $av;
my $descriptions = { lib => $av->lib, opac_description => $av->opac_description };
$memory_cache->set_in_cache( $cache_key, $descriptions );
return $descriptions;

7
t/db_dependent/AuthorisedValues.t

@ -174,7 +174,7 @@ subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
is( $av, undef, );
};
subtest 'get_description_by_koha_field' => sub {
plan tests => 3;
plan tests => 4;
my $descriptions;
# Test authorised_value = 0
@ -199,6 +199,11 @@ subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field(
{ kohafield => 'items.restricted', authorised_value => undef } );
is_deeply( $descriptions, {}, ) ; # This could be arguable, we could return undef instead
# No authorised_value
$descriptions = Koha::AuthorisedValues->get_description_by_koha_field(
{ kohafield => 'items.restricted', authorised_value => "does not exist" } );
is_deeply( $descriptions, {}, ) ; # This could be arguable, we could return undef instead
};
subtest 'get_descriptions_by_koha_field' => sub {
plan tests => 1;

Loading…
Cancel
Save