Symfony 1.4 using deprecated functions in php 5.5

mika picture mika · Aug 6, 2013 · Viewed 28.3k times · Source

I recently upgraded PHP from version 5.3.27 to 5.5.0. Everything is working fine in my Symfony 2.3.2 project, and I can enjoy the latest PHP functionalities.

Now when I am going back to my other Symfony 1.4.16 project, I get a PHP error about preg_replace being deprecated with the /e modifier.

I can find no reference about this error in the forums: Has anyone had this problem before ? Is there any kind of patch that I could apply out of the box ? Is an upgrade to Symfony 1.4.20 going to fix this issue ?

The error message goes like this:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /myproject/lib/vendor/symfony/lib/response/sfWebResponse.class.php on line 409

One way to go may be to modify the code as recommended in the message, and in the manual. How can I change my preg_replace expression to a preg_replace_callback call ?

Any help / hint will be very welcome.

EDIT:

To this date, there is no patch for this (and Symfony 1.4.20 does not address the issue). The solution is to replace failing calls to preg_replace with corresponding call to preg_replace_callback in the sourche, which is easily done in the sfWebResponse class (thanks for the hint Jon). Now next failing occurrence is slightly more complex, unfortunately... And on the other hand, we probably would have to grep for preg_replace uses with /e option in order to find out where Symfony is likely to break. Which gives quite a few results :o

So... My conclusion would be that Symfony 1.4 users would better not upgrade PHP to version 5.5 until some serious patch comes out. What do you think ? Any alternative ?

Answer

flm picture flm · Aug 30, 2013

The errors do not show up in prod unless you have enabled debug in index.php. It' s also possible to remove them in dev by unsetting the E_DEPRECATED flag in settings.yml :

dev:
  .settings:
    error_reporting:  <?php echo ((E_ALL | E_STRICT) ^ E_DEPRECATED)."\n" ?>