繁体   English   中英

Magento 1.7:SUPEE-10975 安全补丁后的严格通知警告

[英]Magento 1.7: Strict Notice warning after SUPEE-10975 security patch

在 Magento 1.7.0.2 中安装 SUPEE-10975 后,我收到此 PHP 通知:

Strict Notice: Declaration of Mage_Core_Controller_Request_Http::getBaseUrl() should be compatible with that of Zend_Controller_Request_Http::getBaseUrl()  in app/code/core/Mage/Core/Controller/Request/Http.php on line 36

#0 app/code/core/Mage/Core/Controller/Request/Http.php(36): mageCoreErrorHandler(2048, 'Declaration of ...', '/kunden/12345_8...', 36, Array)
#1 lib/Varien/Autoload.php(93): include('/kunden/12345_8...')
#2 [internal function]: Varien_Autoload->autoload('Mage_Core_Contr...')
#3 app/code/core/Mage/Core/Model/App.php(1219): spl_autoload_call('Mage_Core_Contr...')
#4 app/code/core/Mage/Core/Model/Cookie.php(83): Mage_Core_Model_App->getRequest()
#5 app/code/core/Mage/Core/Model/Cookie.php(273): Mage_Core_Model_Cookie->_getRequest()
#6 app/code/core/Mage/Core/Model/App.php(568): Mage_Core_Model_Cookie->get()
#7 app/code/core/Mage/Core/Model/App.php(488): Mage_Core_Model_App->_checkCookieStore('website')
#8 app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Model_App->_initCurrentStore('', 'store')
#9 app/Mage.php(683): Mage_Core_Model_App->run(Array)
#10 index.php(87): Mage::run('', 'store')
#11 {main}

似乎代码在我的安装中可用两次:

  • app/code/core/Zend/Controller/Request/Http.php => 与 SUPEE-10975 一起引入
  • lib/Zend/Controller/Request/Http.php => Magento 1.7.0.2基础安装包中可用

这是 SUPEE-10975 的回归还是我的安装问题?

更新:SUPEE-11219 似乎解决了这个问题,所以在应用 11219 补丁后,我下面的修复可能会被删除

原答案:

我见过同样的问题,它看起来像是 1.7 版 SUPEE-10975 补丁中的回归。

更改您的 PHP 配置以抑制严格模式通知将使您工作,但如果您更喜欢在严格模式下工作,也有一种方法可以修补补丁。

正如您所观察到的,SUPEE-10975 添加了一个新的Mage_Core_Controller_Request_Http类,它扩展了新捆绑的 Zend 类Zend_Controller_Request_Http ,位于新文件app/code/core/Zend/Controller/Request/Http.php

发出严格模式通知是因为Mage_Core_Controller_Request_Http::getBaseUrl()方法签名与它扩展的新Zend_Controller_Request_Http::getBaseUrl()方法签名不正确匹配。

Mage_Core_Controller_Request_Http::getBaseUrl()

class Mage_Core_Controller_Request_Http extends Zend_Controller_Request_Http
...
public function getBaseUrl() //getBaseUrl has no parameters here
{
    ...
}

Zend_Controller_Request_Http::getBaseUrl()

class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract
...
public function getBaseUrl($raw = false) //getBaseUrl in the ancestor class has the parameter $raw
{
    ...
}

Mage_Core_Controller_Request_Http::getBaseUrl()方法应该有一个参数$raw以避免严格模式通知。 这不是一个真正的错误,PHP 可以解决它,但理想情况下应该更正。

重新出发

在 PHP 配置中抑制严格模式通知允许代码在忽略此错误的情况下运行,但如果代码可以在严格模式下运行会更好,不是吗?

这是修复它的方法,以便它以严格模式运行

app/code/core/Mage/Core/Controller/Request/Http.php到本地代码池: app/code/local/Mage/Core/Controller/Request/Http.php (注意我们正在创建一个在本地文件夹中覆盖)

编辑app/code/local/Mage/Core/Controller/Request/Http.php并将行号 265 从

public function getBaseUrl()

public function getBaseUrl($raw = false)

如果您的代码已编译,并且编译器运行时没有出错,您可能需要清除编译版本以查看更改。 从 Magento 的 webroot 发出命令php shell/compiler.php clear

商店现在应该正常运行,并应用了 SUPEE-10975 补丁。

这是做什么的

我们在本地代码文件夹中创建了一个核心 Magento 文件的副本,Magento 会在使用核心文件之前尝试文件的本地副本,因此这个本地副本会覆盖原始文件。

我们对文件的编辑,使 getBaseUrl 的方法签名与祖先类匹配,抑制了严格模式通知。

这样做是可以的,因为无论如何 Magento 1.7 代码都没有使用$raw参数,并且该方法的默认行为将与没有参数时完全相同。

要撤消此更改,只需删除我们刚刚创建的本地副本app/code/local/Mage/Core/Controller/Request/Http.php Magento 将自动返回使用核心文件,尽管有严格模式通知。

唯一的问题是...

我们正在创造技术债务

下一次安全补丁或升级发生时,如果原始文件被更改,我们制作的本地副本将不会被修补或更新。 您需要检查是否仍需要进行此更改,如果需要,请将核心文件重新复制到本地文件夹,并按上述方法重新修补文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM