Scry and eregi deprecation

One of the downsides of using software that is not being maintained anymore, is that when dependencies change, its users have to adapt the software. Scry, my favorite photo album software, is running in PHP, which makes that a dependency.

Scry makes use of the PHP functions eregi() and eregi_replace(), which scan strings for pattern matches using regular expressions, or regex. Both functions have been deprecated since PHP version 5.3. When running Scry in any PHP version since 5.3, the web server produces a warning message for every time a visitor does a request involving one of these functions. It is easy to make these messages go away by opening the Scry source files in an editor and putting an @-sign before every eregi() or eregi_replace() function call, but that will still clog the web server’s error log.

The irony of choosing an unmaintained package for its low maintenance aside, the trick is to replace each call to these functions with preg_match() and preg_replace() respectively. These use Perl style regex though, so the function arguments need adjusting too. Perl regex always needs to be delimited, and an extra i is needed to make it case insensitive, like PHP’s eregi(). Here’s an example from exif.php, the file that processes exif information in the pictures.

Using eregi():

if (eregi("NIKON", $make)) {

Using preg_match:

if (preg_match("/NIKON/i", $make)) {

I have created patches that will do all the work for you. I don’t have access to the project’s CVS, so I have uploaded them to Scry’s feature request forum, but you can also download them here.

There are three files. Each file holds the changes that must be made to one of the files that Scry is composed of. Download them and copy them to the directories where the original files are. cd Into the directories and then apply them like this:

# patch < patchfile

I hope this  will be of use and welcome feedback.

Categorised as: howto, linux

Comments are closed.