php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63947 $_POST set as NULL for GET when Content-Type is set as application/json
Submitted: 2013-01-08 20:27 UTC Modified: 2013-10-01 09:31 UTC
From: gholland85 at gmail dot com Assigned: mike (profile)
Status: Closed Package: pecl_http (PECL)
PHP Version: 5.4.10 OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gholland85 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-01-08 20:27 UTC] gholland85 at gmail dot com
Description:
------------
When submitting a GET request with the header 'Content-Type: application/json' the  
$_POST superglobal is set to NULL. It should always be an empty array. Although 
the Content-Type is not required for a GET, some client side frameworks such as 
backbone and spine include it by default, regardless of whether is is a GET, PUT 
or POST. PHP frameworks such as Symfony2 expect the $_POST superglobal to be an 
array at all times. 

Test script:
---------------
<?php


/**
When accessing this via a GET request with the Content-Type header set to application/json, the $_POST superglobal is set to NULL. It should be set as a blank array.
**/


var_dump($_POST);
die();

?>

Expected result:
----------------
array()

Actual result:
--------------
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-09 12:32 UTC] mike@php.net
-Assigned To: +Assigned To: mike
 [2013-01-09 13:14 UTC] mike@php.net
Automatic comment from SVN on behalf of mike
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=329042
Log: Fix bug #63947 $_POST set as NULL for GET when Content-Type is set as application/json
 [2013-01-09 13:15 UTC] mike@php.net
-Status: Assigned +Status: Closed
 [2013-01-09 13:15 UTC] mike@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 [2013-10-01 00:43 UTC] k94ur2 at idirect dot com
This bug is also a problem on Windows 8 and Windows XP platforms.  This bug fix has not been implemented on PHP 5.4 releases up to 5.4.19.
 [2013-10-01 09:31 UTC] mike@php.net
The only interesting version number regarding this bug is the version number of the pecl_http extension.
 [2014-08-05 16:50 UTC] mike@php.net
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=pecl/http/pecl_http.git;a=commit;h=b4920d7ad19ae6704e10cb29fca652b47e1bc61f
Log: Fix bug #63947 $_POST set as NULL for GET when Content-Type is set as application/json
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC