致命错误:未捕获的TypeError:参数1传递给Mage_Core_Model_Design_Package :: getPackageByUserAgent()

时间:2019-10-18 14:20:12

标签: magento-1.9 php-7

将magento 1.9安装从旧服务器移到新服务器后,出现500错误。旧服务器正在运行php5,而这是在7上。我现在遇到以下错误,我知道我必须更改一些代码,但是我不确定是什么:

  

致命错误:未捕获的类型错误:传递给Mage_Core_Model_Design_Package :: getPackageByUserAgent()的参数1必须为数组类型,给定对象,在/home1/acapps/flagstuff.com/app/code/core/Mage/Core/中调用第576行上的Model / Design / Package.php,在/home1/acapps/flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php:586中定义:堆栈跟踪:#0 / home1 / acapps /flagstuff.com/app/code/core/Mage/Core/Model/Design/Package.php(576):Mage_Core_Model_Design_Package :: getPackageByUserAgent(Object(Zend_Log),'design / theme / te ...')#1 / home1 / acapps / flagstuff.com / app / code / core / Mage / Core / Model / Design / Package.php(262):Mage_Core_Model_Design_Package-> _ checkUserAgentAgainstRegexps('design / theme / te ...')#2 / home1 / acapps / flagstuff.com / app / code / core / Mage / Core / Model / Design / Package.php(287):Mage_Core_Model_Design_Package-> getTheme('template')#3 /home1/acapps/flagstuff.com/app/code /core/Mage/Core/Model/Design/Package.php(420):Mage_Core_Model_Design_Package-> updateParamDefaults(Array)#4 / 586行上的home1 / acapps / flagstuff.com / app / code / core / home1 / acapps / flagstuff.com / app / code / core / Mage / Core / Model / Design / Package.php

这是从Package.php的586行开始的代码

public static function getPackageByUserAgent(array $rules, $regexpsConfigPath = 'path_mock')

{
        foreach ($rules as $rule) {

            if (!empty(self::$_regexMatchCache[$rule['regexp']][$_SERVER['HTTP_USER_AGENT']])) {

                self::$_customThemeTypeCache[$regexpsConfigPath] = $rule['value'];

                return $rule['value'];

            }

            $regexp = '/' . trim($rule['regexp'], '/') . '/';

            if (@preg_match($regexp, $_SERVER['HTTP_USER_AGENT'])) {
                self::$_regexMatchCache[$rule['regexp']][$_SERVER['HTTP_USER_AGENT']] = true;

                self::$_customThemeTypeCache[$regexpsConfigPath] = $rule['value'];
                return $rule['value'];
            }
        }

        return false;
    }

1 个答案:

答案 0 :(得分:0)

原来,我需要更改此内容:

public static function getPackageByUserAgent(array $rules, $regexpsConfigPath = 'path_mock')

对此

public static function getPackageByUserAgent($rules, $regexpsConfigPath = 'path_mock')

在那之后,它就像一个魅力