[SOLVED] PHP Fatal error: Cannot redeclare class after upgrade to 2.16.2

Yesterday I upgraded from 2.16.1 to 2.16.2

Mostly it works fine but some widgets in the dashboard show 'Oops… there was a problem during the request […]'
In the apache logfiles there is a
PHP Fatal error: Cannot redeclare class Piwik\\Plugins\\CoreVisualizations\\Visualizations\\HtmlTable in /var/www/piwik/plugins/CoreVisualizations/Visualizations/HtmlTable.php on line 23, referer: http://piwik.example.com/index.php?module=CoreHome&action=index&idSite=1&period=range&date=last30
or another widget:
[Fri Aug 05 19:22:03.828679 2016] [:error] [pid 30782] [client] PHP Fatal error: Cannot redeclare class Piwik\\Plugins\\VisitTime\\API in /var/www/piwik/plugins/VisitTime/API.php on line 0, referer: http://piwik.example.com/index.php?module=CoreHome&action=index&idSite=1&period=range&date=last30

The strange part it: it does not always happen. Usually only a few widgets show the problems. Sometimes a refresh of the page will show all widgets properly, or other widgets show an error.

Just to be sure I later removed the entire piwik folder on the webserver en unzipped a fresh copy. After replacing the config.ini.php the problem was still the same.

I restarted Apache but that did not help either.


i had the same issue and fixed it by setting always_populate_raw_post_data in the php.ini to -1


Thanks for the tip but always_populate_raw_post_data already was set to -1 (for a long time)

Does removing and readding the widgets to your dashboard solve the problem?

Nope, removing does not help. Readding was even very difficult as on mouse-over a preview is shown and that preview failed as well.
After restarting Apache all widgets work for a while so I was able to re-add. They all worked fine for a while but have started failing again.

The weirdest part remains that they work fine for a while and then start failing (but may start working again after a while without any change)

Update: I think I found a solution: xcache seems to be the problem.
Cannot redeclare class view, updating to PHP5.5 [#2066561] | Drupal.org describes a similar problem so in my “\etc\php5\mods-available\xcache.ini” is set xcache.size = 0 and restarted apache.

Since then I have not seen the ‘redeclare class’ again, Piwik is working fine.

Nevertheless it is something you might want to investigate. XCache is very common.

All problems are solved after disabling opcache in php.ini.

Hi mate

Bit of a noob here . facing the same error. Which logs do I look into . I could not find any php error logs. do they log into the sys logs ?? I have also disable opcache and rebooted server but still face the same error

I also use PHP-FPM and lighttpd

would appreciate any help.


Hi Team,

I am facing same issue as ‘Fatal error: Cannot redeclare class Smarty’ . Since, It was working fine. We did upgarde vtiger 5.4 to vtiger 6.0 then after it is apeared. We tried numerous method to figured the same error, but didnot work.


You might have declare use app/model/PhpFileName;

Then created class
class PhpFileName{


Just remove the namespace