View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0027807 | mantisbt | bugtracker | public | 2020-12-28 19:28 | 2021-01-05 18:59 |
Reporter | dregad | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | assigned | Resolution | open | ||
Target Version | 2.26.0 | ||||
Summary | 0027807: Prevent silent update of invalid enum fields when editing issue | ||||
Description | 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. | ||||
Tags | No tags attached. | ||||
The initial approach to fix this by simply adding the field's current value ($p_val parameter) to the select's options in print_enum_string_option_list() introduces a regression in at least 2 pages (view_all_bug_page.php and bug_report_page.php), causing Original patch attached for reference, but a smarter approach is needed. 0001-Prevent-silent-update-of-invalid-enum-field-values.patch (1,272 bytes)
From c237c7baa3b140402e1c96b3eef0189b104782ea Mon Sep 17 00:00:00 2001 From: Damien Regad <dregad@mantisbt.org> 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 |
|