简体   繁体   中英

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.

When submitting a GET AJAX request that contains the header 'Content-Type: application/json' the $_POST superglobal is set to null. If I remove that header, it is set as expected to a blank array()

Is this expected behaviour?

Turns out this was an issue with 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. Removing PECL HTTP solves the problem.

Credit to Michael@AWS for the find. Cross thread: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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