Php 仅在生产上出现无效的块类型异常

Php 仅在生产上出现无效的块类型异常,php,xml,magento,exception,configuration,Php,Xml,Magento,Exception,Configuration,我正在做一个项目,在我的本地机器(OSX-不区分大小写的文件系统)上一切正常,但在生产服务器(Linux-区分大小写的文件系统)上抛出异常“无效块类型”。问题是我想我检查了所有文件名的大小写是否正确 下面是堆栈跟踪: exception 'Mage_Core_Exception' with message 'Invalid block type: Eqush_Eqush_Block_Footertop' in /www/eqush/app/Mage.php:595 Stack trace: #0

我正在做一个项目,在我的本地机器(OSX-不区分大小写的文件系统)上一切正常,但在生产服务器(Linux-区分大小写的文件系统)上抛出异常“无效块类型”。问题是我想我检查了所有文件名的大小写是否正确

下面是堆栈跟踪:

exception 'Mage_Core_Exception' with message 'Invalid block type: Eqush_Eqush_Block_Footertop' in /www/eqush/app/Mage.php:595
Stack trace:
#0 /www/eqush/app/code/core/Mage/Core/Model/Layout.php(495): Mage::throwException('Invalid block t...')
#1 /www/eqush/app/code/core/Mage/Core/Model/Layout.php(437): Mage_Core_Model_Layout->_getBlockInstance('eqush/footertop', Array)
#2 /www/eqush/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('eqush/footertop', 'eqush_footertop')
#3 /www/eqush/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('eqush/footertop', 'eqush_footertop')
#4 /www/eqush/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#5 /www/eqush/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#6 /www/eqush/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#7 /www/eqush/app/code/core/Mage/Catalog/controllers/CategoryController.php(148): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#8 /www/eqush/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Catalog_CategoryController->viewAction()
#9 /www/eqush/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view')
#10 /www/eqush/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 /www/eqush/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#12 /www/eqush/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#13 /www/eqush/index.php(87): Mage::run('', 'store')
#14 {main}
下面是模块配置,包括布局和块:(自定义支付模型工作正常)

以及调用此块的部分布局:(eqsh_page.xml)



我没有主意了。我找了很多,但都没找到。我觉得一切都很好。

第一次看,这是绝对正确的代码。您是否尝试清除magento_root/var/cache文件夹并选中?

让我们看看Mage_Core_Model_布局(app/code/Core/Mage/Core/Model/Layout.php)第482行:

protected function _getBlockInstance($block, array $attributes=array())
{
    if (is_string($block)) {
        if (strpos($block, '/')!==false) {
            if (!$block = Mage::getConfig()->getBlockClassName($block)) {
                Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block));
            }
        }
        if (class_exists($block, false) || mageFindClassFile($block)) {
            $block = new $block($attributes);
        }
    }
    if (!$block instanceof Mage_Core_Block_Abstract) {
        Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block));
    }
    return $block;
}
在堆栈跟踪中,异常在第495行抛出,该行是方法中的第二个ThroweException。如果您查看第486行:

if (!$block = Mage::getConfig()->getBlockClassName($block)) {

如果$block为null,则将抛出first throwException。但是由于抛出了第二个throwException,$block不能是Mage_Core_block_Abstract的实例,可能是字符串。要调试它,可以在第486行添加一个断点,或者转储$block并查看它是什么。

不幸的是,我尝试了,但没有帮助。我通过命令行删除了缓存文件。你说得对。我在第494行之前转储了$block,它是字符串(27)“eqsh\u eqsh\u block\u Footertop”。我现在想弄清楚原因。查看之前的代码,必须知道类_exists返回false,而mageFindClassFile也返回false。为什么它在我的本地环境中不这样做?现在看一下,你的回答让我意识到所有配置都是正确的,并且我检查了唯一一件我以前没有想到的事情。文件的权限不正确。我现在觉得自己很笨。谢谢你让我睁开眼睛,教我深入研究代码。
<reference name="footerTop">
    <block type="eqush/footertop" name="eqush_footertop" template="eqush/footer-top.phtml" before="-"></block>
</reference>
protected function _getBlockInstance($block, array $attributes=array())
{
    if (is_string($block)) {
        if (strpos($block, '/')!==false) {
            if (!$block = Mage::getConfig()->getBlockClassName($block)) {
                Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block));
            }
        }
        if (class_exists($block, false) || mageFindClassFile($block)) {
            $block = new $block($attributes);
        }
    }
    if (!$block instanceof Mage_Core_Block_Abstract) {
        Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block));
    }
    return $block;
}
if (!$block = Mage::getConfig()->getBlockClassName($block)) {