Bug #69699 [NEW]: file_get_contents("php://input") throws warnings

From: Date: Sun, 24 May 2015 14:41:49 +0000
Subject: Bug #69699 [NEW]: file_get_contents("php://input") throws warnings
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192858@lists.php.net to get a copy of this message
From:             lewismoten at gmail dot com
Operating system: Linux
PHP version:      5.6.9
Package:          Output Control
Bug Type:         Bug
Bug description:file_get_contents("php://input") throws warnings

Description:
------------
I have a PHP page where a JSON object is being passed in the raw post
data. To get this object, I use file_get_contents("php://input"). I'm
getting a warning that in the future, PHP will not support raw streams
of input. To get around this issue with the current version, it says I
need to update the php.ini file setting for
always_populate_raw_post_data. The problem is that the suggested work
around is not possible since I do not have access to modify the php.ini
file.

Even if I was able to fix this in the php.ini file, I am concerned about
the removal of posting raw data to PHP pages in the future.

I would like to turn this warning off in pages that have this problem
via ini_set

I also need to be able to continue to post via RAW data to my PHP pages
in the future.

Test script:
---------------
// use the post method with raw data (less than 2048 bytes)
// and send to a PHP page with the following code

if($_SERVER['REQUEST_METHOD'] !== 'POST') exit;
if((int) $_SERVER['CONTENT_LENGTH'] > 2048) exit;
$input = file_get_contents("php://input");
$data = json_decode($input);

Expected result:
----------------
No warning message.

Able to receive raw post data.

Actual result:
--------------
Warning is displayed:

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

-- 
Edit bug report at https://bugs.php.net/bug.php?id=69699&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=69699&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=69699&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=69699&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=69699&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=69699&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=69699&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=69699&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=69699&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=69699&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=69699&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=69699&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=69699&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=69699&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69699&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=69699&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=69699&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=69699&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69699&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=69699&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=69699&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#192858) next »