Magento 1.3.X environment won’t run on PHP 5.3.X due to functions being deprecated. No sweat, there is a quick fix here!

March 5, 2011
By

So, you still have your website in Magento 1.3.X because it has too many customizations and you can’t upgrade, but you decide to upgrade to PHP 5.3.X due to the annoyingness from PCI with the compliance changing every hour and when you are going to check your website… a strange error appears due to some PHP functions being deprecated? Yes, it happens to many of us, but fortunately, here is a solution!

So, when you try to run your website, you get something like this:

Unknown error (8192): Function split() is deprecated in   /app/code/core/Mage/Admin/Model/User.php on line 374
Trace:
#0 [internal function]: mageCoreErrorHandler(8192, ‘Function split(…’, ‘ /app/code/core/Mage/…’, 374, Array)
#1   /app/code/core/Mage/Admin/Model/User.php(374): split()
#2   /app/code/core/Mage/Adminhtml/controllers/IndexController.php(42): Mage_Admin_Model_User->getStartupPageUrl()
#3   /app/code/core/Mage/Core/Controller/Varien/Action.php(376): Mage_Adminhtml_IndexController->indexAction()
#4   /app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(’index’)
#5   /app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#6   /app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#7   /index.php(65): Mage::run()
#8 {main}

 

Well, basically what’s happening is that some functions go deprecated from PHP 5.2.X to 5.3.X and these are present in Magento 1.3.X (but not in Magento 1.4.X).

The solution is a quick fix that involves just 3 files:

Open the file lib/Varien/Object.php, and do the following change:

Look for the line:

public function ___toString(array $arrAttributes = array(), $valueSeparator=’,’)

Change it to:

public function __invoke(array $arrAttributes = array(), $valueSeparator=’,’)

 

Now, go to the file: app\code\core\Mage\Core\Controller\Request\Http.php and change:

Look for the line:

$host = split(‘:’, $_SERVER['HTTP_HOST']);

Change it to:

$host = explode(‘:’, $_SERVER['HTTP_HOST']);

 

Also, go to app\code\core\Mage\Catalog\Model\Category\Attribute\Backend\Sortby.php and change:

Look for the line:

$object->setData($attributeCode, split(‘,’, $data));

Replace With:

$object->setData($attributeCode, explode(‘,’, $data));

 

Finally, open the file: app\code\core\Mage\Admin\Model\User.php and change:

Look for the line:

$nodePath = ‘adminhtml/menu/’ . join(‘/children/’, split(‘/’, $startupPage)) . ‘/action’;

Replace With:

$nodePath = ‘adminhtml/menu/’ . join(‘/children/’, explode(‘/’, $startupPage)) . ‘/action’;

 

That’s it, you Magento environment should run again.

I hope this was helpful for you, and if it was, why don’t you share it among all others? :)

Tags: , , , , , ,

