Updating Magento 1.3.x to PHP 5.3 compatibility
In my first blog post, I'll demonstrate how Magento versions 1.3.x can safely be upgraded to be compatible with PHP 5.3
Before we go any further, I should mention that version of Magento after 1.3.3 are fully compatible with PHP 5.3
PHP 5.2 is now unsupported by Zend (http://www.php.net/archive/2010.php#id2010-12-16-1), so now is a good time to consider upgrading to PHP 5.3
As an aside - I don't advocate upgrading just for the sake of it, the old adage is always true : if it ain't broke, don't fix it
However, if part of your ongoing Magento optimisation strategy is to leverage some of the benefits offered by PHP 5.3 (eg FPM, better memory management, improved performance), then this guide would allow you to upgrade your servers to PHP 5.3 without the necessity to migrate your Magento version at the same time.
The very first commercially available versions of Magento Enterprise edition were based on Magento 1.3.2.4, so I expect that there will still be a few Enterprise installations out there running on EE 1.3.2.4. Infact, a large Magento Enterprise project I'm currently involved with only recently (in November) upgraded from Enterprise 1.3.2.4 to Enterprise 1.9.0.0
The process of upgrading Magento 1.3.x to be PHP 5.3 compatible is actually very easy. Chiefly, there are only 2 errors which prevent these versions of Magento running on PHP 5.3. The first is a rather obvious error as soon as we try to access any page:
Fatal error: Method Varien_Object::__tostring() cannot take arguments in ... /lib/Varien/Object.php on line 488
This can be fixed easily by...
renaming the __toString function in lib/Varien/Object.php to __invoke
The second error is now apparent :
Unknown error (8192): Function split() is deprecated in ../app/code/core/Mage/Core/Controller/Request/Http.php on line 274
Unfortunately, there are several different source files where split is used, all of these need changing to explode
In the following files, replace split with explode :
- Mage/Core/Controller/Request/Http.php
- Mage/Admin/Model/User.php
- Mage/Adminhtml/controllers/System/ConfigController.php
- Mage/Adminhtml/Model/Observer.php
- Mage/Adminhtml/Model/System/Config/Backend/Currency/Abstract.php
- Mage/Adminhtml/Model/System/Config/Backend/Locale.php
- Mage/Catalog/Model/Category/Attribute/Backend/Sortby.php:
- Mage/CatalogRule/Model/Rule/Condition/Product.php
- Mage/Catalog/Model/Category.php
- Mage/Catalog/Model/Convert/Adapter/Product.php
- Mage/Catalog/Model/Resource/Eav/Mysql4/Url.php
- Mage/CatalogIndex/Model/Aggregation.php
- Mage/Customer/Model/Convert/Adapter/Customer.php
- Mage/Downloadable/Helper/Download.php
- Mage/Eav/Model/Convert/Adapter/Entity.php
- Mage/Sales/Model/Order/Pdf/Abstract.php
Additionally, for Enterprise versions :
- Enterprise/GiftCard/sql/enterprise_giftcard_setup/mysql4-upgrade-0.0.4-0.0.5.php
- Enterprise/GiftCard/sql/enterprise_giftcard_setup/mysql4-upgrade-0.0.6-0.0.7.php
- Enterprise/Staging/Model/Staging/Config.php
Be careful not to use s/split/explode/g - there's variables named split as well as string_split functions being used... safest way to replace instances of "split" with "explode" is the hard way - manually. It should only take about 15 minutes.
Once that has been done, you should find that your Magento 1.3.x installation works under PHP 5.3
Remember, if you've got any additional modules installed you'll have to make the same changes to those also.