mattab commented on Oct 19 2014                                                    

Our build fails on 5.6 because of this warning.

It's quite annoying and I find lots of people online with the problem.

I'm not sure the proper way to fix this. a search in our code shows we don't use $HTTP_RAW_POST_DATA.

Maybe we really need to edit php.ini and set always_populate_raw_post_data to -1? (in this case we'd have to add system check to check users have set it to -1).

See also:

 

@mattab mattab added Task c: Tests & QA labels on Oct 19 2014                                            

@mattab mattab added this to the Piwik 2.9.0 milestone on Oct 19 2014                                            

@mattab mattab added a commit that referenced this issue on Oct 19 2014                                            

@mattab                                                        refs #6465 Allow 5.6 build to fail - note: we must find proper soluti…                                                          76a74f5                                                        
@mnapoli                                            
 Member                                                    

mnapoli commented on Oct 19 2014                                                    

always_populate_raw_post_data=-1
                                                                   

that would solve the problem if we don't use the variable that was deprecated (if I understand it correctly).

What I don't understand though is that the warning appears regardless of whether an application uses that variable… I've had that warning on very small scripts that didn't use the variable at all. I find it weird that PHP 5.6 ships like that, maybe I'm missing something.

 

@mattab mattab modified the milestone: Piwik 2.9.0Piwik 2.8.1 on Oct 19 2014                                            

@mattab                                            
 Owner                                                    

mattab commented on Oct 19 2014                                                    

I find it weird that PHP 5.6 ships like that, maybe I'm missing something.

I think it could be a bug in PHP 5.6 that was overlooked. Or maybe it's also triggered when something else than this variable is used. For example in the case of Piwik it seems to be triggered only for afew tests, those tests maybe that use Bulk tracking only? in bulk tracking for example we use file_get_contents("php://input"); maybe this or something else would also trigger the warning?

 

 mnapoli self-assigned this on Oct 20 2014                                            

@mnapoli                                            
 Member                                                    

mnapoli commented on Oct 20 2014                                                    

It seems like there are several people meeting the same problem with codebases not using HTTP_RAW_POST_DATA:

When we read PHP 5.6 migration guide we read:

always_populate_raw_post_data will now generate an E_DEPRECATED error when enabled.

It seems that it's simple: to not get the deprecation, you need to disable this in php.ini.

i just find it stupid that PHP 5.6 ships with a config that makes it throw deprecation warnings automatically…

 

 mnapoli added a commit that referenced this issue on Oct 20 2014                                            

                                                       Fixes #6465 Tests failures with PHP 5.6                                                          5f87625                                                        
@mnapoli                                            
 Member                                                    

mnapoli commented on Oct 20 2014                                                    

As a follow up, using ini_set() to set always_populate_raw_post_data doesn't work. We need to use php.ini.

 

 mnapoli closed this in de8e60b on Oct 20 2014                                            

 

@mattab mattab referenced this issue on Oct 20 2014                                            

 Closed                                            

Add system check to enforce always_populate_raw_post_data is -1 on PHP 5.6#6468                                            

@mnapoli                                            
 Member                                                    

mnapoli commented on Oct 21 2014                                                    

I got some feedback from the dev that added that to PHP (http://fr.reddit.com/r/PHP/comments/2jpzzj/php_56_throws_e_deprecated_by_default_for_no/):

the default value is 0, as you can see here: http://lxr.php.net/xref/PHP_5_6/main/main.c#641                                                                        

what I was referring to by -1 was the suggested default php.ini files (http://lxr.php.net/xref/PHP_5_6/php.ini-development[2] http://lxr.php.net/xref/PHP_5_6/php.ini-production).

but those lines are commented out, so even distros which use those files as-is for the default php.ini will have always_populate_raw_post_data=0

and the E_DEPRECATED message is triggered when we actually populate the $HTTP_RAW_POST_DATA

So yes, by default PHP 5.6 ships with a configuration that throws deprecated notices… The only fix is for users to add this to their php.ini:

always_populate_raw_post_data=-1
                                                                   

For reference, the #internals discussion: http://www.serverphorums.com/read.php?7,1048319,1048407                                                                    

 
@diosmosis                                            
 Member                                                    

diosmosis commented on Oct 21 2014                                                    

Do you know what triggers the error? If so, maybe we can use a custom error handler to ignore the error so at least it won't break Piwik for people who upgrade.

 
@mnapoli                                            
 Member                                                    

mnapoli commented on Oct 21 2014                                                    

Some HTTP requests. It's not related to the code.

 
@diosmosis                                            
 Member                                                    

diosmosis commented on Oct 21 2014                                                    

Maybe we can catch it in Piwik's error handler? I guess if PHP throws it on startup, then not so much.

 
@mattab                                            
 Owner                                                    

mattab commented on Oct 21 2014                                                    

FYI I posted new comment on the bug, it's our duty to fight for our users, won't give up so easily ;-) https://bugs.php.net/bug.php?id=66763                                                                    

 
@bramus                                            
 

bramus commented on Oct 25 2014                                                    

@mnapoli RE: "Some HTTP requests."

By the looks of it: requests that use a payload, instead of regular requests (which use form-urlencoded encoded data)

Works fine:

$ curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "foo=bar" http://domain.tld/
                                                                   

Throws out a Deprecated warning:

$ curl -X POST -H "Content-Type: application/json" -d "{foo: bar}" http://domain.tld/
                                                                   

Ajax requests done using jQuery for example use a payload, and thus will trigger the warning :-1:                                                                        

 

 Unknown referenced this issue in owncloud/core on Oct 29 2014                                            

 Closed                                            

PHP 5.6 compability #10700                                            

@mattab                                            
 Owner                                                    

mattab commented on Nov 6 2014                                                    

users start to report this error eg. in this forum post                                                                    

 
@bramus                                            
 

bramus commented on Nov 6 2014                                                    

@mattab                                            
 Owner                                                    

mattab commented on Nov 27 2014                                                    

FYI added system check in #6468 to let users know about this pro-actively

 

This was referenced on Dec 18 2014

 Closed                                                

Cannot Star/Unstar : Internal Error SSilence/selfoss#565                                                    

 Closed                                                

Documents app broken on master owncloudarchive/documents#431                                                    

 Open                                                

Issue with AJAX File Uploads in 2.6.0. ryancramerdesign/ProcessWire#1174                                                    

@powtac                                            
 

powtac commented on May 18 2015                                                    

Maybe http://3v4l.org can help to spot the version differences?

Made a quick test: http://3v4l.org/bO96q seems to change nothing.

 
@mnapoli                                            
 Member                                                    

mnapoli commented on May 18 2015                                                    

@powtac it's a INI setting that cannot be changed in a PHP file (it's a PHP_INI_PERDIR setting: http://php.net/manual/en/ini.core.php so read this)

 
@powtac                                            
 

powtac commented on May 18 2015                                                    

I see! Sorry.

 

This was referenced on Jun 3 2015

 Closed                                                
 Closed                                                

@fishilico fishilico added a commit to Polytechnique-org/platal that referenced this issue on Oct 5 2015                                            

@fishilico                                                        Replace deprecated $HTTP_RAW_POST_DATA with file_get_contents("php://…                                                          3904bb1                                                        
@justincletus                                            
 

justincletus commented on Feb 23 2016                                                    

always_populate_raw_post_data PHP setting Not set to -1. for drupal 8 site report shows this error how to fix it

 

@wethod wethod pushed a commit to wethod/wethod-heroku-buildpack-prod that referenced this issueon Nov 18 2016                                            

                                                       Fix for: ‘Automatically populating $HTTP_RAW_POST_DATA is deprecated …                                                          48b448c                                                        
@dicePrime                                            
 

dicePrime commented on Jan 22                                                    

Apparently it is a bug from PHP 5.6 i stop receiving this warning after switching to php 7.0.10

 
@mattab                                            
 Owner                                                    

mattab commented on Feb 18                                                    

Yes upgrading to PHP7 will fix this issue automatically :+1:                                                                        

 

 DaazKu referenced this issue in vanilla/vanilla on Apr 20                                            

 Merged                                            

Improve unit testing compatibility with Travis CI #5445                                            

4 of 4 tasks complete                                        
 
Sign up for free to join this conversation on GitHub. Already have an account? 



来自  https://github.com/piwik/piwik/issues/6465

                                           

最近做了一个程序,部署在 SAE 上,环境是 PHP 5.6。
今天看了一下 SAE 上的日志,debug 中上万条日志提示:

PHP 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.
                                                           

因为我这个程序是和微信公众号对接的,微信会把消息体以 XML 的结构 POST 到我这边,所以我现在使用 file_get_contents('php://input') 来获取消息。

不知道是不是我对这条 debug 理解有问题,说的应该是推荐用 php://input 吧?但怎么还每一次都有警告呢?

难道 5.6 之后不推荐这个方式了?那用什么方式来代替呢?谢谢~

第 1 条附言  ·  2015-08-10 20:13:34 +08:00                                                     
根据讨论,估计是 SAE 环境的问题,目前已经发工单给 SAE,尚未得到回复,有结果了再 APPEND
第 2 条附言  ·  2015-08-18 15:12:54 +08:00                                                     
SAE 给的答复: 
您好,为了 PHP5.6 环境的兼容性,暂时不会将这个警告的 ini 选项关闭,这个警告不影响 PHP5.6 环境的正常使用。
 
14 回复  |  直到 2015-08-10 20:14:41 +08:00                                                
                                                                
    1                                                                    
 xbonline   2015-08-10 16:15:23 +08:00                                                                     
To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input 
stream instead. 
已經說得很清楚了嘛
                                                                
    2                                                                    
 honkew   2015-08-10 16:15:57 +08:00                                                                     
为什么不用$_POST呢,这是取信息流吧,$HTTP_RAW_POST_DATA全局变量应该能取到
                                                                
    3                                                                    
 iugo   2015-08-10 16:20:06 +08:00                                                                     
最近在做微信开发的时候用到. 官方文档说建议使用 php://input. 

在 PHP 7 中, 会完全摒弃 HTTP_RAW_POST_DATA. 后者会消耗更多的资源, 并且功能可以被完全取代, 所以取消了. 在 ini 中的配置项也失效.
                                                                
    4                                                                    
 abelyao   2015-08-10 16:21:50 +08:00                                                                     
@xbonline 
谢谢,我是已经使用 file_get_contents('php://input') 了,而且没有在其它地方用到 $HTTP_RAW_POST_DATA,另外 SAE 的环境不能修改 php.ini 配置吧? 

@honkew 
因为微信服务器 POST 过来不是以某个字段 POST 过来的,而是将整个内容 POST 过来。话说这个警告不就是说不要用 $HTTP_RAW_POST_DATA 来或吗?
                                                                
    5                                                                    
 abelyao   2015-08-10 16:22:55 +08:00                                                                     
@iugo 那我的理解应该木有错啊,用 php://input 是对的,可是在 SAE 的环境中也没办法修改 php.ini 来去掉这个警告…
                                                                
    6                                                                    
 honkew   2015-08-10 16:38:27 +08:00                                                                     
能正常使用 直接屏蔽掉这个错误就好 
@file_get_contents('php://input');
                                                                
    7                                                                    
 abelyao   2015-08-10 16:39:27 +08:00                                                                     
@honkew ……对哦,把这个给忘了
                                                                
    8                                                                    
 gongpeione   2015-08-10 16:40:26 +08:00                                                                     
ini_set('always_populate_raw_post_data', '-1'); 用这个?
                                                                
    9                                                                    
 abelyao   2015-08-10 16:54:33 +08:00                                                                     
@honkew 加了 @ 也没用…… 

@gongpeione 
在 index.php 入口文件的第一行加了这句话也没用… 还是抛出警告,估计是 SAE 屏蔽了这个函数…
                                                                
    10                                                                    
 msxcms   2015-08-10 19:10:06 +08:00                                                                     
扔掉 SAE
                                                                
    11                                                                    
 realpg   2015-08-10 19:37:42 +08:00                                                                     
@abelyao SAE的PHP不是一般的PHP 
他可能再内部转换了你的php://input为那个 然后就抛这个问题了…… 
他的PHP改得乱七八糟的
                                                                
    12                                                                    
 abelyao   2015-08-10 19:53:36 +08:00 via iPhone                                                                     
@realpg 确实改得太多… 据说连 curl 也都是重新封装过的…
                                                                
    13                                                                    
 kn007   2015-08-10 19:57:04 +08:00                                                                     
@abelyao 确实都是重新封装过的,很多函数。
                                                                
    14                                                                    
 abelyao   2015-08-10 20:14:41 +08:00                                                                     
@kn007 发了个工单给 SAE,主要是因为 debug 日志里面全被这条警告占满了,影响了日志的作用,看看 SAE 怎么答复吧。

来自 https://www.v2ex.com/t/212133