关于`$ HTTP_RAW_POST_DATA`的警告已被弃用 [英] Warning about `$HTTP_RAW_POST_DATA` being deprecated

查看:7695
本文介绍了关于`$ HTTP_RAW_POST_DATA`的警告已被弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我切换到PHP 5.6.0现在我得到以下警告无处不在:

 已弃用:自动填充$ HTTP_RAW_POST_DATA已弃用,并且将在未来版本中删除
。为了避免这个警告,在php.ini中将
'always_populate_raw_post_data'设置为'-1',而改用php:// input stream
。在未知的第0行

警告:不能修改头信息 - 头已经发送在未知在行0

很好,我依赖一些已弃用的功能。除了我不要!


  1. 我没有在任何脚本中使用此变量。

  2. phpinfo()显示我有 always_populate_raw_post_data 设置为0(禁用)。那么发生了什么?



我不想通过将此值设置为-1来避免警告。这将隐藏警告,我仍然会弃用配置。我想从源头解决这个问题,知道为什么PHP认为 HTTP_RAW_POST_DATA 填充被打开。

解决方案

原来,我对错误消息的理解是错误的。我会说它的字的选择非常差。 Google环聊向我显示了其他人对我的信息的误解,请参阅 PHP错误#66763 。 p>

完全无用的这是RM想要的方式。 Mike回答这个错误,Tyrael解释说,将其设置为-1不会使警告消失。它执行正确的事情,即它完全禁用填充罪魁祸首变量。原因是在某些情况下将其设置为0 STILL 填充数据。谈论坏设计!引用 PHP RFC


更改always_populate_raw_post_data INI设置以接受三个值而不是两个值。




  • -1:master的行为;不会填充$ GLOBALS [HTTP_RAW_POST_DATA]

  • 0 / off / whatever:BC行为(如果内容类型未注册或请求方法不是POST,则填充)

  • 1 / on / yes / true:BC行为(总是填充$ GLOBALS [HTTP_RAW_POST_DATA])


所以,设置为-1不仅避免了警告,就像消息所说,但它也终止了填充这个变量,这是我想要的。


I switched to PHP 5.6.0 and now I get the following warning everywhere:

Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will
be removed in a future version. To avoid this warning set
'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream
instead. in Unknown on line 0

Warning: Cannot modify header information - headers already sent in Unknown on line 0

Fine, I rely on some deprecated feature. Except that I don't!

  1. I haven't ever used this variable in any of my scripts. To be honest I had no idea it even exists.
  2. phpinfo() shows that I have always_populate_raw_post_data set to 0 (disabled). So what is going on?

I don't want to "avoid the warning" by setting this value to -1. This will just hide the warning, and I'll still have deprecated configuration. I want to solve the problem at its source and know why PHP thinks that HTTP_RAW_POST_DATA populating is turned on.

解决方案

It turns out that my understanding of the error message was wrong. I'd say it features very poor choice of words. Googling around shown me someone else misunderstood the message exactly like I did - see PHP bug #66763.

After totally unhelpful "This is the way the RMs wanted it to be." response to that bug by Mike, Tyrael explains that setting it to "-1" doesn't make just the warning to go away. It does the right thing, i.e. it completely disables populating the culprit variable. Turns out that having it set to 0 STILL populates data under some circumstances. Talk about bad design! To cite PHP RFC:

Change always_populate_raw_post_data INI setting to accept three values instead of two.

  • -1: The behavior of master; don't ever populate $GLOBALS[HTTP_RAW_POST_DATA]
  • 0/off/whatever: BC behavior (populate if content-type is not registered or request method is other than POST)
  • 1/on/yes/true: BC behavior (always populate $GLOBALS[HTTP_RAW_POST_DATA])

So yeah, setting it to -1 not only avoids the warning, like the message said, but it also finally disables populating this variable, which is what I wanted.

这篇关于关于`$ HTTP_RAW_POST_DATA`的警告已被弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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