Bugzilla – Attachment 101535 Details for
Bug 21503
Update AuthorisedValues.pm to fall back to code if description doesn't exist
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21503: Restore existing ternary operator logic
Bug-21503-Restore-existing-ternary-operator-logic.patch (text/plain), 2.58 KB, created by
Jonathan Druart
on 2020-03-24 10:25:32 UTC
(
hide
)
Description:
Bug 21503: Restore existing ternary operator logic
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-24 10:25:32 UTC
Size:
2.58 KB
patch
obsolete
>From 594280dac91a2be4e6f78b2e37a77bfc04234ef4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 24 Mar 2020 11:04:28 +0100 >Subject: [PATCH] Bug 21503: Restore existing ternary operator logic > >This syntax is much more readable IMO. Precendent patch also missed the >case where the parameter was undef. >I think we are good now. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Template/Plugin/AuthorisedValues.pm | 17 ++++++----------- > .../Template/Plugin/AuthorisedValues.t | 5 ++++- > 2 files changed, 10 insertions(+), 12 deletions(-) > >diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm >index ae90288fb7..a4e163430a 100644 >--- a/Koha/Template/Plugin/AuthorisedValues.pm >+++ b/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; >diff --git a/t/db_dependent/Template/Plugin/AuthorisedValues.t b/t/db_dependent/Template/Plugin/AuthorisedValues.t >index 8d2382536b..722a229f0f 100644 >--- a/t/db_dependent/Template/Plugin/AuthorisedValues.t >+++ b/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; > }; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21503
:
80151
|
80152
|
80233
|
80439
|
80521
|
80544
|
80545
|
80558
|
80561
|
80562
|
80563
|
80601
|
80758
|
80759
|
80762
|
101323
|
101324
|
101325
|
101326
|
101327
|
101328
|
101524
|
101525
|
101526
|
101527
|
101528
|
101529
|
101533
|
101534
| 101535