簡體   English   中英

僅在生產中無效的塊類型異常

[英]Invalid block type exception on production only

我正在開發一個項目,並且在本地計算機(OS x-不區分大小寫的文件系統)上一切正常,但是在生產服務器(Linux-區分大小寫的文件系統)上拋出異常“ Invalid block type”。 問題是我認為我檢查了所有文件名的大小寫是否正確。

這是堆棧跟蹤:

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}

這是帶有布局和塊的模塊配置:(並且自定義付款模型正常運行)

<?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>

這是塊代碼(app / code / local / Eqush / Eqush / Block / Footertop.php)

class Eqush_Eqush_Block_Footertop extends Mage_Core_Block_Template
{}

以及部分布局需要此代碼塊:(eqush_page.xml)

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

我沒主意了。 我搜索了很多,但沒有任何幫助。 對我來說一切都很好。

讓我們看一下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;
}

在您的堆棧跟蹤中,異常在第495行拋出,這是方法中的第二個throwException。 如果您查看第486行:

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

如果$ block為null,則將引發第一個throwException。 但是由於拋出了第二個throwException,所以$ block一定不能是Mage_Core_Block_Abstract的實例,也許是字符串。 要調試它,請在第486行添加一個斷點或轉儲$ block看看它是什么。

乍看之下,這絕對是正確的代碼。 您是否嘗試清除過magento_root / var / cache文件夾並檢查?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM