{"id":90,"date":"2015-11-03T13:36:42","date_gmt":"2015-11-03T12:36:42","guid":{"rendered":"http:\/\/www.contentecontent.com\/blog\/?p=90"},"modified":"2015-11-03T13:53:19","modified_gmt":"2015-11-03T12:53:19","slug":"mysterious-headers-already-sent-while-handling-phpinput","status":"publish","type":"post","link":"https:\/\/www.contentecontent.com\/blog\/2015\/11\/mysterious-headers-already-sent-while-handling-phpinput\/","title":{"rendered":"Mysterious &#8216;headers already sent&#8217; while handling php:\/\/input stream"},"content":{"rendered":"<p>A script that handled a php:\/\/input stream exited rather unexpectedly when it called <code>session_start()<\/code>. I had &#8216;track_errors&#8217; enabled, so there was a message in <code>$php_errormsg<\/code> saying that headers had already been sent. But there was no file name or line number.<\/p>\n<p><!--more--><\/p>\n<p>Fortunately the error log contained useful information: &#8220;PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set &#8216;always_populate_raw_post_data&#8217; to &#8216;-1\u2019 in php.ini and use the php:\/\/input stream instead. in Unknown on line 0&#8221;.<\/p>\n<p>The message must have been echoed, leading to the &#8216;headers already sent&#8217; message when <code>session_start<\/code> tried to set a cookie.<\/p>\n<p>Setting <code>always_populate_raw_post_data<\/code> to <code>-1<\/code> in php.ini indeed made the error go away.<\/p>\n<p>Hope this helps someone.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A script that handled a php:\/\/input stream exited rather unexpectedly when it called session_start(). I had &#8216;track_errors&#8217; enabled, so there was a message in $php_errormsg saying that headers had already been sent. But there was no file name or line number.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[7],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-misc","tag-php"],"_links":{"self":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":4,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":94,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/90\/revisions\/94"}],"wp:attachment":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}