#38 ereg_replace deprecated warnings

V 5.3
closed-out-of-date
nobody
None
5
19 hours ago
2011-10-11
Colin
No

This post relates to the significant number of warnings I was getting about ereg_replace being deprecated.

The offending call is in database.inc.php ln71. The PHP website http://php.net/manual/en/function.ereg-replace.php says that this function was deprecated from PHP 5.3.0 - the version I'm using. Some further reading suggests that this should be replaced with a call to preg_replace() but that needs a small tweak to the regex pattern - preg patterns must be delimited so I just added a / at start and end:

// PATCH: ereg_replace is deprecated
//$sql = ereg_replace("([,\(=])[\r\n\t ]*''",'\\1NULL',$sql);
$sql = preg_replace("/([,\(=])[\r\n\t ]*''/",'\\1NULL',$sql);
// PATCH:

That got rid of the warnings although no guarantees the code is doing exactly what it was meant to!

I suspect its my setup that's 'caused' this problem. I'm running WAMPServer 2.0i. That's not the recommended AMP stack but then I was familiar with it and didn't want to setup another system. However, it would obviously be good if code wasn't using a deprecated function.

Thanks.

Discussion

  • Our developers are working on it to fix it soon.

    OS4ED support

     
  • admin@OS4ED
    admin@OS4ED
    2012-10-02

    If you use php ver 5.2 or below, you will not get this error. We are going t upgrade this function so that it works in 5.3 and is backward compatible.

     
  • admin@OS4ED
    admin@OS4ED
    19 hours ago

    • status: open --> closed-out-of-date
    • Group: --> V 5.3