Warning about `$HTTP_RAW_POST_DATA` being deprecated(关于 `$HTTP_RAW_POST_DATA` 被弃用的警告)
问题描述
我切换到 PHP 5.6.0,现在到处都收到以下警告:
已弃用:自动填充 $HTTP_RAW_POST_DATA 已弃用,并将在未来的版本中被删除.为了避免这个警告集'always_populate_raw_post_data' 到 '-1' 在 php.ini 并使用 php://input 流反而.在第 0 行的未知中警告:无法修改标头信息 - 标头已在第 0 行的未知中发送
好的,我依赖于一些已弃用的功能.除了我没有!
- 我从来没有在我的任何脚本中使用过这个变量.老实说,我什至不知道它的存在.
phpinfo()
表明我已将always_populate_raw_post_data
设置为 0(禁用).那到底是怎么回事?
我不想通过将此值设置为 -1 来避免警告".这只会隐藏警告,我仍然会有弃用的配置.我想从源头解决问题,并知道为什么 PHP 认为 HTTP_RAW_POST_DATA
填充已打开.
原来我对报错信息的理解是错误的.我会说它的单词选择很差.谷歌搜索显示其他人误解了我的消息 - 请参阅 PHP bug #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!
- I haven't ever used this variable in any of my scripts. To be honest I had no idea it even exists.
phpinfo()
shows that I havealways_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` 被弃用的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:关于 `$HTTP_RAW_POST_DATA` 被弃用的警告
基础教程推荐
- Libpuzzle 索引数百万张图片? 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在多维数组中查找最大值 2021-01-01