Search code examples
phpmagentomagento-1.9php-7

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


Magneto 1.9.3 moved to new server with PHP version 7.0.23

I updated my Magento website server to a new PHP version; it's now 7.0.23, but before that it was working fine. Now it's giving me this error:

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

I tried inchoo patch for php 7 also but nothing work. https://github.com/Inchoo/Inchoo_PHP7


Solution

  • I tried the method mentioned by @cd001 in a comment:

    First I updated file app/code/core/Mage/Core/Model/Store/Group.php. In that file I just replaced the below line:

    public function setWebsite(Mage_Core_Model_Website $website)
    

    with

    public function setWebsite(Mage_Core_Model_Website $website = null)
    

    Then I got another error:

    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
    

    For that I updated the file: app/code/core/Mage/Core/Model/Layout.php. In that file, I replaced the below line:

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

    with

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

    and everything works fine now.