500 error when saving record when audit enabled on numeric field #5038

Closed
opened 2026-02-20 16:28:29 -05:00 by deekerman · 0 comments
Owner

Originally created by @JackBuchanan on GitHub (Jul 5, 2023).

Issue

500 error is thrown when saving a record if a numeric field is set to auditable and the data change is to or from a null/empty value

Expected Behavior

Users should be able to save no value in a numeric field with audit enabled on that field

Actual Behavior

A 500 error is thrown when saving:

[05-Jul-2023 10:50:32 UTC] PHP Fatal error: Uncaught TypeError: Unsupported operand types: string + int in /var/www/SuiteCRM/include/database/DBManager.php:3093
Stack trace:
#0 /var/www/SuiteCRM/include/database/DBManager.php(3137): DBManager->getDataChanges()
#1 /var/www/SuiteCRM/data/SugarBean.php(6296): DBManager->getAuditDataChanges()
#2 /var/www/SuiteCRM/data/SugarBean.php(2428): SugarBean->auditBean()
#3 /var/www/SuiteCRM/include/SugarObjects/templates/company/Company.php(105): SugarBean->save()
#4 /var/www/SuiteCRM/modules/Accounts/AccountFormBase.php(510): Company->save()
#5 /var/www/SuiteCRM/modules/Accounts/Save.php(55): AccountFormBase->handleSave()
#6 /var/www/SuiteCRM/include/MVC/View/SugarView.php(824): include_once('...')
#7 /var/www/SuiteCRM/include/MVC/View/views/view.classic.php(72): SugarView->includeClassicFile()
#8 /var/www/SuiteCRM/include/MVC/View/SugarView.php(210): ViewClassic->display()
#9 /var/www/SuiteCRM/include/MVC/Controller/SugarController.php(432): SugarView->process()
#10 /var/www/SuiteCRM/include/MVC/Controller/SugarController.php(363): SugarController->processView()
#11 /var/www/SuiteCRM/include/MVC/SugarApplication.php(101): SugarController->execute()
#12 /var/www/SuiteCRM/index.php(51): SugarApplication->execute()
#13 {main}
thrown in /var/www/SuiteCRM/include/database/DBManager.php on line 3093

Possible Fix

Cast values to float before doing math on the values to determine if there has been a data change

Steps to Reproduce

  1. Create integer field and set it to auditable
  2. Add new field to edit view
  3. Set value to 10 and save
  4. Re-save the record after changing the value to and empty string(Suite will treat this as null when comparing)
  5. See 500 error

Context

Trying to save record after updating PHP version from 7 -> 8

Your Environment

  • SuiteCRM Version used: 7.13.3
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Chrome latest
  • Environment name and version (e.g. MySQL, PHP 7): PHP 8.0
  • Operating System and version (e.g Ubuntu 16.04): 18.04
Originally created by @JackBuchanan on GitHub (Jul 5, 2023). <!--- Provide a general summary of the issue in the **Title** above --> <!--- Before you open an issue, please check if a similar issue already exists or has been closed before. ---> <!--- If you have discovered a security risk please report it by emailing security@suitecrm.com. This will be delivered to the product team who handle security issues. Please don't disclose security bugs publicly until they have been handled by the security team. ---> <!--- Please be aware that as of the 31st January 2022 we no longer support 7.10.x. New issues referring to 7.10.x will only be valid if applicable to 7.12.x and above. If your issue is still applicable in 7.12.x, please create the issue following the template below --> #### Issue 500 error is thrown when saving a record if a numeric field is set to auditable and the data change is to or from a null/empty value <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> <!--- Ensure that all code ``` is surrounded ``` by triple back quotes. This can also be done over multiple lines --> #### Expected Behavior Users should be able to save no value in a numeric field with audit enabled on that field <!--- Tell us what should happen --> #### Actual Behavior A 500 error is thrown when saving: [05-Jul-2023 10:50:32 UTC] PHP Fatal error: Uncaught TypeError: Unsupported operand types: string + int in /var/www/SuiteCRM/include/database/DBManager.php:3093 Stack trace: #0 /var/www/SuiteCRM/include/database/DBManager.php(3137): DBManager->getDataChanges() #1 /var/www/SuiteCRM/data/SugarBean.php(6296): DBManager->getAuditDataChanges() #2 /var/www/SuiteCRM/data/SugarBean.php(2428): SugarBean->auditBean() #3 /var/www/SuiteCRM/include/SugarObjects/templates/company/Company.php(105): SugarBean->save() #4 /var/www/SuiteCRM/modules/Accounts/AccountFormBase.php(510): Company->save() #5 /var/www/SuiteCRM/modules/Accounts/Save.php(55): AccountFormBase->handleSave() #6 /var/www/SuiteCRM/include/MVC/View/SugarView.php(824): include_once('...') #7 /var/www/SuiteCRM/include/MVC/View/views/view.classic.php(72): SugarView->includeClassicFile() #8 /var/www/SuiteCRM/include/MVC/View/SugarView.php(210): ViewClassic->display() #9 /var/www/SuiteCRM/include/MVC/Controller/SugarController.php(432): SugarView->process() #10 /var/www/SuiteCRM/include/MVC/Controller/SugarController.php(363): SugarController->processView() #11 /var/www/SuiteCRM/include/MVC/SugarApplication.php(101): SugarController->execute() #12 /var/www/SuiteCRM/index.php(51): SugarApplication->execute() #13 {main} thrown in /var/www/SuiteCRM/include/database/DBManager.php on line 3093 <!--- Tell us what happens instead --> <!--- Also please check relevant logs (suitecrm.log, php error.log etc.) --> #### Possible Fix Cast values to float before doing math on the values to determine if there has been a data change <!--- Not obligatory, but suggest a fix or reason for the bug --> #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. Create integer field and set it to auditable 2. Add new field to edit view 3. Set value to 10 and save 4. Re-save the record after changing the value to and empty string(Suite will treat this as null when comparing) 5. See 500 error #### Context Trying to save record after updating PHP version from 7 -> 8 <!--- How has this bug affected you? What were you trying to accomplish? --> <!--- If you feel this should be a low/medium/high priority then please state so --> #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.13.3 * Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): Chrome latest * Environment name and version (e.g. MySQL, PHP 7): PHP 8.0 * Operating System and version (e.g Ubuntu 16.04): 18.04
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#5038
No description provided.