Skip to content

Commit

Permalink
prevend div/0 - thanks @psren - fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
jadwigo committed Nov 13, 2015
1 parent 0347166 commit f2fc6c2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ function getFullTaxonomy($name = null, $taxonomy = null, $params = null) {
// return only rows with results
$populatedrows = array();
foreach($rows as $row) {
$row['weightpercent'] = ($row['count'] - $named['mincount']) / ($named['maxcount'] - $named['mincount']);
$row['weightpercent'] = 1; // everything is all
if($named['maxcount'] != $named['mincount']) { // prevent divide by zero
$row['weightpercent'] = ($row['count'] - $named['mincount']) / ($named['maxcount'] - $named['mincount']);
}
$row['weight'] = round($row['weightpercent'] * 100);

if($row['weight']<=20) {
Expand Down

0 comments on commit f2fc6c2

Please sign in to comment.