View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0027807 | mantisbt | bugtracker | public | 2020年12月28日 19:28 | 2025年12月13日 12:16 |
| Reporter | dregad | Assigned To | dregad | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | assigned | Resolution | open | ||
| Target Version | 2.29.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 @0@ to be displayed in the select.
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: 2020年9月26日 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
Powered by MantisBT 2.29.0-dev-master-e4ff7ef87
Copyright © 2000 - 2026 MantisBT Team
Contact administrator for assistance
Copyright © 2000 - 2026 MantisBT Team
Contact administrator for assistance
Page execution time: 0.1652 seconds