When ampersand is used in a text field before_save and after_save mismatched #9015
Labels
Area: Databases
Issues & PRs related to all things regarding databases
Area: Module
Issues & PRs related to modules that do not have specific label
Priority:Important
Issues & PRs that are important; broken functions, errors - there are workarounds
Type: Bug
Bugs within the core SuiteCRM codebase
Issue
I have a relatively simple logic hook that compares a text field and monitors a text field (chase_status) for changes on save.
On changes the logic hook will update two other fields with todays date (last_chased) and the current user full name (last_chased_by). This works well until an ampersand is used anywhere within the text field.
When using an ampersand within this text field and saving the record the logic hooks incorrectly identifies a change and whenever any subsequent saves are performed on the record from this point onwards the date of change field and current user full name field are continually updated even if not changes have been performed to this specific field
We have enabled auditing on this text field and the audit continually records a change even though nothing has changed
This is the logic hook used
Expected Behavior
last_chased and last_chased_by fields should only update when a change to the text field chase_status occurs
Actual Behavior
When a record is saved and the text field contains an ampersand the fields last_chased and last_chased_by are updated even when no changes has been made to the text field chase_status
Possible Fix
When running a query on the audit table I can see that the values for before_value_string and after_value_string do not match when an ampersand is used
On the before_value_string the ampersand is identified as '&' and on the after_value_string its identified as '&' causing the issue.
Context
The bug is causing issues with reporting and business functions relying on accurate reports as we've missed records that have not been "chased" as these records containing an ampersand will have an incorrect last_chased date. Audit data will also be inaccurate showing various users as chasing the record even though they have not actually performed this task.
Your Environment
The text was updated successfully, but these errors were encountered: