From 72a03dc03e7dd8681e21d643a5b584df85ae6dfe Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 25 Aug 2016 15:45:09 -0700 Subject: [PATCH] Add a setup warning for "always_populate_raw_post_data" Summary: Fixes T9235. When the stars align, PHP 5.6 or newer emits a deprecation warning on startup about "always_populate_raw_post_data" which occurs too early for us to intercept and can break responses by adding garbage to the output. These settings appear to be sufficient: ``` always_populate_raw_post_data = 1 display_errors = 1 display_startup_errors = 1 error_reporting = -1 ``` Then make a request with an unusual content type: ``` $ curl -X POST -H "Content-Type: application/json" -d "{foo: bar}" http://phabricator.example.com/ ``` This triggers the warning: ```
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

... ``` To avoid this, just instruct administrators to set this value to "-1", which completely disables the feature and silences the warning. Test Plan: - Reproduced this issue by following the instructions above. - Triggered the setup issue locally and read all the captivating prose: {F1786911} - Made the configuration change it directed me to, saw the setup issue resolve. Reviewers: jcox Reviewed By: jcox Maniphest Tasks: T9235 Differential Revision: https://secure.phabricator.com/D16454 --- .../check/PhabricatorPHPConfigSetupCheck.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php b/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php index b3fd03fd19..ec61b4764d 100644 --- a/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php +++ b/src/applications/config/check/PhabricatorPHPConfigSetupCheck.php @@ -224,5 +224,26 @@ final class PhabricatorPHPConfigSetupCheck extends PhabricatorSetupCheck { ->setSummary($summary) ->setMessage($message); } + + $raw_post_data = (int)ini_get('always_populate_raw_post_data'); + if ($raw_post_data != -1) { + $summary = pht( + 'PHP setting "%s" should be set to "-1" to avoid deprecation '. + 'warnings.', + 'always_populate_raw_post_data'); + + $message = pht( + 'The "%s" key is set to some value other than "-1" in your PHP '. + 'configuration. This can cause PHP to raise deprecation warnings '. + 'during process startup. Set this option to "-1" to prevent these '. + 'warnings from appearing.', + 'always_populate_raw_post_data'); + + $this->newIssue('php.always_populate_raw_post_data') + ->setName(pht('Disable PHP %s', 'always_populate_raw_post_data')) + ->setSummary($summary) + ->setMessage($message) + ->addPHPConfig('always_populate_raw_post_data'); + } } }