In another post about Function eregi() deprecated I provided some readily fixed Joomla 1.0 files to overcome issues related with upgrading to PHP 5.3 for Joomla 1.0 sites. But since a Joomla site is not built only from the core code, but there are other third party add-ons too, not only these older Joomla sites can be plagued by bad coding practices. The most problematic issues are related with templates. Most of the addons are fixed already, but you might have templates with unsupported functions. Here are couple of tricks wich might help you fix them!

So, if you arrived here, you already know, that after upgrade to PHP 5.3, chances are high you’re going to run into a few warnings or deprecated function messages. An example is the ereg family of functions, which are gone for good, as they were slower and felt less familiar than the alternative Perl-compatible preg family.

To migrate ereg():

ereg('\.([^\.]*$)', $this->file_src_name, $extension);

becomes:

preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);

Notice that I wrapped the pattern (\.([^\.]*$)) around / /, which are RegExp delimiters. If you find yourself escaping / too much (for an URL for example), you might want to use the # delimiter instead.

To migrate ereg_replace():

$this->file_dst_name_body = ereg_replace('[^A-Za-z0-9_]', '', $this->file_dst_name_body);

becomes

$this->file_dst_name_body = preg_replace('/[^A-Za-z0-9_]/', '', $this->file_dst_name_body);

Again, I just added delimiters to the pattern.

If you are using eregi functions (which are the case-insensitive version of ereg), you’ll notice there are no equivalent pregi functions. This is because this functionality is handled by RegExp modifiers.

Basically, to make the pattern match characters in a case-insensitive way, append i after the delimiter:

eregi('\.([^\.]*$)', $this->file_src_name, $extension);

becomes

preg_match('/\.([^\.]*$)/i', $this->file_src_name, $extension);

To migrate another common troublemaker, the split() function you can also use a replacement. This way

split('&task=view&id=', $mitem->link); 

becomes:

explode('&task=view&id=', $mitem->link); 

In case you're interested in knowing more info on digital agency, stop by www.borneagency.com

0
0
0
s2sdefault
Category: Template trickery