aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-01-26 14:55:07 +0100
committerGitHub <noreply@github.com>2020-01-26 14:55:07 +0100
commitf6637392a93fb0708b7f972a22151b38795dc1e2 (patch)
tree82a95ff0db10ba3eec901f796859bf7100c9dfbf
parentc653ae3bfb11f663a52f55817e6d02a66d0852c8 (diff)
parentb495d5c92ad453baddb05c7a7763ae434f0c50ae (diff)
downloadShaarli-f6637392a93fb0708b7f972a22151b38795dc1e2.tar.gz
Shaarli-f6637392a93fb0708b7f972a22151b38795dc1e2.tar.zst
Shaarli-f6637392a93fb0708b7f972a22151b38795dc1e2.zip
Fix division by zero in tagcloud (#1411)
Fix division by zero in tagcloud
-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, '.', ''),