cubecart / v6

CubeCart Version 6
https://cubecart.com
73 stars 57 forks source link

Code Check: Reusing Changed Variable Type #3601

Closed bhsmither closed 5 months ago

bhsmither commented 5 months ago

With respect to #3506:

In statistics.index.inc.php, near line 281, there is:

$divider = (float)$divider[0]['total_sales'];

This is inside a foreach() loop.

This means that $divider no longer exists as an array after the first iteration.

Suggest near line 282:

$result['percent'] = (float)$divider[0]['total_sales'] ? number_format(100*($result['customer_expenditure']/$divider[0]['total_sales']), 2) : 0;

and delete line 281.

Relating to the comments in #3506, typecasting the test expression to a float will result false-like when the database result 'total_sales' is the string "0.00".

abrookbanks commented 5 months ago

Thanks Brian!