aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-01-26 14:52:10 +0100
committerArthurHoaro <arthur@hoa.ro>2020-01-26 14:52:10 +0100
commitb495d5c92ad453baddb05c7a7763ae434f0c50ae (patch)
tree82a95ff0db10ba3eec901f796859bf7100c9dfbf
parentc653ae3bfb11f663a52f55817e6d02a66d0852c8 (diff)
downloadShaarli-b495d5c92ad453baddb05c7a7763ae434f0c50ae.tar.gz
Shaarli-b495d5c92ad453baddb05c7a7763ae434f0c50ae.tar.zst
Shaarli-b495d5c92ad453baddb05c7a7763ae434f0c50ae.zip
Fix division by zero in tagcloud
It happens if we have a maximum of 1 occurrence in tags (log(1) = 0)
-rw-r--r--index.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/index.php b/index.php
index 474d9af5..b53b16fe 100644
--- a/index.php
+++ b/index.php
@@ -659,6 +659,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
659 659
660 alphabetical_sort($tags, false, true); 660 alphabetical_sort($tags, false, true);
661 661
662 $logMaxCount = $maxcount > 1 ? log($maxcount, 30) : 1;
662 $tagList = array(); 663 $tagList = array();
663 foreach ($tags as $key => $value) { 664 foreach ($tags as $key => $value) {
664 if (in_array($key, $filteringTags)) { 665 if (in_array($key, $filteringTags)) {
@@ -666,8 +667,8 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM
666 } 667 }
667 // Tag font size scaling: 668 // Tag font size scaling:
668 // default 15 and 30 logarithm bases affect scaling, 669 // default 15 and 30 logarithm bases affect scaling,
669 // 22 and 6 are arbitrary font sizes for max and min sizes. 670 // 2.2 and 0.8 are arbitrary font sizes in em.
670 $size = log($value, 15) / log($maxcount, 30) * 2.2 + 0.8; 671 $size = log($value, 15) / $logMaxCount * 2.2 + 0.8;
671 $tagList[$key] = array( 672 $tagList[$key] = array(
672 'count' => $value, 673 'count' => $value,
673 'size' => number_format($size, 2, '.', ''), 674 'size' => number_format($size, 2, '.', ''),