我有一个托管在1&1上的Magento 1.6.2网站。 由于某些已安装的扩展,我必须支持 PHP 版本 5.3,但遗憾的是 1&1 的可用选项是 PHP 5.2 或他们称之为 PHP Dev 的东西。 快速phpinfo()
显示这实际上是 PHP 5.4。
我的问题是,当我设置为 5.4 时,后端的"类别"页面会引发 500 错误。 回滚到 5.2 可以解决此问题,但这会破坏我的产品页面。 在短期内,我可以处理必须在它们之间交换,但是当网站交给客户时,这对于长期解决方案来说显然是不可接受的。
谁能建议这种不兼容可能在哪里,以及我可以采取哪些步骤来解决它? 我最大的障碍是托管在共享服务器上,因此我不允许查看Apache日志。
更新:
根据CCBlackburn在评论中的建议,我试图跟踪错误的来源点,但我不得不承认我并不真正了解我得到的结果。 类别页面的 URL 如下所示:
example.com/index.php/admin/catalog_category/index/key/blahblah
我以为Mage_Adminhtml_CatalogController
将是开始查找的地方,但是作为indexAction()
第一行的Mage::log()
调用未能写入日志。
我决定向上移动继承并切入构造函数,因此将以下内容添加到Mage_Adminhtml_Controller_Action
:
function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array()) {
Mage::log('construct pre');
parent::__construct($request,$response,$invokeArgs);
Mage::log('construct post');
}
这更好,因为第一个日志调用写入文件,但第二个没有。
接下来,我再次向上移动继承,并修改了Mage_Core_Controller_Varien_Action
的构造函数,如下所示:
public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
{
Mage::log('request: '.$request);
$this->_request = $request;
Mage::log('response: '.$response);
$this->_response= $response;
Mage::log('pre set action');
Mage::app()->getFrontController()->setAction($this);
Mage::log('post set action');
$this->_construct();
}
问题是这些日志调用都不执行任何操作。 这让我感到困惑,因为肯定从Mage_Adminhtml_Controller_Action
调用parent::__construct();
应该在执行任何操作之前至少再执行一次日志调用。 除非传入值存在问题,但我不知道如何检查/调试?
我在 Google Chrome 和 Apple Safari 的 OSX Lion 下遇到了同样的问题,使用 Magento 1.7 和 PHP 5.4。突然间,Magento类别管理员开始给出500个错误,我不知道发生了什么。这似乎是 PHP 5.4 的问题。起初我以为是XDebug导致了这个错误。然后我禁用了XDebug,问题仍然存在。它与火狐一起工作比奇怪更奇怪!
我的解决方案是降级到最新的 PHP 5.3,但是现在已经从 PHP 5.4.3 开始修复。