Bug #66763 [Com]: always_populate_raw_post_data=0 BC issue with in-built web server
| From: | matt at piwik dot org | Date: | Sun, 19 Oct 2014 22:40:16 +0000 |
| Subject: | Bug #66763 [Com]: always_populate_raw_post_data=0 BC issue with in-built web server | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188191@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66763&edit=1
ID: 66763
Comment by: matt at piwik dot org
Reported by: sixd@php.net
Summary: always_populate_raw_post_data=0 BC issue with
in-built web server
Status: Suspended
Type: Bug
Package: Built-in web server
Operating System: Linux
PHP Version: 5.6Git-2014-02-24 (Git)
Assigned To: tyrael
Block user comment: N
Private report: N
New Comment:
Currently the message implies that we are using $HTTP_RAW_POST_DATA but actually it's not
used.
Maybe it would be worth updating the error message to explain that the setting should be set to -1
even in cases where $HTTP_RAW_POST_DATA is not used?
Or maybe you could only show the Warning when $HTTP_RAW_POST_DATA is used?
Looking online a lot of people have a problem that this warning is output by default in 5.6
configuration and this seems to confuse many users including advanced PHP users.
Also we noticed that always_populate_raw_post_data cannot be set with ini_set(), it must be set in
php.ini which requires admin access to the server.
Reference: issue on Piwik project https://github.com/piwik/piwik/issues/6465
Previous Comments:
------------------------------------------------------------------------
[2014-04-18 16:57:41] mike@php.net
Sorry, no offense intended! :)
I doubt it classifies as a *real* BC break because a production server should probably not output
any warning, I agree though, that it might pop up in development, and that, as far as I am
concerned, is a very good thing.
I really appreciate that Ferenc made it possible to bring this enhancement into 5.6
------------------------------------------------------------------------
[2014-04-18 16:02:35] tyrael@php.net
I think mike's summary a bit too compact/dense.
The current warning is indeed was my idea to allow the introducion of mike's slim post data rfc
in 5.6:
https://wiki.php.net/rfc/slim_post_data
the original implementation would have caused more serious BC breaks, you can read more about it in
the "[RFC] Slim POST data (was: PHP-5.6 and $HTTP_RAW_POST_DATA)" thread.
I guess we can improve the current situation for the developer server though.
------------------------------------------------------------------------
[2014-03-25 09:32:30] mike@php.net
This is the way the RMs wanted it to be.
------------------------------------------------------------------------
[2014-02-24 19:12:50] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66763&edit=1