tags:

views:

1830

answers:

5

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?

+2  A: 

Looks like they are still in the process of making it compatible:

http://www.magentocommerce.com/boards/viewthread/29670/P15/

If I were you, I would wait for an official release before attempting an upgrade to PHP5.3

Mark
A: 

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

Matt
not quite sure why this got a negative...those are the functions required to make the jump. the other is just sound advice for a prod environment, but whatever, I suppose egos can get in the way of knowledge sometimes.
Matt
A: 

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

Elzo Valugi
A: 

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!)

A: 

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(), '_');
Jim Miller