Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
anonymous-matomo-user opened this issue Jun 6, 2010 · 9 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@anonymous-matomo-user
Copy link

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.

@robocoder
Copy link
Contributor

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

@anonymous-matomo-user
Copy link
Author

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.

@robocoder
Copy link
Contributor

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.

@anonymous-matomo-user
Copy link
Author

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.

@robocoder
Copy link
Contributor

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.

@robocoder
Copy link
Contributor

(In [2283]) fixes #1412

@anonymous-matomo-user
Copy link
Author

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...)

@robocoder
Copy link
Contributor

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.

@anonymous-matomo-user
Copy link
Author

(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.

@anonymous-matomo-user anonymous-matomo-user added this to the Piwik 0.6.3 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants