From c237c7baa3b140402e1c96b3eef0189b104782ea Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sat, 26 Sep 2020 23:34:53 +0200 Subject: [PATCH] Prevent silent update of invalid enum field values If the value of a field stored in the database is not valid per the associated Enum string, editing the issue will silently reset the field's selection list to the enum's first value. The user may not notice this, and unwittingly update the field when saving other changes made to the Issue. To prevent this, print_enum_string_option_list() has been modified to add the field's current value to the select's options. Fixes #27807 --- core/print_api.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/print_api.php b/core/print_api.php index 8f4cd4fdb..dff1f3f16 100644 --- a/core/print_api.php +++ b/core/print_api.php @@ -976,6 +976,9 @@ function print_enum_string_option_list( $p_enum_name, $p_val = 0 ) { } $t_enum_values = MantisEnum::getValues( $t_config_var_value ); + if( !MantisEnum::hasValue( $t_config_var_value, $p_val ) ) { + array_unshift( $t_enum_values, $p_val ); + } foreach ( $t_enum_values as $t_key ) { $t_label = MantisEnum::getLocalizedLabel( $t_config_var_value, $t_string_var, $t_key ); -- 2.25.1