You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The BeanJsonSerializer.php incorrectly treats numeric strings as numbers during JSON serialization. This issue arises particularly in fields containing leading zeros, such as phone and company registration numbers.
Description:
When using BeanJsonSerializer.php to convert bean objects into JSON format, any field that contains numbers is treated as a numeric value rather than a string. This behavior leads to several problems, especially with fields that should preserve their original format.
Example Issue:
For instance, a company registration number stored as "0001234" is serialized to 1234 in the resulting JSON output. This loss of leading zeros is technically incorrect and can cause data integrity issues.
Impact:
This bug affects fields such as:
Phone numbers (which may also require leading zeros)
Company registration numbers (which need to maintain their original format)
Expected Result:
The JSON output should retain the original string format, resulting in "0001234" instead of 1234.
Modify the BeanJsonSerializer.php to ensure that any field containing numbers that should be treated as strings (i.e., those with leading zeros) is serialized correctly without losing the leading zeros. Check for data type of the original field and don't rely on PHP is_string()
Steps to Reproduce the Issue
1. Create a bean object with a text field containing leading zeros (e.g., `"0001234"`).
2. Serialize the object using `BeanJsonSerializer.php`.
3. Check the serialized JSON output to see if the leading zeros are preserved.
Context
No response
Version
8.7.1
What browser are you currently using?
Chrome
Browser Version
No response
Environment Information
MySql
Operating System and Version
Ubuntu
The text was updated successfully, but these errors were encountered:
Issue
The
BeanJsonSerializer.php
incorrectly treats numeric strings as numbers during JSON serialization. This issue arises particularly in fields containing leading zeros, such as phone and company registration numbers.Description:
When using
BeanJsonSerializer.php
to convert bean objects into JSON format, any field that contains numbers is treated as a numeric value rather than a string. This behavior leads to several problems, especially with fields that should preserve their original format.Example Issue:
"0001234"
is serialized to1234
in the resulting JSON output. This loss of leading zeros is technically incorrect and can cause data integrity issues.Impact:
Expected Result:
The JSON output should retain the original string format, resulting in
"0001234"
instead of1234
.See
SuiteCRM-Core/public/legacy/lib/Utility/BeanJsonSerializer.php
Line 145 in 582636a
or it could be using NUMERIC_CHECK
SuiteCRM-Core/public/legacy/lib/Utility/BeanJsonSerializer.php
Line 89 in 582636a
Possible Fix
Modify the
BeanJsonSerializer.php
to ensure that any field containing numbers that should be treated as strings (i.e., those with leading zeros) is serialized correctly without losing the leading zeros. Check for data type of the original field and don't rely on PHP is_string()Steps to Reproduce the Issue
Context
No response
Version
8.7.1
What browser are you currently using?
Chrome
Browser Version
No response
Environment Information
MySql
Operating System and Version
Ubuntu
The text was updated successfully, but these errors were encountered: