View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0022408 | mantisbt | custom fields | public | 2017-02-22 06:38 | 2025-09-09 14:23 |
Reporter | jensberke | Assigned To | vboctor | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | assigned | Resolution | open | ||
Product Version | 1.3.5 | ||||
Target Version | 2.28.0 | ||||
Summary | 0022408: Custom field's value logged as changed in history, when it wasn't changed | ||||
Description | If a custom field of type "multiselection list" in an issue already has a value and you change another value in the ticket, the custom field's value also gets logged in the issue history though it hasn't changed. | ||||
Steps To Reproduce |
| ||||
Tags | No tags attached. | ||||
has duplicate | 0022421 | closed | atrol | On Issue Update, history always lists the multiselection custom fields though they have not been updated |
has duplicate | 0023756 | closed | atrol | Multiselection list field in Issue History Always Shows New Value Instead of Old Value |
has duplicate | 0026750 | closed | atrol | multilist and checkbox customfields are listed in history without change |
related to | 0022464 | assigned | dregad | Loose type comparison can prevent custom field update |
I just checked Mantis 2.1.0 and it happens there as well. |
|
Right. The problem is caused by the function that get executed when storing/restoring the values to/from database No time to have a deeper look at the moment. |
|
The root cause is that bug_update.php does not compare old vs new value when building the list of custom fields to update [1]. The problem can be fixed there or in custom field API [2], by adding a comparison between old and new values; the latter is less efficient (we can avoid calling custom_field_set_value() completely, since we already know the values), but would ensure consistent behavior from SOAP API, so maybe we should do both. [1] https://github.com/mantisbt/mantisbt/blob/release-2.1.0/bug_update.php#L307-L308 |
|
@dregad, not sure if you are aware that it works for other custom field types because there is a comparison of old and new value in function history_log_event_direct [1] The comparison fails in this case as we store the values by adding | at the begin and the end)
but compare after removing the |
[1] https://github.com/mantisbt/mantisbt/blob/release-2.1.0/core/history_api.php#L78 EDIT (dregad) use Markdown |
|
@atrol I did not realize that, thanks for pointing me to it. I'll have a look at the logic there. That being said, I think it makes sense to merge the proposed change anyway, as there is no point in executing an UPDATE query when it's not needed. |
|
I think the logic in the call to history_log_event_direct() in custom_field_set_value() is wrong.
So history_log_event_direct() is effectively comparing apples with oranges. |
|
@atrol your feedback on 0022408:0055747 would be appreciated. Do you agree with my analysis ? |
|
I don't have time to have a deeper look and for tests. |
|
I didn't test either, but yes this is what I think |
|
@vboctor, what's your take on 0022408:0055747 ? |
|
Hi, |
|
Hi, i think the correct fix is in the function custom_field_set_value : history_log_event_direct( $c_bug_id, $t_name, custom_field_database_to_value( $row['value'], $t_type ), $p_value ); So was this line in Mantis 1.2.10. So instead of $t_value it has to be $p_value, which is the new not formatted value. |
|
@dregad seems reasonable since it seems to fix the issue :) |
|
Hi! Any update on this issue? from the above history it looks like the PR is there but we're still seeing this issue so are there plans to roll it out? |
|
@sandyj there is a good reason that the PR is not merged, see my comment |
|
In file
can we call a |
|
created a pull request: https://github.com/mantisbt/mantisbt/pull/1514 |
|
still happening in 2.23.0 |
|
and still happening in 2.25.2 |
|
We need a hero to fix this bug because it's crucial to preserving data integrity. |
|
Hello, great job developing MantisBT, thank you for it. As MarcoW suggested in 0022408:0055863 to fix the issue for me I replaced the last parameter in history_log_event_direct to $p_value, so correct values are compared. Seems both PRs complicate the matter and it prevents the issue to be fixed. For example in PR 1930 an addition to core/custom_field_api.php doesn't seem right, $t_value is a value prepared for the database and for some time, checkbox and multiselect values are stored with a pipe at the beginning and the end, so it would break integrity of stored data. So what about changing one character and fix it for now? |
|
@pkaizar thanks for the ping, I had forgotten about this issue. Reading your comment, I realize that I completely overlooked @MarcoW's March 2017 note... The change from In any case you may be right that changing back to $p_value will fix this Issue, but some testing is needed to confirm. |
|
@dregad as feedback after all those years, i'd like to say that mantisbt is active in our production with this little change i have mentioned without any problems. I have taken this change in different releases, now we're at 2.15. |
|
Hello @dregad I tested it on version 2.25.2, so would be great, if someone could test it with the latest version. On the image are updates to the page. COE is input, Location checkboxes. |
|
Well, those are 2 production tests, because we have it released too :) |
|