Running Joomla 1.0 on PHP 5.3 without errors

Of course ideally nobody should be using Joomla 1.0 any more as it is no longer supported and might contain security vulnerabilites. In reality, sometimes you just have to let a 1.0 site linger for a while until you get time to upgrade. But if your host upgrades to PHP 5.3, you can find your site breaks completely.

In particular, you can find that the content area is blank, the contact us page is completely blank, and lots of error messages appearing on screen warning about PHP functions that are 'deprecated'. Whilst I was able to find fixes for some of these errors on various different sites, nobody seems to have a complete patch for getting Joomla 1.0 running on PHP 5.3. So I thought I'd better write one.

I applied the fix for the content area and contact pages being blank, then searched through the entire code looking for all the function calls to eregi, eregi_replace, split, and assigning new by reference (=& new). These seem to be the main culprits for generating 'deprecated' errors which may fill up the screen or cause your error log to grow enormous. There might be others, but I haven't come across them yet. I replaced these functions with PHP 5.3 equivalent code. To apply the patch, download the following file, unzip it on your computer, and upload to your Joomla 1.0.15 site (use entirely at your own risk, and make sure you back up your site first, just in case!):

http://www.netshinesoftware.com/downloads/joomla_1_0_15_for_php_5_3_patch.zip

This is of course released under the GPLv2 license.

The patch only includes core Joomla files. You might have 3rd party extensions that also produce errors. In this case, here is a brief guide on how to fix eregi, eregi_replace, split, and =& new (again, use this information entirely at your own risk):

In the error message (either on screen or in your error log) it usually tells you which file and line number is causing a problem.

Assigning the return value of new by reference is deprecated

If you get this error, just look for "=& new" and remove the ampersand (so it just says "= new").

Function eregi() is deprecated

You can replace eregi with preg_match, however you have to add a delimiter and a directive. Typically you use a forward slash as the delimter, but if the contents of the pattern in the first parameter contains a forward slash you will have to choose a different character (eg. a hash # or a pipe | are common alternatives). At the end of the string, you repeat the delimter, followed by the letter 'i' (meaning case insensitive). For example, change this:

eregi('pattern', $string)

to this:

preg_match('/pattern/i', $string)

or if the pattern contains a forward slash already, you could use this instead:

preg_match('|pattern|i', $string)

Function eregi_replace() is deprecated

This is dealt with in the same way as eregi, above, but instead of using preg_match, you use preg_replace.

Function split() is deprecated

In most cases you can simply replace split with explode. If the first parameter is a regular expression, you have to use preg_split instead.

Comments

Posted by MSLinkExchange on
Thanks for this patch!! It worked. :)
Posted by Rui on
Your patch worked just fine and just rescued 2 of my old sites.

Tanks for sharing this outstanding work.
Posted by Leonid on
Thank you from Russia!
It works great!
Posted by blackweb on
Thank you very much! It worked well!
Posted by Thoai on
Thank you very much, this patch saved my day!!!
Posted by Koen on
AMAZING Helped a lot! THANKS !
Posted by Keith on
Good Job! Thank you for your hard work, now to convince the client that they need to upgrade... :o)
Posted by Ute on
You not only saved my day but my sanity too....where ever you are...you must have heard the rock fall off my heart. Thanks a million!!!
Posted by irdesigner on
this is best patch that i can find, Thank you very much, It worked
Posted by Stewart on
I have a couple of older sites running on Joomla 1.0 and couldn't fix them at all while I upgraded.

However, I found your fix and it worked perfectly (though I did have to upload each file manually for some reason).

Many, many thanks!
Posted by Marco on
Thank you very very very much!! It works great!
Posted by Matt on
Man, you saved my day. Many thanks!
Posted by Khan on
Really great work. Thanks a lot.
Posted by Normann Dahle on
Thank you.. Really good work! Works fine!
Posted by Evaristo on
Hello.

Thank you for sharing !
Posted by Brandt on
Many, many thanks!
Posted by Chris on
Hi - so much thanx for that post- you saved my 1.0.15 site with that! The problem is that a migration to 1.5 - in my case - is nearly impossible because of individual adjustement and programming in many 3hrd party components i have in use. Just one warning i can not find a solution (it is in the needed SEO component Artio i use):
if (eregi($regexSuffix.'$', $imptrim)) {
No Matter what i try:
if (preg_match($regexSuffix.'/$/i', $imptrim)) {
if (preg_match($regexSuffix.'/$/', $imptrim)) {
if (preg_match($regexSuffix.'/^$/i', $imptrim)) {
and so on, i always get:
Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in ....
Can someone help me with that?
Posted by netshine on
The delimiter needs to come at the start and the end, eg:

if (preg_match('/' . $regexSuffix . '$/i', $imptrim)) {

Depending on the contents of $regexSuffix and the purpose of the dollar sign at the end, you might need to add a backslash before the dollar sign, eg:

if (preg_match('/' . $regexSuffix . '\$/i', $imptrim)) {
Posted by Allison on
THANK YOU!!!
Posted by Andreas Fricke on
A very BIG Thank you from Cologne!!! Here is a Beer waiting for you!!!
Posted by Peter on
Thank you so much for this great help!
I had to solve this joomla 1.0.15/php5-problem on some sites and this was easy, fast, stable with your patch!
Posted by Arie on
Thank you,
The patch worked fine and i had to replace 1 split to explode.
Posted by Anando on
wonderful patch, thank you so much
Posted by Thanos on
It worked for me too!
Good job and thank you.
Posted by Raymond on
Thanks, worked perfectly for me..
Posted by Andy on
AWESOME STUFF! THANK YOU!
Leave a Reply



(Your email will not be publicly displayed.)


Captcha Code

Click the image to see another captcha.


Posted by:

Share: