From 906024f45bebc1ab7e98a1a79d864b0dc1c9d6bc Mon Sep 17 00:00:00 2001 From: VeekeeFr <20480977+VeekeeFr@users.noreply.github.com> Date: Fri, 12 Oct 2018 01:52:26 +0200 Subject: [PATCH 1/2] Fixed rare case of division by 0 --- app/Http/Controllers/StatusPageController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/StatusPageController.php b/app/Http/Controllers/StatusPageController.php index 409e6372..81c0129d 100644 --- a/app/Http/Controllers/StatusPageController.php +++ b/app/Http/Controllers/StatusPageController.php @@ -74,7 +74,11 @@ class StatusPageController extends AbstractApiController ->values(); $numIncidentDays = count($allIncidentDays); - $numPages = round($numIncidentDays / $appIncidentDays); + if ($appIncidentDays > 0) { + $numPages = round($numIncidentDays / $appIncidentDays); + } else { + $numPages = 1; + } $selectedDays = $allIncidentDays->slice($page * $appIncidentDays, $appIncidentDays)->all(); From 28ca20f99fe37510a8a334c199afe4379e8e550f Mon Sep 17 00:00:00 2001 From: VeekeeFr <20480977+VeekeeFr@users.noreply.github.com> Date: Mon, 15 Oct 2018 18:29:12 +0200 Subject: [PATCH 2/2] Applying @jbrooksuk implementation (see MR 3273) --- app/Http/Controllers/StatusPageController.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/Http/Controllers/StatusPageController.php b/app/Http/Controllers/StatusPageController.php index 81c0129d..87ced74b 100644 --- a/app/Http/Controllers/StatusPageController.php +++ b/app/Http/Controllers/StatusPageController.php @@ -74,11 +74,7 @@ class StatusPageController extends AbstractApiController ->values(); $numIncidentDays = count($allIncidentDays); - if ($appIncidentDays > 0) { - $numPages = round($numIncidentDays / $appIncidentDays); - } else { - $numPages = 1; - } + $numPages = round($numIncidentDays / max($appIncidentDays, 1)); $selectedDays = $allIncidentDays->slice($page * $appIncidentDays, $appIncidentDays)->all();