Quick fix for the ‘Deprecated: Function eregi() is deprecated ‘ issue / error with phpThumb and PHP 5.3+

I recently upgraded a production server to PHP 5.3.6 from a much earlier 5.2.x build and noticed that the process had killed all instances of phpThumb on the server due to the deprecation of the functions ‘eregi’, ‘ereg’, ‘split’ & ‘eregi_replace’.

See:- http://php.net/manual/en/migration53.deprecated.php for a full list of functions deprecated since PHP 5.3.0.

The messages being output by phpThumb are similar to:

Deprecated: Function eregi() is deprecated in /home/test/public_html/phpThumb/phpThumb.php on line 152

The quickest fix is to modify phpThumb.php to suppress the warnings, open the file and change the first few lines from:

error_reporting(E_ALL);
ini_set('display_errors', '1');

To

error_reporting(0);
 ini_set('display_errors', '0');

IMPORTANT: his will SUPPRESS ALL PHP WARNINGS & ERRORS from phpThumb, so if you get other errors you won’t know much about it.
A BETTER way to remove the errors is to patch phpThumb, all calls to the deprecated functions need replacing.

As an interim measure, until an updated version of phpThumb is released, I have patched a copy of phpThumb 1.7.9 to be PHP 5.3.0+ compatible.

Download the patched version of phpThumb 1.7.9 that has been fixed to work with PHP 5.3.x

If anyone finds an bugs let me know and I’ll patch them.

 

Tags:
Post comment as twitter logo facebook logo
Sort: Newest | Oldest
bhupen 5 pts

It dosen't fix my problem at all i got the following error after replacing your folder:

http://www.photoloveletter.co.uk/includes/thumb/phpThumb.php?zc=1&q=100&w=1098&h=1088&fltr[]=crop|0|0|41.84|146.44&fltr[]=bord|9|0|0|ffffff&src=/images/flash/userimages/1353443087_2.jpg

coduanh 5 pts

This fix work for me completely. I spend a lot of time to fix until I find this article. Thanks a lot

S3nd41 5 pts

I applied your fix and I keep getting the ereg error and now I get even an additional error:

[13-Nov-2012 12:22:24 UTC] PHP Notice:  Undefined offset: 0

Is there some way to solve this?

gosunkugi 5 pts

till now, august 2012, is any bug there? anyway I will use it immediately, and thank a lot for the fixing :D

gosunkugi 5 pts

till now, august 2012, is any bug there? anyway I will use it immediately, and thank a lot for the fixing :D

Trackbacks

  1. [...] un fix aqui para corregirlo … bueno… realmente no lo corregia, solo dejaba de mostrar los errores (tipica [...]