Thursday, April 12, 2012

Fixing Joomla 1.0 for php 5.3.x | Joomla > Core - KPS | Melbourne Joomla Consultants

Joomla 1.0 has a few things that break under PHP 5.3.x, as a number of users have found over time.
Obviously, it's recommended that developers now take the time to upgrade their Joomla sites to 1.5 at least, and ideally now Joomla 1.6 as Joomla 1.5 has reached it's end of development life, and most major components are now available for Joomla 1.5.
Following upgrading my version of PHP recently, I needed to do my homework, and have found a few simple workarounds to get Joomla 1.0 functioning on PHP 5.3.x until I can get to the stage where I can update the last few sites I have in Joomla 1.0.
Note that only core Joomla 1.0 filexes are outlined in this article. If you are encountering problems with Joomla 1.0 templates developed by third parties, visit the third party's website to diagnose and fix the issue (if they have a solution) or upgrade your 1.0 site to a newer version of Joomla.

TO MAKE JOOMLA 1.0.X COMPATIBLE TO PHP 5.3.X, THERE'S A FEW STEPS.

First up, if you're getting content not showing on most pages, go to Function.php files  your directory on /public_html/includes/Cache/Lite.
Then replace:
$arguments = func_get_args();
with
$arguments = func_get_args();
$numargs = func_num_args();
for($i=1; $i < $numargs; $i++){
$arguments[$i] = &$arguments[$i];
}
in includes/Cache/Lite/Function.php. It fixes compatibility view issues for Joomla 1.0.x on php 5.3.x.
Original Post explaining the cache lite fix is here.

COM_CONTACT WHITE SCREEN / VCARD.CLASS.PHP ERROR

Depending on which other components you have in your 1.0 site, there may be other items to be fixed.
com_contacts uses the includes/vcard.class.php file, which also needs to be modified to avoid this error:
Fatal error: Cannot redeclare quoted_printable_encode() in includes/vcard.class.php on line 74
In vcard.class.php around line 36 is the function quoted_printable_encode. This ends up declaring twice, causing the error, so you can prevent the error and fix the error by checking if the function already exists, and if it does, PHP ignores the function declaration. Adding the green lines of code before and after the existing function clears the problem.
if(!function_exists('quoted_printable_encode')) {
 function quoted_printable_encode($input, $line_max=76) {
 /* ... */
 }
}
Original post for helping with this solution.

TIMEZONES

Another PHP 5.3 change is to how the timezones are set.
The easiest solution I've found for fixing that aspect is to place some timezone code in the .htaccess file for your site. Assuming you're using it for SEF URLs already, it will have been renamed from htaccess.txt, so you should just need to edit your .htaccess file.
Add the following, chaning your timezone to your required timezone:
# set the server timezone
  SetEnv TZ Australia/Victoria
Original post for helping with this solution. For a full list of timezones, see the PHP Reference Manual.

DEPRECATED: FUNCTION EREGI() IS DEPRECATED IN INCLUDES/SEF.PHP ON LINE 533

Additional Info: September 29 2011
The functionality of eregi in newer php versions is performed by changing to the preg_match function, then modifying some of the regular expressions used in the function.
You can download the fix for the SEF.PHP problem via the original post link below, or manually change the 5 lines as follows.
Line 370:
WAS:
     if ($juri != '' && $juri != '/' && !eregi( "index\.php", $_SERVER['REQUEST_URI'] ) && !eregi( "index2\.php", $_SERVER['REQUEST_URI'] ) && !eregi( "/\?", $_SERVER['REQUEST_URI'] ) && $_SERVER['QUERY_STRING'] == '' ) {
BECOMES:
     if ($juri != '' && $juri != '/' && !preg_match( "index\.php/i", $_SERVER['REQUEST_URI'] ) && !preg_match( "index2\.php/i", $_SERVER['REQUEST_URI'] ) && !preg_match( "/\?/i", $_SERVER['REQUEST_URI'] ) && $_SERVER['QUERY_STRING'] == '' ) {
Line 388:
WAS:
if( $mosConfig_sef && $mosConfig_multilingual_support && $string!='index.php' && !eregi("^(([^:/?#]+):)",$string) && !strcasecmp(substr($string,0,9),'index.php') && !eregi('lang=', $string) ) {
BECOMES:
if( $mosConfig_sef && $mosConfig_multilingual_support && $string!='index.php' && !preg_match("^(([^:/?#]+):)/i",$string) && !strcasecmp(substr($string,0,9),'index.php') && !preg_match('lang=/i', $string) ) {
Line 393:
WAS:
if ($mosConfig_sef && !eregi("^(([^:/?#]+):)",$string) && !strcasecmp(substr($string,0,9),'index.php')) {
BECOMES:
if ($mosConfig_sef && !preg_match("/^(([^\/:?#]+):)/i",$string) && !strcasecmp(substr($string,0,9),'index.php')) {
Line 409:
WAS:
if (preg_match('@^[A-Za-z][A-Za-z0-9:_.-]*$@', $url['fragment'])) {
BECOMES:
if (preg_match('@^[A-Za-z][A-Za-z0-9:_.-]*$@/i', $url['fragment'])) {
Line 533:
WAS:
eregi("^(https?:[\/]+[^\/]+)(.*$)", $mosConfig_live_site, $live_site_parts);
BECOMES:
preg_match("/^(https?:[\/]+[^\/]+)(.*$)/i", $mosConfig_live_site, $live_site_parts);


More than 3 requests, I'll translate this to Chinese.
超过3个请求,我就会把这篇文章翻译成中文。

No comments: