Reputation: 1507
I need to upgrade my server to PHP 5.3 but have a Magento install and I know that Magento doesn't play nicely with PHP 5.3.
I think that the changes won't be too extensive (from what I've read). But, I figured I would open it up to the SO crowd.
Has anyone done this successfully? If so, did you take good notes?
Upvotes: 4
Views: 9929
Reputation: 2004
In order to run Magento 1.3.x on PHP 5.3, you need to replace the following function from the corresponding files:
1> index.php
error_reporting(E_ALL | E_STRICT);
to
error_reporting(E_ALL & E_STRICT & ~E_DEPRECATED);
2> lib/Varien/Object.php
__toString
to
__invoke
3> lib/Varien/Pear.php
error_reporting(E_ALL & ~E_NOTICE);
to
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
4> downloader/Maged/Pear.php
error_reporting(E_ALL & ~E_NOTICE);
to
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
5> app\code\core\Mage\Catalog\Model\Layer\Filter\Price.php
__toString
to
__invoke
6> app\code\core\Mage\Core\Controller\Request\Http.php
split
to
explode
7> app\code\core\Mage\Catalog\Model\Category\Attribute\Backend\Sortby.php
split
to
explode
8> app\code\core\Mage\Admin\Model\User.php
split
to
explode
For terminal user who just want to apply patch, i would recommend to use the following article: http://goivvy.com/blog/magento1.3fix/
You can get more info from following Magento Blog:
http://www.blog.magepsycho.com/how-to-run-magento-1-3-x-on-php-5-3/
Hope this helps.
Upvotes: 5
Reputation: 6254
Looks like they are still in the process of making it compatible:
http://www.magentocommerce.com/boards/viewthread/54158/
If I were you, I would wait for an official release before attempting an upgrade to PHP5.3
Upvotes: 1
Reputation: 262
I found a long list of files that use the function split. It needs to be replaced by explode. A simple change of the function name will do. This list adds to what MagePsycho posted above. The downloader folder may contain several more files, the search I used is in the first line.
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']);
Upvotes: 0
Reputation: 9
I have covered this situation on my blog. It actually explains how to solve the incompatibilities between Magento 1.3.X and PHP 5.3.X. I hope it helps.
Upvotes: -1
Reputation: 3329
Re nic28's solution: On a 1.3.3.0 Magento installation, I also needed to do the __toString to __invoke change in app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php, line 139:
$key=.=taxReq->__toString(array(), '_');
Upvotes: 0
Reputation: 75
Well, if you do decide to run Magento with PHP 5.3 anyway, here's how to do it (tested with version 1.3.2.3):
1: in index.php, around line 35, replace
error_reporting(E_ALL | E_STRICT);
with
error_reporting((E_ALL | E_STRICT) & !E_DEPRECATED)
(reason: Magento often uses the split function, which is deprecated in PHP 5.3)
2: in /lib/Varien/Object.php, around line 484 change
public function ___toString(array $arrAttributes = array(), $valueSeparator=',')
to
public function __invoke(array $arrAttributes = array(), $valueSeparator=',')
(reason: I don't really know, but it works!)
Upvotes: 0
Reputation: 27886
I wouldn't bother with modifying Magento to work with 5.3, as the changes will definitely will be more complex than your source assumes. PHP 5.3 comes with namespaces and the autoloading mechanism will change for sure. This means that a lot of stuff will change internally. Long classes name like :
// Mage_Sales_Model_Order
Mage::getModel('sales/order');
will be called only as order in its own namespace instead of:
// maybe something like this
Mage::getModel('order');
// or like this
$order = new Order();
// it depends on how Magento team will implement namespaces
Upvotes: -1
Reputation: 89
2 lines of code but then is not upgrade safe....a production server should never run the latest release anyway, I would never upgrade on a production server...beta or test sure. __toString -> __invoke and a split -> explode
Upvotes: 1