eisaacson
eisaacson

Reputation: 800

Magento Fatal error: include(): Cannot redeclare class varien_profiler in /lib/Varien/Autoload.php on line 93

I just copied over our files and database. Everything seems to be there with the right permissions and linked up to the right database and the right database pointing to the right path. Any ideas why I get this error?

Upvotes: 1

Views: 1878

Answers (1)

Alana Storm
Alana Storm

Reputation: 166106

That's an interesting error.

Magento Fatal error: include(): Cannot redeclare class varien_profiler in /lib/Varien/Autoload.php on line 93

It's interesting because I'd expect to see Varien_Profiler, and not `varien_profiler'. The line that's throwing this error is the last of your autoload method.

#File: lib/Varien/Autoload.php
public function autoload($class)
{
    if ($this->_collectClasses) {
        $this->_arrLoadedClasses[self::$_scope][] = $class;
    }
    if ($this->_isIncludePathDefined) {
        $classFile =  COMPILER_INCLUDE_PATH . DIRECTORY_SEPARATOR . $class;
    } else {
        $classFile = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $class)));
    }
    $classFile.= '.php';
    //echo $classFile;die();
    return include $classFile;
}

What's odd about your error is it seems like someone tried to declare/use a

varien_profiler

class. However, all the standard Magento references to this class are

Varien_Profiler

With leading word case. When you use Varien_Profiler, Magento will try to include the file

lib/Varien/Profiler.php

However, in your case, Magento should try to include the file

lib/varien/profiler.php

Which is different — and doesn't exist in a standard installation. I'm guessing you downloaded this from a heavily modified unix system — and pulled it down to a Mac or Windows system where case sensitivity isn't an issue.

All that's a long way of saying — this is an issue with your specific installation, and you'll need to debug it. The best way, as other commenters have noted, is to get a stack trace and find out where the rouge varien_profiler is coming from, and then fix it so it's Varien_Profiler. Temporarily modify the function above with the following code

if($class == 'varien_profiler')
{
    mageDebugBacktrace();
    exit;
}
return include $classFile;

This will output a simplified stack trace of files.php:line-number — something like this

[1] :
[2] /Users/alanstorm/Sites2014/magento-march2014.dev/app/Mage.php:665
[3] /Users/alanstorm/Sites2014/magento-march2014.dev/index.php:87

This should let you track down the rouge declaration.

Upvotes: 1

Related Questions