Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#1412 closed Bug (fixed)

Fatal error: Class 'Piwik_Common' not found in ... core/Piwik.php on line 0

Reported by: fmaz Owned by:
Priority: normal Milestone: Piwik 0.6.3
Component: Core Keywords:
Cc: Sensitive: no

Description

Hi,

I just unzipped piwik on my site, then I access http://mysite.com/piwik/, and I have this error:

Fatal error: Class 'Piwik_Common' not found in /<censored>/public_html/piwik/core/Piwik.php on line 0

Things starts out pretty bad I guess.

Change History (9)

comment:1 Changed 4 years ago by vipsoft (robocoder)

  • Keywords Installation Piwik_Common removed
  • Resolution set to invalid
  • Status changed from new to closed

Please use the forum for installation support. PM me ("vipsoft") your phpinfo and a backtrace from your web server's error_log.

comment:2 Changed 4 years ago by fmaz

This is not a support issue, this is a bug: a displayed fatal error.

No matter what my php info could give, this is a bug.

Note:
I've games engines, 4 sites, many SMF forum, no problem at all.

If you need a specific information, I'll be glad to provide you with that. But for now, you should check why the file Piwik call a class that doesn't exist.

comment:3 Changed 4 years ago by vipsoft (robocoder)

I didn't say it wasn't a bug, but there's insufficient info in your bug report to debug.

I can't duplicate the error you're experiencing, and we can't PM via Trac.

If your phpinfo and backtrace, then we can begin diagnosing the root cause.

comment:4 Changed 4 years ago by fmaz

I just installed Xdebug, here is the stack trace:

( ! ) Fatal error: Class 'Piwik_Common' not found in /var/www/*/public_html/piwik/core/Piwik.php on line 0
Call Stack
# Time Memory Function Location
1 0.0000 664608 {main}( ) ../index.php:0
2 0.0200 1877728 Piwik_FrontController->init( ) ../index.php:58
3 0.0300 2584816 Piwik::checkDirectoriesWritableOrDie( ) ../FrontController.php:191
4 0.0300 2584816 Piwik::checkDirectoriesWritable( ) ../Piwik.php:49

( ! ) Fatal error: Class 'Piwik_Common' not found in /var/www/*/public_html/piwik/core/Piwik.php on line 0
Call Stack
# Time Memory Function Location
1 0.0000 664608 {main}( ) ../index.php:0
2 0.0200 1877728 Piwik_FrontController->init( ) ../index.php:58
3 0.0300 2584816 Piwik::checkDirectoriesWritableOrDie( ) ../FrontController.php:191
4 0.0300 2584816 Piwik::checkDirectoriesWritable( ) ../Piwik.php:49
5 0.0300 2600608 Piwik_FrontController->destruct( ) ../FrontController.php:0
6 0.0300 2609272 Piwik::getModule( ) ../FrontController.php:165

If you need specific information from the phpinfo, I'll be glad to provide you with that, but not the whole file.

comment:5 Changed 4 years ago by vipsoft (robocoder)

  • Priority changed from major to normal
  • Resolution invalid deleted
  • Status changed from closed to reopened

Thanks.

The root cause is that your config and tmp folders are not writeable by the web server user. Chmod/chown to resolve.

The error message appears to be a shutdown bug in your version or build of php. We can mitigate that by reordering some code in the destruct.

comment:6 Changed 4 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [2283]) fixes #1412

comment:7 Changed 4 years ago by fmaz

Isn't it possible to test the access permission with fileperms() (instead of making PHP Crash) ?
I'm running PHP 5.3.2-1.

But anyway, the error is Piwik_Common not found. If you look in your function you have static call at line 55 and 101.

Is it possible to get there without having the Piwik_Common class loaded ? (I can even figure out where the class is located...)

comment:8 Changed 4 years ago by vipsoft (robocoder)

Is the patch not working for you?

fileperms() wouldn't make a difference. The test for access permissions isn't causing the crash. I'm running php 5.3.2-1ubuntu4.2 with the Suhosin patch.

The reason you don't see a require_once for core/Common.php is because Piwik uses an autoloader. However, judging from the stacktrace, it isn't even reaching lines 55 or 101 of Piwik.php. The reference to Piwik_Common is in FrontController's destruct. If an uncaught exception occurs in a destruct, a fatal error occurs.

A number of users have reported problems with eAccelerator. You might try disabling that if you have it.

comment:9 Changed 4 years ago by fmaz

(jump to the end, solution founded)

Yes, I've the Suhosin Patch 0.9.9.1 installed.

Ok, this time I've been able to manually trace everything (by placing old-school echo everywhere), here is the result:

The line in problem is:

echo 'y';
$directory = Piwik_Common::realpath($directoryToCheck);
echo 'z';

From the checkDirectoriesWritable() method of the Piwik.php class.

While executing the line, the autoloader is called.
When an error occur, the autoloader throw an exception, but nothing catch it.
So I've changed the exception for a die(...); in the autoload method from the Loader class.

puwyPiwik_Common could not be autoloaded.abeA
Fatal error: Class 'Piwik_Common' not found in /var/www/***/public_html/piwik/core/Piwik.php on line 1151

Note: The line # is incorrect, because I've added new debug line.

Then I see the a,b,e point are executed. They're from the FrontController destruct() method:

function __destruct()
	{
		echo 'a';
		try {
			echo 'b';
			Piwik::printSqlProfilingReportZend();
			echo 'c';
			Piwik::printQueryCount();
			echo 'd';
		} catch(Exception $e) {}
		echo 'e';
		if(Piwik::getModule() !== 'API')
		{
			echo 'f';
//			Piwik::printMemoryUsage();
//			Piwik::printTimer();
		}
		echo 'g';
	}

But why no 'g' ?

So I've checked in the Piwik::getModule() method, adding new debug values, and modifying a little bit the method to be able to continue my uggly but useful debug:

	static public function getModule()
	{
		echo 'A';
		$val = Piwik_Common::getRequestVar('module', '', 'string');
		echo 'B';
		return $val;
	}

So the A is executed, but then an error appear because the Piwik_Common class have previously failed to launch.


So why does Piwik_Common is not found ?

I've dumped the $path variable instead of $class in the autoloader, and I get this:
/var/www/*/public_html/piwik/core/Common.php
/var/www/
*/public_html/piwik/libs/Common.php
/var/www/*/public_html/piwik/plugins/Common.php

And, of course, none of theses file exist...

So basically, it was a SSH upload problem, or a broken archive when I downloaded it (but I don't think so)

It would be nice if the file inclusion error were someking of accessible, as the exception is not displayed anywhere, and cause a fatal error.

Note: See TracTickets for help on using tickets.