Bugzilla – Attachment 116883 Details for
Bug 22824
Replace YAML::Syck with YAML::XS
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22824: Prevent YesNo to be filled with invalid values
Bug-22824-Prevent-YesNo-to-be-filled-with-invalid-.patch (text/plain), 2.15 KB, created by
Jonathan Druart
on 2021-02-15 10:38:49 UTC
(
hide
)
Description:
Bug 22824: Prevent YesNo to be filled with invalid values
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-02-15 10:38:49 UTC
Size:
2.15 KB
patch
obsolete
>From cfa1b4cb12dd971982568f4de998c2a809269bb7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 15 Feb 2021 11:37:58 +0100 >Subject: [PATCH] Bug 22824: Prevent YesNo to be filled with invalid values > >This patch prevents koha-preferences to set other values than 1/0 to be >used for YesNo prefs >--- > misc/admin/koha-preferences | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > >diff --git a/misc/admin/koha-preferences b/misc/admin/koha-preferences >index 418c80cb04..ca3fa775d3 100755 >--- a/misc/admin/koha-preferences >+++ b/misc/admin/koha-preferences >@@ -60,7 +60,15 @@ sub _set_preference { > > _debug( "Setting $preference to $value" ); > >- C4::Context->set_preference( $preference, $value ); >+ if ( $preference->{type} eq 'YesNo' >+ && $value ne '0' >+ && $value ne '1' ) >+ { >+ print STDERR sprintf "System preference %s is YesNo and expects 1 or 0. '%s' was given, using '0'\n", >+ $preference->{variable}, $value; >+ } >+ >+ C4::Context->set_preference( $preference->{variable}, $value ); > } > > sub GetPreferences { >@@ -91,12 +99,11 @@ sub SetPreferences { > > exit 2 if ( scalar( @$current_state ) != scalar( keys %preferences ) ); > >- # Iterate through again, now that we've checked all of the YesNo sysprefs >- > foreach my $row ( @$current_state ) { >- next if ( $preferences{$row->{'variable'}} eq $row->{'value'} ); >+ my $new_value = $preferences{ $row->{variable} }->{value}; >+ next if $new_value && $row->{value} && $new_value eq $row->{value}; > >- _set_preference( $row->{'variable'}, $preferences{$row->{'variable'}} ); >+ _set_preference( $row, $new_value ); > } > > # FIXME This may be not needed >@@ -134,7 +141,7 @@ sub SetPreference { > > exit 3 if ( $value eq $row->{'value'} ); #FIXME exit?? > >- _set_preference( $preference, $value ); >+ _set_preference( $row, $value ); > } > > sub ClearPreference { >@@ -148,7 +155,7 @@ sub ClearPreference { > > exit 3 if ( $value eq $row->{'value'} ); > >- _set_preference( $preference, $value ); >+ _set_preference( $row, $value ); > } > > =head1 OPTIONS >-- >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 22824
:
116722
|
116723
|
116724
|
116725
|
116726
|
116727
|
116728
|
116729
|
116730
|
116731
|
116732
|
116733
|
116734
|
116735
|
116736
|
116741
|
116742
|
116743
|
116744
|
116745
|
116746
|
116747
|
116748
|
116749
|
116750
|
116751
|
116752
|
116753
|
116754
|
116755
|
116756
|
116881
|
116882
|
116883
|
116884
|
117037
|
117039
|
117040
|
117041
|
117042
|
117043
|
117044
|
117045
|
117046
|
117047
|
117048
|
117049
|
117050
|
117051
|
117052
|
117053
|
117054
|
117055
|
117056
|
117057
|
117058
|
117636
|
117637
|
117638
|
117639
|
117640
|
117641
|
117642
|
117643
|
117644
|
117645
|
117646
|
117647
|
117648
|
117649
|
117650
|
117651
|
117652
|
117653
|
117664
|
117666