@@ -, +, @@ --- Koha/Template/Plugin/AuthorisedValues.pm | 17 ++++++----------- .../Template/Plugin/AuthorisedValues.t | 5 ++++- 2 files changed, 10 insertions(+), 12 deletions(-) --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ a/Koha/Template/Plugin/AuthorisedValues.pm @@ -81,17 +81,12 @@ sub GetDescriptionByKohaField { authorised_value => $params->{authorised_value}, } ); - my $av_check = $params->{authorised_value}; - if ($params->{opac}) { - if ($av->{opac_description}) { - $av_check = $av->{opac_description} - } elsif ($av->{lib}) { - $av_check = $av->{lib} - } - } elsif ($av->{lib}) { - $av_check = $av->{lib} - } - return $av_check + + my $description = $av->{lib} || $params->{authorised_value} || ''; + + return $params->{opac} + ? $av->{opac_description} || $description + : $description; } 1; --- a/t/db_dependent/Template/Plugin/AuthorisedValues.t +++ a/t/db_dependent/Template/Plugin/AuthorisedValues.t @@ -73,7 +73,7 @@ subtest 'GetByCode' => sub { subtest 'GetDescriptionByKohaField' => sub { - plan tests => 7; + plan tests => 8; $schema->storage->txn_begin; @@ -145,6 +145,9 @@ subtest 'GetDescriptionByKohaField' => sub { $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( { kohafield => 'dummy.field', authorised_value => $non_existent_av } ); is( $av, $non_existent_av, 'If both OPAC and staff descriptions are missing, the parameter should be displayed'); + $av = Koha::Template::Plugin::AuthorisedValues->GetDescriptionByKohaField( + { kohafield => 'dummy.field', authorised_value => undef } ); + is( $av, '', 'If both OPAC and staff descriptions are missing, and the parameter is undef, an empty string should be displayed'); $schema->storage->txn_rollback; }; --