|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-02-24 19:12 UTC] sixd@php.net
Description: ------------ Always_populate_raw_post_data=0 causes the in-built web server to display a deprecatation warning. Backwards compatibility is broken because headers are sent. The warning should only ever be sent when always_populate_raw_post_data=1 though this is debatable because any warning would break code similar to the testcase. Test script: --------------- A testcase is based on http://www.whitewashing.de/2014/01/31/soap_and_php_in_2014.html Create these two files: server.php <?php // server.php class MyService { public function add($x, $y) { return $x + $y; } } $options = array( 'uri' => 'http://localhost/namespace', 'location' => 'http://localhost:8899/server.php', ); $server = new SOAPServer(null, $options); $server->setObject(new MyService()); $server->handle(); ?> client.php: <?php // client.php $options = array( 'uri' => 'http://localhost/namespace', 'location' => 'http://localhost:8899/server.php', ); $client = new SOAPClient(null, $options); echo $client->add(10, 10); ?> Expected result: ---------------- Start the PHP 5.6 in-built webserver with: $ php56 -d always_populate_raw_post_data=-1 -S 0.0.0.0:8899 or use PHP 5.5: $ php55 -d always_populate_raw_post_data=0 -S 0.0.0.0:8899 Then execute the client in a terminal shell: $ php56 client.php The expected output of '20' is displayed. Starting the PHP 5.6 server with always_populate_raw_post_data=0 should similarly allow client.php to work: $ php56 -d always_populate_raw_post_data=0 -S 0.0.0.0:8899 Actual result: -------------- With the default php.ini files, then either of these two PHP 5.6 cases cause the test to fail. This is a BC break. $ php56 -d always_populate_raw_post_data=0 -S 0.0.0.0:8899 or with the default php.ini value (which is always_populate_raw_post_data=0): $ php56 -S 0.0.0.0:8899 Then the client fails with the text: Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in /home/cjones/public_html/soap/client.php:10 Stack trace: #0 /home/cjones/public_html/soap/client.php(10): SoapClient->__call('add', Array) #1 /home/cjones/public_html/soap/client.php(10): SoapClient->add(10, 10) #2 {main} thrown in /home/cjones/public_html/soap/client.php on line 10 The web server displays: [Mon Feb 24 10:56:46 2014] 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. in Unknown on line 0 [Mon Feb 24 10:56:46 2014] PHP Warning: Cannot modify header information - headers already sent in Unknown on line 0 [Mon Feb 24 10:56:46 2014] PHP Warning: Cannot modify header information - headers already sent in /home/cjones/public_html/soap/server.php on line 20 [Mon Feb 24 10:56:46 2014] PHP Warning: Cannot modify header information - headers already sent in /home/cjones/public_html/soap/server.php on line 20 [Mon Feb 24 10:56:46 2014] 127.0.0.1:47848 [200]: /server.php PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 08:00:01 2025 UTC |
> The current error message tells you the problem ($HTTP_RAW_POST_DATA is deprecated, and will be gone in a future version), and how to remove the warning (always_populate_raw_post_data=-1) and what should you use instead of $HTTP_RAW_POST_DATA(php://input). Just to repeat/confirm: we do not use $HTTP_RAW_POST_DATA and we only use php://input. Yet the deprecated notice is thrown. Isn't that a bug? at least the error message should be changed because it is currently incorrect? (It suggests us to use php://input but this is what we are already using this AFAIK.) > running with display_errors=On in production is a bad practice It's bad practise but it's also the default configuration. Bad practise == default == widespread (ie. dozens of thousands of servers running with display_errors on). > imo a normal user would just either change this in the php.ini or complain to their hoster/developer to fix the issue after upgrading their php installation. agreed but still it means thousands of hours of frustration for users. Now I have an idea that could solve the problem nicely for us: could you make ini_set work for this setting value? ini_set('always_populate_raw_post_data', -1); This would provide very nice workaround for us and many other PHP apps that could just add this ini_set. Thanks for considering!