简体   繁体   English

如果标题中包含“ Content-Type:application / json”,则不会创建PHP 5.4.9 $ _POST超全局变量

[英]PHP 5.4.9 $_POST superglobal not created if 'Content-Type: application/json' is in header

I noticed a strange bug in my application that happens when using the AWS Elastic Beanstalk PHP 5.4.9 AMI. 我发现应用程序中使用AWS Elastic Beanstalk PHP 5.4.9 AMI时会发生一个奇怪的错误。

When submitting a GET AJAX request that contains the header 'Content-Type: application/json' the $_POST superglobal is set to null. 提交包含标头'Content-Type: application/json'的GET AJAX请求时,$ 'Content-Type: application/json' POST超全局变量将设置为null。 If I remove that header, it is set as expected to a blank array() 如果我删除该标头,则按预期将其设置为空白array()

Is this expected behaviour? 这是预期的行为吗?

Turns out this was an issue with PECL. 原来这是PECL的问题。 When PECL HTTP is installed running PHP 5.4, it causes $_POST to be set to null when a "Content-Type: application/json" header is provided for a GET request. 当安装的PECL HTTP运行PHP 5.4时,如果为GET请求提供了“ Content-Type:application / json”标头,则会导致$ _POST设置为null。 Removing PECL HTTP solves the problem. 删除PECL HTTP可解决此问题。

Credit to Michael@AWS for the find. 归功于Michael @ AWS的发现。 Cross thread: https://forums.aws.amazon.com/message.jspa?messageID=413836 交叉线程: https : //forums.aws.amazon.com/message.jspa?messageID=413836

Edit: Fixed by the PHP team: https://bugs.php.net/bug.php?id=63947&edit=2 编辑:由PHP团队修复: https : //bugs.php.net/bug.php?id=63947& edit =2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM