php - 未捕获的类型错误:传递给 Mage_Core_Model_Store_Group::setWebsite() 的参数 1 必须是 Mage_Core_Model_Website 的实例,给定 null

标签 php magento magento-1.9 php-7

Magneto 1.9.3 已迁移到 PHP 版本 7.0.23 的新服务器

我将 Magento 网站服务器更新为新的 PHP 版本;现在是 7.0.23,但在此之前它工作正常。现在它给了我这个错误:

Fatal error: Uncaught TypeError: Argument 1 passed to Mage_Core_Model_Store_Group::setWebsite() must be an instance of Mage_Core_Model_Website, null given, called in

enter image description here

我也尝试了 php 7 的 inhoo patch,但没有任何效果。 https://github.com/Inchoo/Inchoo_PHP7

最佳答案

我尝试了@cd001提到的方法在评论中:

首先我更新了文件app/code/core/Mage/Core/Model/Store/Group.php。在该文件中,我刚刚替换了以下行:

public function setWebsite(Mage_Core_Model_Website $website)

public function setWebsite(Mage_Core_Model_Website $website = null)

然后我又遇到了一个错误:

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

为此,我更新了文件:app/code/core/Mage/Core/Model/Layout.php。在该文件中,我替换了以下行:

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

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

现在一切正常。

关于php - 未捕获的类型错误:传递给 Mage_Core_Model_Store_Group::setWebsite() 的参数 1 必须是 Mage_Core_Model_Website 的实例,给定 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46785667/

相关文章:

php - 如果我使用 AWS rds 作为数据库实例,是否需要在 AWS EC2 上安装 mysql?

magento - 如何使用 CentOS 在 Amazon Web Service 托管上设置 Magento?

mysql - 违反完整性约束 Magneto v1.9 向用户添加 REST 角色

mysql - 未找到基表或 View : 1146 Tablecatalog_product_entity doesn't exist

php - Magento:通过本地副本获取 "overriding"核心 config.xml 文件?这个对吗?

php - PayPal 支付总是被拒绝(沙盒)

php - civicrm的基本结构是什么?

image - Magento:在订单电子邮件中显示产品图像

php - Magento 在后端的销售发货网格中添加一列

php - 尽管代码相同,但在一台服务器上出现 SQL 错误,但在另一台服务器上却没有