Please Login or Register

Knowledgebase

Magento and PHP 5.3 - Magento not working on PHP 5.3

Your Magento Site is hosted in a shared environment, PHP has been upgraded to 5.3 without any regards, and finally everything seems broken?

Don't panic. Without considering this as normal, the problem is already well known, and actually being corrected if it's not already the case. Theses errors come from pieces of code which have probably been produced a log time ago, and which are using deprecated PHP functions and syntaxes.

In case of emmergency, or if you just can't consider an upgrade, here's how you can fix it:

In "/lib/Varien/Object.php", line ~ 484, replace this method declaration (deprecated syntax):

public function __toString(array $arrAttributes = array(), $valueSeparator=',')

With:

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

Then, add this method just after __invoke, to be sure that direct call to the __toString method will still work:

function __toString() {
    return $this->__invoke( func_get_arg(0), func_get_arg(1) );
}

Afterwhat, you need to go on "split" function calls hunting, since this one is now forbidden, to replace them with the "explode" function, which works exactly the same way.

Example: in "/app/code/core/Mage/Core/Controller/Request/Http.php" line 274

Replace:

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

With:

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

There is several occurencies of "split" to replace, but be careful, don't use a massive replace feature, you would replace occurencies of "preg_split" and "str_split" too, which are both used in Magento core source code, and which are still valids.

Finally, don't forget to check you locals Magento modules too!

Once all these modifications are done, your Magento site should be back online and working.

NOTE: these modifications alter Magento core (especially in "/app/code/core" and "/lib"), so you would be advise to not operating directly on a production.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article


Quick Navigation

Client Login

Email

Password

Remember Me

Search