From f3d797695e1c9969dabb4a43b7b06cf8b5ab7865 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 6 May 2019 20:31:08 +0100 Subject: [PATCH] Bugfix: Don't crash when updating stats if no pages have any tags yet --- Changelog.md | 1 + modules/page-list.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 3e1b1d5..9acb47a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t ### Fixed - Fixed double-escaping of rendered HTML when nesting templates - Squashed a warning if the search index doesn't exist yet + - Fixed the stats updater if no pages in the system have tags yet ### Added - [Module API] Added new extra data system. See `parser-parsedown` and `page-edit` for an example. diff --git a/modules/page-list.php b/modules/page-list.php index ce856f3..a0e8e36 100644 --- a/modules/page-list.php +++ b/modules/page-list.php @@ -175,7 +175,7 @@ register_module([ $tag_counts[] = count($page_entry->tags ?? []); $result = new stdClass(); // value, state, completed - $result->value = round(array_sum($tag_counts) / count($tag_counts), 3); + $result->value = empty($tag_counts) ? -1 : round(array_sum($tag_counts) / count($tag_counts), 3); $result->completed = true; return $result; }