我需要将我的服务器升级到 PHP 5.3,但安装了 Magento,而且我知道 Magento 不能很好地与 PHP 5.3 配合使用。
我认为这些变化不会太大(从我读过的内容来看)。但是,我想我会向 SO 人群开放它。
有没有人成功做到这一点?如果是这样,你有没有记好笔记?
为了在 PHP 5.3 上运行 Magento 1.3.x,您需要从相应的文件中替换以下函数:
1> 索引.php
error_reporting(E_ALL | E_STRICT);
至
error_reporting(E_ALL & E_STRICT & ~E_DEPRECATED);
2> 库/变量/Object.php
__toString
至
__invoke
3> lib/Varien/Pear.php
error_reporting(E_ALL & ~E_NOTICE);
至
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
4> 下载器/Maged/Pear.php
error_reporting(E_ALL & ~E_NOTICE);
至
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
5> app\code\core\Mage\Catalog\Model\Layer\Filter\Price.php
__toString
至
__invoke
6> app\code\core\Mage\Core\Controller\Request\Http.php
split
至
explode
7> app\code\core\Mage\Catalog\Model\Category\Attribute\Backend\Sortby.php
split
至
explode
8> 应用程序\代码\核心\法师\管理员\模型\用户.php
split
至
explode
对于只想打补丁的终端用户,我建议使用以下文章: http: //goivvy.com/blog/magento1.3fix/
您可以从以下 Magento 博客获取更多信息:http:
//www.blog.magepsycho.com/how-to-run-magento-1-3-x-on-php-5-3/
希望这可以帮助。
2行代码,但升级不安全....生产服务器无论如何都不应该运行最新版本,我永远不会在生产服务器上升级...测试版或测试确定。__toString -> __invoke 和一个拆分 -> 爆炸
重新 nic28 的解决方案:在 1.3.3.0 Magento 安装上,我还需要在 app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php 中执行 __toString 到 __invoke 更改,第 139 行:
$key=.=taxReq->__toString(array(), '_');
好吧,如果你决定用 PHP 5.3 运行 Magento,这里是如何做到的(用 1.3.2.3 版本测试):
1:在 index.php 中,第 35 行左右,替换
error_reporting(E_ALL | E_STRICT);
和
error_reporting((E_ALL | E_STRICT) & !E_DEPRECATED)
(原因:Magento 经常使用 split 函数,在 PHP 5.3 中已弃用)
2:在 /lib/Varien/Object.php 中,大约第 484 行更改
public function ___toString(array $arrAttributes = array(), $valueSeparator=',')
至
public function __invoke(array $arrAttributes = array(), $valueSeparator=',')
(原因:我真的不知道,但它有效!)
我发现了一长串使用 split 功能的文件。需要用explode替换。只需更改函数名称即可。此列表添加到 MagePsycho 上面发布的内容。下载器文件夹可能包含更多文件,我使用的搜索在第一行。
Search "\bspliti?\(" (68 hits in 54 files)
E:\magento\shop\app\code\core\Mage\Adminhtml\controllers\System\ConfigController.php (1 hits)
Line 155: foreach(split("\n", $e->getMessage()) as $message) {
E:\magento\shop\app\code\core\Mage\Adminhtml\Model\Observer.php (1 hits)
Line 63: $value = is_array($request->getPost($key)) ? $request->getPost($key) : split(',', $request->getPost($key));
E:\magento\shop\app\code\core\Mage\Adminhtml\Model\System\Config\Backend\Currency\Abstract.php (2 hits)
Line 47: return split(',', Mage::getConfig()->getNode('currency/options/allow', $this->getScope(), $this->getScopeId()));
Line 59: return split(',', Mage::getStoreConfig('system/currency/installed'));
E:\magento\shop\app\code\core\Mage\Adminhtml\Model\System\Config\Backend\Locale.php (1 hits)
Line 49: $values = split(',', $this->getValue());
E:\magento\shop\app\code\core\Mage\Bundle\sql\bundle_setup\mysql4-install-0.1.0.php (1 hits)
Line 162: $applyTo = split(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
E:\magento\shop\app\code\core\Mage\Catalog\Model\Category.php (1 hits)
Line 756: $available = split(',', $available);
E:\magento\shop\app\code\core\Mage\Catalog\Model\Convert\Adapter\Product.php (2 hits)
Line 561: $websiteCodes = split(',', $importData['websites']);
Line 592: $value = split(self::MULTI_DELIMITER, $value);
E:\magento\shop\app\code\core\Mage\Catalog\Model\Resource\Eav\Mysql4\Url.php (2 hits)
Line 502: $split = split('/', $category->getPath());
Line 710: $product->setCategoryIds(split(',', $product->getCategoryIds()));
E:\magento\shop\app\code\core\Mage\Catalog\sql\catalog_setup\mysql4-upgrade-0.7.39-0.7.40.php (1 hits)
Line 35: $applyTo = split(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
E:\magento\shop\app\code\core\Mage\CatalogRule\Model\Rule\Condition\Product.php (1 hits)
Line 361: $value = split(',', $value);
E:\magento\shop\app\code\core\Mage\CatalogRule\sql\catalogrule_setup\mysql4-upgrade-0.7.1-0.7.2.php (1 hits)
Line 44: foreach (split(',', $r['store_ids']) as $storeId) {
E:\magento\shop\app\code\core\Mage\Customer\Model\Convert\Adapter\Customer.php (1 hits)
Line 500: $value = split(self::MULTI_DELIMITER, $value);
E:\magento\shop\app\code\core\Mage\Downloadable\Helper\Download.php (2 hits)
Line 210: $contentType = split('; ', $this->_urlHeaders['content-type']);
Line 225: $contentDisposition = split('; ', $this->_urlHeaders['content-disposition']);
E:\magento\shop\app\code\core\Mage\Downloadable\sql\downloadable_setup\mysql4-install-0.1.0.php (1 hits)
Line 46: $applyTo = split(',', $installer->getAttribute('catalog_product', $field, 'apply_to'));
E:\magento\shop\app\code\core\Mage\Downloadable\sql\downloadable_setup\mysql4-upgrade-0.1.0-0.1.1.php (1 hits)
Line 32: $applyTo = split(',', $installer->getAttribute('catalog_product', 'weight', 'apply_to'));
E:\magento\shop\app\code\core\Mage\Eav\Model\Convert\Adapter\Entity.php (1 hits)
Line 107: $split = split('/', $k);
E:\magento\shop\app\code\core\Mage\Sales\Model\Order\Pdf\Abstract.php (1 hits)
Line 157: foreach (split("\|", $address) as $str) {
E:\magento\shop\lib\PEAR\SOAP\Parser.php (1 hits)
Line 381: $this->message[$pos]['arrayOffset'] = split(',', substr($value, 1, strlen($value) - 2));
E:\magento\shop\lib\PEAR\SOAP\Transport\HTTP.php (2 hits)
Line 272: $headers = split("\r?\n", $headers);
Line 278: list($name, $value) = split(':', $value);
E:\magento\shop\lib\Varien\Db\Adapter\Pdo\Mysql.php (1 hits)
Line 585: $keyList[$v[1]] = split(',', str_replace($this->getQuoteIdentifierSymbol(), '', $v[2]));
E:\magento\shop\lib\Zend\Cache\Frontend\Page.php (1 hits)
Line 316: $tmp = split(':', $headerSent);
E:\magento\shop\lib\Zend\Gdata\YouTube\VideoEntry.php (1 hits)
Line 839: return split('(, *)|,', $keywordsString);
E:\magento\shop\lib\Zend\Service\Amazon.php (1 hits)
Line 202: $responseGroup = split(',', $options['ResponseGroup']);
我不会费心修改 Magento 以使用 5.3,因为更改肯定会比您的来源假设的更复杂。PHP 5.3 带有命名空间,自动加载机制肯定会改变。这意味着很多东西会在内部发生变化。长类名称,如:
// Mage_Sales_Model_Order
Mage::getModel('sales/order');
将仅在其自己的命名空间中按顺序调用,而不是:
// maybe something like this
Mage::getModel('order');
// or like this
$order = new Order();
// 这取决于 Magento 团队将如何实现命名空间
我已经在我的博客上介绍了这种情况。它实际上解释了如何解决 Magento 1.3.X 和 PHP 5.3.X 之间的不兼容问题。我希望它有所帮助。