Openbiz's Blog

Web Solutions

Running Magento 1.3 on PHP 5.3

leave a comment »

Magento 1.3 is not compatible with PHP 5.3 without any additional modifications. So if you decide to run Magento with PHP 5.3, here is a two-step description how to do it:

1) Open index.php and locate the line containing :

error_reporting(E_ALL | E_STRICT);

It is the 35th line in Magento 1.3.3.0. Replace it with :

error_reporting((E_ALL | E_STRICT) & !E_DEPRECATED);

In PHP 5.3 functions like split() and ereg() are deprecated. Magento 1.3 widely uses these two functions so you have to disable error reporting for the newly introduced error level E_DEPRECATED.

2) Open lib/Varien/Object.php and look for the method :

public function __toString(array $arrAttributes = array(), $valueSeparator=’,’)
{
    $arrData = $this->toArray($arrAttributes);
    return implode($valueSeparator, $arrData);
}

It is line 484 in Magento 1.3.3.0. Replace it with

public function __toString()
{
    if(func_num_args() > 0) {
        $arrAttributes = func_get_arg(0);
    } else {
        $arrAttributes = array();
    }
    if(func_num_args() > 1) {
        $valueSeparator = func_get_arg(1);
    } else {
        $valueSeparator = ‘,’;
    }
    $arrData = $this->toArray($arrAttributes);
    return implode($valueSeparator, $arrData);
}

With PHP 5.3 the magic method __toString() no more accepts any parameters. That’s why the old method declaration will cause the following error:

Fatal error: Method Varien_Object::__tostring() cannot take arguments in /magento/lib/Varien/Object.php

Note: The steps listed above are tested with Magento 1.3.3.0.

Advertisements

Written by openbizblog

December 10, 2011 at 1:36 pm

Posted in Magento

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: