Magento1.9.4不使用PHP7运行,它显示错误如下:

Fatal error: Uncaught Error: Function name must be a string in 
app\code\core\Mage\Core\Model\Layout.php:555 Stack trace: #0 
app\code\core\Mage\Core\Controller\Varien\Action.php(390): Mage_Core_Model_Layout->getOutput() #1 
app\code\core\Mage\Cms\Helper\Page.php(137): Mage_Core_Controller_Varien_Action->renderLayout() #2 
app\code\core\Mage\Cms\Helper\Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home') #3 
app\code\core\Mage\Cms\controllers\IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home') #4 
app\code\core\Mage\Core\Controller\Varien\Action.php(418): Mage_Cms_IndexController->indexAction() #5 
app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index') #6 
app\code\core\Mage\Core\Model\Layout.php on line 555
有帮助吗?

解决方案

它发生是因为在 PHP 7 你需要澄清你要打电话给 $callback 变量作为方法(函数)。所以,代码的原始行看起来如下所示(文件 app/code/core/Mage/Core/Model/Layout.php):

$out .= $this->getBlock($callback[0])->$callback[1]();

为了使它在最新的PHP版本上工作,我们需要用这个代码替换这段代码:

$out .= $this->getBlock($callback[0])->{$callback[1]}();

参考 这个博客 有关更多资料。

其他提示

如果您想在PHP7上运行Magento 1.x网站,您需要在某些Magento 1.x文件中进行一些小调整,以使其在没有任何问题的情况下工作。

大多数Magento代码在PHP 7中仍然有效,以下几乎没有列出的不兼容:

1。统一变量语法问题:

1.1应用/代码/核心/ mage / mage / model / model / layout.php:555

此文件导致Magento崩溃的原因和致命错误。覆盖文件和 替换

$out .= $this->getBlock($callback[0])->$callback[1]();
.

$out .= $this->getBlock($callback[0])->{$callback[1]}();
.

1.2 app \ code \ core \ mage \ mage \ importexport \ model \ import \ uploader.php:135

此文件效果magento csv进口商。覆盖文件,然后覆盖_validatefile()函数并替换第135行 替换

$params['object']->$params['method']($filePath);
.

$params['object']->{$params['method']}($filePath);
.

1.3应用程序\ code \ core \ mage \ mage \ importexport \ model \ export \ entity \ product \ type \ abstract.php:99

这个问题效果magento的出口功能。 Magento从上面的抽象类中延伸了三个类,所以下面的误差的根本原因是上面类中的行#99。

mage_importexport_model_export_entity_product_type_configureable mage_importexport_model_export_entity_product_type_grouped. mage_importexport_model_export_entity_product_type_simple

我们需要在本地代码池中覆盖三个类并覆盖覆盖覆盖()函数,替换行#99

$data['filter_options'] = $this->$data['options_method']();
.

$data['filter_options'] = $this->{$data['options_method']}();
.

1.4 app \ code \ core \ mage \ mage \ importexport \ model \ export \ entity \ customer.php:250

此文件效果导出客户功能。覆盖上面的文件并更改行#250,如下所示

$data['filter_options'] = $this->$data['options_method']();
.

$data['filter_options'] = $this->{$data['options_method']}();
.

1.5 lib \ varien \ file \ uploader.php:259

文件上传将无法正常工作。 Magento将Mage_core_model_file_uploader从上面类扩展,因此我们需要覆盖此类并重写_validatefile()函数替换以下行

$params['object']->$params['method']($this->_file['tmp_name']);
.

$params['object']->{$params['method']}($this->_file['tmp_name']);
.

2。类型铸造问题

2.1 app \ code \ core \ mage \ core \ model \ model \ resource \ session.php:218

magento会话不适用于php 7,因此,结果用户登录不起作用。 读取($ sessid)函数应返回一个字符串,使返回变量如下:

return $data;
.

return (string)$data;
.

3。不正确的总总计

由于错误排序的小计,折扣,运输等原因,总计不正确 通过创建扩展来更正排序顺序,并在extension的config.xml中放置以下代码

<global>
    <sales>
        <quote>
            <totals>
                <msrp>
                    <before>grand_total</before>
                </msrp>
                <shipping>
                    <after>subtotal,freeshipping,tax_subtotal,msrp</after>
                </shipping>
            </totals>
        </quote>
    </sales>
</global>
.

以下是我在上面发布的原始引用: http://scriptbaker.com/tag/magento-1-9/

如果您无法在代码中找到任何查询,那么Magento将涵盖,正如我之前所说的那样,大多数代码都有效,因此您可能只是忽略它。我相信这一切都可以回答你的问题。

许可以下: CC-BY-SA归因
scroll top