cubecart / v6

CubeCart Version 6
https://cubecart.com
71 stars 58 forks source link

Code Check: Reusing Changed Variable Type #3601

Closed bhsmither closed 1 month ago

bhsmither commented 1 month 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 1 month ago

Thanks Brian!