Lewis' Blog Tales from the trenches of information technology

26May/130

Still more PHP 5.3 fixes for Joomla! 1.5

Download PDF

When you're on a roll, you're on a roll...

Almost done patching this particular old rowboat. This installment deals with quieting this bit of error log noise:

PHP Deprecated:  Function eregi() is deprecated in blahblah\components\com_htmlmap\views\htmlmap\tmpl\default_map.php on line 20

Among the many functions which became deprecated with PHP 5.3 were ereg() and eregi() POSIX regular expression functions. In fact, I think they all were deprecated in favor of the PCRE functions.

Like so much of Joomla! 1.5, the HTML map component (com_htmlmap) has not been updated in some time. The latest version I could find at JoomlaCode was 1.2.2, dated July 6, 2009...eek! No help there. So, time to roll up the sleeves and have a look see.

The erring bit of code is indeed on line 20:

if (eregi('index.php\?', $area->link) && !eregi('Itemid=', $area->link)) {
	$area->link .= '&Itemid='.$area->itemid;
}

We need to replace instances of eregi() with preg_match(). To make preg_match() case-insensitive, we append the i option, and because the string to be found must - just like when working with Perl regex - be set off with slash delimiters, we have a couple additional slashes to insert. Thus, the above becomes:

if (preg_match('/index.php\?/i', $area->link) && !preg_match('/Itemid=/i', $area->link)) {
	$area->link .= '&Itemid='.$area->itemid;
}

Archive the original file (or rename it), save the above changes, and we're done. More noise quieted.

BTW, in my previous post, I referenced this article which made mention of some rather awkward (to my way of thinking) string replacements for managing such updates. However, the suggestion there to simply prepend all occurrences of ereg() and eregi() with "@" seems woefully inadequate to the task of actually making the code PHP 5.3-compliant. I don't mean to criticize the author, but the title of the article seems a bit out of step with some of the "procedures" <ahem> discussed.

Last Updated on by

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.