15 Responses to Magento 1.3.X environment won’t run on PHP 5.3.X due to functions being deprecated. No sweat, there is a quick fix here!

  1. Paul Boekholt on March 16, 2011 at 5:31 am

    We blogged about this when we switched to php 5.3, see http://www.byte.nl/blog/2010/09/28/how-to-use-magento-1-3-with-php-5-3/ . You can turn E_DEPRECATED off, then you won’t get errors about deprecated functions.

    • Helder Martins on March 16, 2011 at 9:09 am

      Hey Paul,

      Yes, that’s another way to do it, but I felt doing that would probably bring some issues in the future, as if we decide to change something later and that causes some sort of a problem, then we wouldn’t be able to notice it as the warning messages are turned off. Of course, it’s a valid solution though. Still, thanks for reading and contributing, that’s the whole idea! :)

  2. zeratool on May 30, 2011 at 10:13 pm

    thanks dude, your solution works!

  3. rakesh on October 20, 2011 at 4:07 am

    now no errors, but directly goes to phpmyadmin page…

    • Helder Martins on October 20, 2011 at 8:59 am

      Well… something must be wrong and I guess it’s in your server’s configuration, because phpMyAdmin should have its own folder to work on and depending on the server’s configuration maybe its own port. I would say that you consult with your server’s provider about this, I don’t believe this being Magento’s related at all.

  4. Jason McCreary on December 8, 2011 at 10:23 am

    Good write up. Note that there are far more instances of `split()` than you listed. Doing a project search, there’s about 108. As commented by Paul Boekholt above, you may not have to change all these. Only the `__toString()` update is critical.

  5. Jason McCreary on December 14, 2011 at 10:22 am

    Also had some issues with the Zend framework installed for Magento (v. 1.1.8)

    Reference this Zend thread – http://framework.zend.com/issues/browse/ZF-3417. There were about a dozen places these magic methods need to be changed from `protected` to `public`.

    • Helder Martins on December 14, 2011 at 12:22 pm

      Thanks, this is a nice and useful contribution for the community and readers.

  6. Mark Thompson on January 3, 2012 at 10:29 am

    Thanks for this, had the Magento back-end explode after we migrated the website across servers to a MUCH more up-to-date version of php in the US. This fixed the issue, now I’m advising the client to upgrade Magento!

    I noticed that 1.7.0.0 Alpha is coming up as an upgrade in the admin panel ? I’m no Magento Expert, I’m merely a PHP developer, what’s the latest stable/safe version of Magento ? (I’m hesitant to advise the use of an Alpha release)

    Thanks again

    Mark

    • Helder Martins on January 3, 2012 at 3:37 pm

      Hello Mark,

      First of all, I’m glad my blog has helped another person :)

      About what you mention, I would never recommend someone to use an Beta or Alpha version for a production environment, as a matter of fact, I’m very conservative on this, and specially with Magento, and I won’t recommend to jump into 1.7 even after it’s new released version, I would always stick to one below the latest version until the latest version has at least 6 months old. This is because sometimes Magento has launched versions that have critical things not addressed and many people has fallen for those things having to run to fix them before Magento releases a patch or a fix and if you are in a production environment this is critical.

      My recommendation on this would be that you upgrade up to 1.6 at the most. Of course, consider that you will have a LOT of work, probably consider to re-do the entire site because since version 1.3 for me it’s just a new system.

  7. Katie on January 11, 2012 at 6:17 pm

    Hi,

    Our server has just been upgraded to php 5.3 and we get this issue. However, we have magento 1.4.0.1 so confused as your article implies we shouldn’t have an issue. The error below shows this relates to an seo extension so very confused.

    > a:5:{i:0;s:157:”Deprecated functionality: Function split() is deprecated in /home/domain/public_html/app/code/local/MageWorx/SeoSuite/Block/Page/Html/Head.php on line 103″;i:1;s:2854:”#0 [internal function]: mageCoreErrorHandler(8192, ‘Function split(…’, ‘/home/littlebi/…’, 103, Array)
    > #1 /home/domain/public_html/app/code/local/MageWorx/SeoSuite/Block/Page/Html/Head.php(103): split()

    Any idea on whether your suggestion above will work for this too or is it a different fix for 1.4.0.1?

    Thanks,

    Katie

    • Helder Martins on January 12, 2012 at 8:10 am

      Hello, thanks for reading the blog.

      This post as you mention is for Magento 1.3.X which relies in several PHP functions which were deprecated in PHP 5.3.

      According to what I see from your error, the problem is not with Magento 1.4.0.1 itself, the problem with the deprecated function is with the plugin SEOSuite from MageWorx, which apparently uses split() that has been deprecated from PHP 5.3.

      My recommendation would be to first contact MageWorx who is the developer of this extension, and consult for a patch or possible upgrade that should correct this issue. If this doesn’t work then you might need to go to that particular file in your installation: /home/domain/public_html/app/code/local/MageWorx/SeoSuite/Block/Page/Html/Head.php on line 103, and try to replace it (I recommend reading explode() function from PHP here: http://php.net/manual/en/function.explode.php, that might help).

      I hope this helps.

      Regards.

Leave a Reply

Your email address will not be published. Required fields are marked *

*




plugin by DynamicWP
#