仅在生产时无效的块类型异常

时间:2022-08-14 21:52:41

I'm working on a project and everything is working fine on my local machine (OS x - case insensitive filesystem) but throws exception "Invalid block type" on production server (Linux - case sensitive filesystem). Problem is I think I checked all file names for proper upper/lower case.

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

Here is stack trace:

这是堆栈跟踪:

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}

Here is module configuration with layout and block: (and custom payment model is working correctly)

这是带布局和块的模块配置:(并且自定义支付模型正常工作)

<?xml version="1.0"?>
<config>
    <modules>
        <Eqush_Eqush>
            <version>0.0.1</version>
        </Eqush_Eqush>
    </modules>
    <global>
        <blocks>
            <eqush>
                <class>Eqush_Eqush_Block</class>
            </eqush>
        </blocks>
        <models>
            <eqush>
                <class>Eqush_Eqush_Model</class>
            </eqush>
        </models>
    </global>

    <default>
        <payment>
            <eqush_paypal>
                <model>eqush/paypal</model>
                <active>1</active>
                <order_status>pending</order_status>
                <title>PayPal</title>
                <sort_order>1</sort_order>
            </eqush_paypal>
        </payment>
    </default>

    <frontend>
        <layout>
            <updates>
                <eqush>
                    <file>eqush_page.xml</file>
                </eqush>
            </updates>
        </layout>
    </frontend>
</config>

Here is block code (app/code/local/Eqush/Eqush/Block/Footertop.php)

这是块代码(app / code / local / Eqush / Eqush / Block / Footertop.php)

class Eqush_Eqush_Block_Footertop extends Mage_Core_Block_Template
{}

And part of layout calling for this block: (eqush_page.xml)

并且部分布局调用此块:(eqush_page.xml)

<reference name="footerTop">
    <block type="eqush/footertop" name="eqush_footertop" template="eqush/footer-top.phtml" before="-"></block>
</reference>

I'm out of ideas. I searched a lot, but nothing helped. Everything looks fine to me.

我没有想法。我搜索了很多,但没有任何帮助。一切看起来都很好。

2 个解决方案

#1


Let's take a look at Mage_Core_Model_Layout (app/code/core/Mage/Core/Model/Layout.php) line 482:

我们来看看Mage_Core_Model_Layout(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;
}

In your stack trace, the exception is thrown at line 495, the second throwException in the method. If you look up at line 486:

在堆栈跟踪中,异常将在第495行引发,这是方法中的第二个throwException。如果你抬头看486行:

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

if $block is null, then the first throwException will be thrown. But since the second throwException is thrown, $block must NOT be an instance of Mage_Core_Block_Abstract, maybe it's a string. To debug this, either add a breakpoint at line 486 or dump $block and see what it is.

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

#2


At frist look this is absolutely correct code. Did you try clear magento_root/var/cache folder and check?

在frist看起来这是绝对正确的代码。您是否尝试过清除magento_root / var / cache文件夹并检查?

#1


Let's take a look at Mage_Core_Model_Layout (app/code/core/Mage/Core/Model/Layout.php) line 482:

我们来看看Mage_Core_Model_Layout(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;
}

In your stack trace, the exception is thrown at line 495, the second throwException in the method. If you look up at line 486:

在堆栈跟踪中,异常将在第495行引发,这是方法中的第二个throwException。如果你抬头看486行:

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

if $block is null, then the first throwException will be thrown. But since the second throwException is thrown, $block must NOT be an instance of Mage_Core_Block_Abstract, maybe it's a string. To debug this, either add a breakpoint at line 486 or dump $block and see what it is.

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

#2


At frist look this is absolutely correct code. Did you try clear magento_root/var/cache folder and check?

在frist看起来这是绝对正确的代码。您是否尝试过清除magento_root / var / cache文件夹并检查?