Symfony 1.4使用PHP 5.5中不推荐使用的功能 [英] Symfony 1.4 using deprecated functions in php 5.5

查看:82
本文介绍了Symfony 1.4使用PHP 5.5中不推荐使用的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将PHP从5.3.27版本升级到了5.5.0. 在我的Symfony 2.3.2项目中一切正常,我可以享受最新的PHP功能.

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.

现在,当我返回到另一个Symfony 1.4.16项目时,我收到一个关于使用/e修饰符弃用preg_replace的PHP错误.

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.

我在论坛中找不到有关此错误的参考:之前有人遇到过此问题吗?我可以直接使用任何补丁吗?升级到Symfony 1.4.20可以解决此问题吗?

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 ?

错误消息如下:

不建议使用:preg_replace():不建议使用/e修饰符,而应在第409行的/myproject/lib/vendor/symfony/lib/response/sfWebResponse.class.php中使用preg_replace_callback

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.

到目前为止,尚无补丁程序(Symfony 1.4.20尚未解决该问题).解决方案是将对preg_replace的失败调用替换为在源代码中对preg_replace_callback的相应调用,这很容易在sfWebResponse类中完成(感谢提示Jon).现在下一次失败要多一些复杂,不幸的是...另一方面,我们可能必须使用grep来将preg_replace与/e选项一起使用,以便找出Symfony可能在哪里中断.给出了很多结果:o

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

所以...我的结论是,Symfony 1.4用户最好不要发布PHP到版本5.5,直到出现一些严重的补丁为止.你怎么认为 ?还有其他选择吗?

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 ?

推荐答案

除非您在 index.php 中启用了调试,否则错误不会显示在prod中.也可以通过在 settings.yml 中设置E_DEPRECATED标志来删除它们:

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" ?>

这篇关于Symfony 1.4使用PHP 5.5中不推荐使用的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