Bugfix: Don't crash when updating stats if no pages have any tags yet

This commit is contained in:
Starbeamrainbowlabs 2019-05-06 20:31:08 +01:00
parent c177b66b42
commit f3d797695e
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 2 additions and 1 deletions

View File

@ -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.

View File

@ -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;
}