Magento 致命错误:include():无法在第 93 行的 /lib/Varien/Autoload.php 中


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

我刚刚复制了我们的文件和数据库。一切似乎都有正确的权限,并链接到正确的数据库和指向正确路径的正确数据库。知道为什么我会收到此错误吗?

这是一个有趣的错误。

Magento 致命错误:include():无法在第 93 行的/lib/Varien/Autoload.php 中重新声明类 varien_profiler

这很有趣,因为我希望看到Varien_Profiler,而不是"varien_profiler"。 引发此错误的行是自动加载方法的最后一行。

#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;
}

你的错误奇怪的是,似乎有人试图声明/使用

varien_profiler

.class。 但是,对此类的所有标准Magento引用都是

Varien_Profiler

带前导词大小写。 当您使用Varien_Profiler时,Magento将尝试包含该文件

lib/Varien/Profiler.php

但是,在您的情况下,Magento应该尝试包含该文件

lib/varien/profiler.php

这是不同的 - 并且在标准安装中不存在。 我猜你从一个经过大量修改的Unix系统下载了这个 - 并将其拉到Mac或Windows系统中,其中区分大小写不是问题。

说来话长

- 这是您的特定安装的问题,您需要对其进行调试。 正如其他评论者所指出的那样,最好的方法是获取堆栈跟踪并找出胭脂varien_profiler的来源,然后修复它以便Varien_Profiler . 使用以下代码临时修改上面的函数

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

这将输出文件的简化堆栈跟踪.php:行号 — 如下所示

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

这应该可以让您追踪胭脂声明。