PHP Fatal error: Uncaught TypeError: Unsupported operand types: string / float #5222

Open
opened 2026-02-20 16:31:37 -05:00 by deekerman · 3 comments
Owner

Originally created by @jobst on GitHub (Jul 8, 2024).

Issue

Clicking on "View Roi" within a campaign yields following PHP error

PHP Fatal error: Uncaught TypeError: Unsupported operand types: string / float in SUITECRMINSTALL/modules/Campaigns/RoiDetailView.php:163

It is a fatal error (blank page)

Possible Fix

Sorry I do not have the time in the moment

Steps to Reproduce the Issue

1.open a campaign
2.click on "View ROI" 
3.the page stays blank
4.checking PHP log shows the bug

Context

Can see ROI.

Version

7.14.4

What browser are you currently using?

Firefox

Browser Version

NOT APPLICABLE

Environment Information

mysqld Ver 8.0.36, PHP 8.2

Operating System and Version

Alma 8.10

Originally created by @jobst on GitHub (Jul 8, 2024). ### Issue Clicking on "View Roi" within a campaign yields following PHP error ` PHP Fatal error: Uncaught TypeError: Unsupported operand types: string / float in SUITECRMINSTALL/modules/Campaigns/RoiDetailView.php:163 ` It is a fatal error (blank page) ### Possible Fix Sorry I do not have the time in the moment ### Steps to Reproduce the Issue ```bash 1.open a campaign 2.click on "View ROI" 3.the page stays blank 4.checking PHP log shows the bug ``` ### Context Can see ROI. ### Version 7.14.4 ### What browser are you currently using? Firefox ### Browser Version NOT APPLICABLE ### Environment Information mysqld Ver 8.0.36, PHP 8.2 ### Operating System and Version Alma 8.10
Author
Owner

@johnM2401 commented on GitHub (Jul 10, 2024):

Hey @jobst !
Thank you for being in touch and raising this!

I've given this a try on a local environment, but I'm afraid I'm not able to replicate as of yet.

I've created and sent a test campaign, with click-through events registered
I then access its "View ROI" page, and it renders:
image

This environment is:
PHP8.2.11 / Mysql8 / SuiteCRM 7.14.4 / Firefox 113.02


Have I perhaps missed any pertinent information that might help replicate?
ie:
Does this happen for a specific Campaign Type, or when certain actions/results are performed for a Campaign?
Does this happen when you enter specific values in the campaign's "Actual Cost" field? (ie: Custom Currencies / text values e/etc)

Thanks again!

@johnM2401 commented on GitHub (Jul 10, 2024): Hey @jobst ! Thank you for being in touch and raising this! I've given this a try on a local environment, but I'm afraid I'm not able to replicate as of yet. I've created and sent a test campaign, with click-through events registered I then access its "View ROI" page, and it renders: ![image](https://github.com/salesagility/SuiteCRM/assets/13675281/2b153e48-b462-4389-b2e1-cebc3d2d03e1) This environment is: PHP8.2.11 / Mysql8 / SuiteCRM 7.14.4 / Firefox 113.02 <br> Have I perhaps missed any pertinent information that might help replicate? ie: Does this happen for a specific Campaign Type, or when certain actions/results are performed for a Campaign? Does this happen when you enter specific values in the campaign's "Actual Cost" field? (ie: Custom Currencies / text values e/etc) Thanks again!
Author
Owner

@jobst commented on GitHub (Jul 11, 2024):

Ok, I looked at the code, the error has to do what INPUT of the fields is provided.

The code clearly checks for the LINKS to be greater ZERO to omit division by zero.
However it does NOT check the inputs for a VALID number like !empty or "q" (i.e. MUST be a number and NOT empty).

For this (and many other) campaigns we did not place "actual costs" which leads to a FATAL error when using PHP8,2.

Looking at other places in the code of RoiDetailView.php I see there are other spots where the input is not checked or not given a default value like "0" (zero).

For a person like me I can figure this out but IMHO a normal user should get a "you cant do that" and not a blank page.

@jobst commented on GitHub (Jul 11, 2024): Ok, I looked at the code, the error has to do what INPUT of the fields is provided. The code clearly checks for the LINKS to be greater ZERO to omit division by zero. However it does NOT check the inputs for a VALID number like !empty or "q" (i.e. MUST be a number and NOT empty). For this (and many other) campaigns we did not place "actual costs" which leads to a FATAL error when using PHP8,2. Looking at other places in the code of RoiDetailView.php I see there are other spots where the input is not checked or not given a default value like "0" (zero). For a person like me I can figure this out but IMHO a normal user should get a "you cant do that" and not a blank page.
Author
Owner

@johnM2401 commented on GitHub (Jul 15, 2024):

Hey @jobst !
Thank you for that additional information.

Interestingly, I'm unable to replicate when either either text or empty values, (ie: don't touch the fields at all), into the fields when creating a Campaign.

However, if I set the values to "null" in the db directly, I can indeed replicate the whitescreen error.

I'll mark this with a priority now that I can confirm.

Thank you again for your issue and your time!

@johnM2401 commented on GitHub (Jul 15, 2024): Hey @jobst ! Thank you for that additional information. Interestingly, I'm unable to replicate when either either text or empty values, (ie: don't touch the fields at all), into the fields when creating a Campaign. However, if I set the values to "null" in the db directly, I can indeed replicate the whitescreen error. I'll mark this with a priority now that I can confirm. Thank you again for your issue and your time!
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#5222
No description provided.