Division by Zero


Just came across this error and wondered if anyone knew what the solution was?

There is an error. Please report the message and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).

Warning: Division by zero in /var/www/default/piwik/core/Visualization/Cloud.php on line 59 

Backtrace -->
#0 Piwik_ErrorHandler(...) called at [/var/www/default/piwik/core/Visualization/Cloud.php:59]#1 Piwik_Visualization_Cloud->render(...) called at [/var/www/default/piwik/core/ViewDataTable/Cloud.php:112]#2 Piwik_ViewDataTable_Cloud->buildView(...) called at [/var/www/default/piwik/core/ViewDataTable/Cloud.php:71]#3 Piwik_ViewDataTable_Cloud->main(...) called at [/var/www/default/piwik/core/Controller.php:146]#4 Piwik_Controller->renderView(...) called at [/var/www/default/piwik/plugins/VisitTime/Controller.php:42]#5 Piwik_VisitTime_Controller->getVisitInformationPerServerTime(...) called at [:]#6 call_user_func_array(...) called at [/var/www/default/piwik/core/FrontController.php:136]#7 Piwik_FrontController->dispatch(...) called at [/var/www/default/piwik/index.php:53]

Thanks in advance!


I’m seeing that message also, just updated Piwik today. In my case I have a plugin that returned a table full of rows of value 0 sometimes. If you change line 59 of Cloud.php

from this:

$percent = ($popularity / $maxValue) * 100;

to this:

if ($maxValue != 0) { $percent = ($popularity / $maxValue) * 100; } else { $percent = 0; }

you will not get that error anymore.

Thanks for the report, created a bug in Division by zero in core/Visualization/Cloud.php on line 59 · Issue #2636 · matomo-org/matomo · GitHub

Thanks guys - I’m not 100% sure but it seems to be working now - I can’t honestly remember what I did tho! :frowning:

Thanks for the report - the bug is now fixed in SVN