From 5121f1058770e22c0695255c87e331940091c60b Mon Sep 17 00:00:00 2001 From: Javier Alejandro Ruiz G <87763270+jaaruizgu@users.noreply.github.com> Date: Sun, 13 Nov 2022 07:53:54 -0500 Subject: [PATCH] Fix billing graph when the period is zero or doesn't exist, before the fix a divide by zero error was happening when the billing api was being call for an image (#14623) --- includes/billing.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/billing.php b/includes/billing.php index 4075cde5e8..c29dc5621f 100644 --- a/includes/billing.php +++ b/includes/billing.php @@ -192,9 +192,9 @@ function getRates($bill_id, $datefrom, $dateto, $dir_95th) $data['total_data'] = $mtot; $data['total_data_in'] = $mtot_in; $data['total_data_out'] = $mtot_out; - $data['rate_average'] = ($mtot / $ptot * 8); - $data['rate_average_in'] = ($mtot_in / $ptot * 8); - $data['rate_average_out'] = ($mtot_out / $ptot * 8); + $data['rate_average'] = ! empty($ptot) ? ($mtot / $ptot * 8) : 0; + $data['rate_average_in'] = ! empty($ptot) ? ($mtot_in / $ptot * 8) : 0; + $data['rate_average_out'] = ! empty($ptot) ? ($mtot_out / $ptot * 8) : 0; // print_r($data); return $data;