From b0c1bfc0ab83c5a602d7c24a421be3567eefd19b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 27 Aug 2021 16:56:08 +0200 Subject: [PATCH] Bug 28912: Prevent Pseudonymization to be set if bcrypt_settings not set MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If Pseudonymization is set but the bcrypt_settings config used by the feature is not set, then there is an ugly 500 on checking out. bad bcrypt settings at /kohadevbox/koha/Koha/PseudonymizedTransaction.pm line 116. However it's pretty hard to handle correctly this exception (and that's why it hasn't be done initially). However we could prevent the pref to be turned on if the config entry is not present. Test plan: Remove the bcrypt_settings from the config Try to turn the syspref on Add the config Try to turn the syspref on/off Signed-off-by: Andrew Fuerste-Henry JD amended patch: fix qa failures Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit f73868b8ee121103e7406e26b20e9cf3ccae4eb7) Signed-off-by: Fridolin Somers --- admin/preferences.pl | 8 +++++++- .../prog/en/modules/admin/preferences.tt | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/admin/preferences.pl b/admin/preferences.pl index 1353397b9b..42fdc4e4ec 100755 --- a/admin/preferences.pl +++ b/admin/preferences.pl @@ -160,6 +160,7 @@ sub TransformPrefsToHTML { foreach my $line ( @{ $tab->{ $group } } ) { my @chunks; my @names; + my @warnings; foreach my $piece ( @$line ) { if ( ref ( $piece ) eq 'HASH' ) { @@ -178,6 +179,10 @@ sub TransformPrefsToHTML { # No highlighting of inputs yet, but would be useful $chunk->{'highlighted'} = 1 if ( $searchfield && $name =~ /^$searchfield$/i ); + if ( $name eq 'Pseudonymization' && ! C4::Context->config('bcrypt_settings')) { + push @warnings, 'bcrypt_config_not_set'; + $chunk->{disabled} = 1 unless $value; # Let disable if enabled + } push @chunks, $chunk; my $name_entry = { name => $name }; @@ -189,6 +194,7 @@ sub TransformPrefsToHTML { } } $name_entry->{'overridden'} = 1 if ( any { $name eq $_ } @override_syspref_names ); + push @names, $name_entry; } else { push @chunks, $piece; @@ -206,7 +212,7 @@ sub TransformPrefsToHTML { push @chunks, { type_text => 1, contents => $piece }; } } - push @lines, { CHUNKS => \@chunks, NAMES => \@names, is_group_title => 0 }; + push @lines, { CHUNKS => \@chunks, NAMES => \@names, WARNINGS => \@warnings, is_group_title => 0 }; } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt index dc9377fc01..961676261b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt @@ -100,7 +100,11 @@ [% IF ( CHUNK.dateinput ) %][% INCLUDE 'date-format.inc' %][% END %] [% END %] [% ELSIF ( CHUNK.type_select ) %] - + [% ELSE %] +