How to run Magento 1.3 with PHP 5.3 version

Article ID #1051
Revision: 1.6
Last update: 2013-01-18

Magento 1.3 version shows the following error when running PHP 5.3 version:

Fatal error: Method Varien_Object::__tostring() cannot take arguments

Since we use PHP 5.3 by default and the old Magento 1.3 version is not compatible with PHP 5.3 without additional modifications, there are two possible ways to run the old Magento 1.3 version:

  • Use our Power of Freedom or Triple Power plans. We can install any PHP version for you in those plans
  • Modify the Magento code to run on PHP 5.3

To use our Power plans, please simply upgrade your subscription and notify the Support Team that you need particular PHP version.

To modify Magento 1.3 code to run with PHP 5.3, please use the following steps:

  • Modify the lib/Varien/Object.php file by replacing "public function __toString", the old code:
    public function __toString(array $arrAttributes = array(), $valueSeparator=',')
    {
        $arrData = $this->toArray($arrAttributes);
        return implode($valueSeparator, $arrData);
    }

should be replaced with the following code:

    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);
    }
  • In the app/code/core/Mage/CatalogIndex/Model/Aggregation.php file replace all calls for split() function with explode() function:
    @@ -153,3 +153,3 @@
             foreach ($tags as $tag) {
    -            $tagInfo = split(':', $tag);
    +            $tagInfo = explode(':', $tag);
                 if (count($tagInfo)==1) {
    @@ -157,3 +157,3 @@
                 } else {
    -                $tagVariants = split('/', $tagInfo[1]);
    +                $tagVariants = explode('/', $tagInfo[1]);
                     foreach ($tagVariants as $tagVariant) {
    
  • In the app/code/core/Mage/Core/Controller/Request/Http.php file replace all calls for split() function with explode() function:
    @@ -273,3 +273,3 @@
             if ($trimPort) {
    -            $host = split(':', $_SERVER['HTTP_HOST']);
    +            $host = explode(':', $_SERVER['HTTP_HOST']);
                 return $host[0];
    
  • In the app/code/core/Mage/Admin/Model/User.php file replace all calls for split() function with explode() function:
    @@ -373,3 +373,3 @@
             if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) {
    -            $nodePath = 'adminhtml/menu/' . join('/children/', split('/', $startupPage)) . '/action';
    +            $nodePath = 'adminhtml/menu/' . join('/children/',explode('/', $startupPage)) . '/action';
                 if ($url = Mage::getConfig()->getNode($nodePath)) {
    

 

  • If there are any other entries for split() calls, all of them should be replaced with explode() one by one. You can find these calls by searching for 'split(' pattern in code, with grep (on Mac and LInux) or findstr (on Windows), for example:
    $ grep " split(" -r path/to/magento/
    # findstr /s /p /i /n /c:"split(" path\to\magento

    Though, all warnings about deprecated split() function are non-critical and can be turned off simply by replacing error_reporting function in index.php:
    error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
    ini_set('display_errors',0);
  • Clear Magento cache and ensure that store now opens properly
Did this article help you solve your issue?


Average rating: 4.36 (22 votes)

completely useless 1 2 3 4 5 most valuable

Tags: ,