salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.38k stars 2.05k forks source link

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

Open jobst opened 2 months ago

jobst commented 2 months ago

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

johnM2401 commented 1 month ago

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!

jobst commented 1 month ago

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.

johnM2401 commented 1 month ago

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!