From ce86b59eba48430675e88d7039453a97fb0a7673 Mon Sep 17 00:00:00 2001 From: webchick Date: Tue, 19 May 2015 15:49:00 -0700 Subject: [PATCH] Issue #2456025 by stefan.r, alexpott, klausi: Rest tests fail on PHP 5.6 because of always_populate_raw_post_data ini setting --- .htaccess | 3 +++ core/modules/rest/rest.install | 23 ++++++++++++++++++++++ core/modules/rest/src/Tests/CreateTest.php | 2 ++ core/modules/rest/src/Tests/CsrfTest.php | 2 ++ 4 files changed, 30 insertions(+) create mode 100644 core/modules/rest/rest.install diff --git a/.htaccess b/.htaccess index fd7bd2917e..c29b0d5177 100644 --- a/.htaccess +++ b/.htaccess @@ -39,6 +39,9 @@ AddEncoding gzip svgz php_value mbstring.http_input pass php_value mbstring.http_output pass php_flag mbstring.encoding_translation off + # PHP 5.6 has deprecated $HTTP_RAW_POST_DATA and produces warnings if this is + # not set. + php_value always_populate_raw_post_data -1 # Requires mod_expires to be enabled. diff --git a/core/modules/rest/rest.install b/core/modules/rest/rest.install new file mode 100644 index 0000000000..2afe0b5365 --- /dev/null +++ b/core/modules/rest/rest.install @@ -0,0 +1,23 @@ += 0 && ini_get('always_populate_raw_post_data') != -1) { + $requirements['always_populate_raw_post_data'] = array( + 'title' => t('always_populate_raw_post_data PHP setting'), + 'value' => t('Not set to -1.'), + 'severity' => REQUIREMENT_ERROR, + 'description' => t('The always_populate_raw_post_data PHP setting should be set to -1 in PHP versions 5.6 and up. Please check the PHP manual for information on how to correct this.'), + ); + } + return $requirements; +} diff --git a/core/modules/rest/src/Tests/CreateTest.php b/core/modules/rest/src/Tests/CreateTest.php index 98b944a461..4badd7dd5f 100644 --- a/core/modules/rest/src/Tests/CreateTest.php +++ b/core/modules/rest/src/Tests/CreateTest.php @@ -308,6 +308,8 @@ public function createAccountPerEntity($entity_type) { * The body for the POST request. */ public function assertCreateEntityOverRestApi($entity_type, $serialized = NULL) { + // Note: this will fail with PHP 5.6 when always_populate_raw_post_data is + // set to something other than -1. See https://www.drupal.org/node/2456025. $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, $this->defaultMimeType); $this->assertResponse(201); } diff --git a/core/modules/rest/src/Tests/CsrfTest.php b/core/modules/rest/src/Tests/CsrfTest.php index a686f44804..a438b173ed 100644 --- a/core/modules/rest/src/Tests/CsrfTest.php +++ b/core/modules/rest/src/Tests/CsrfTest.php @@ -80,6 +80,8 @@ public function testCookieAuth() { $curl_options = $this->getCurlOptions(); // Try to create an entity without the CSRF token. + // Note: this will fail with PHP 5.6 when always_populate_raw_post_data is + // set to something other than -1. See https://www.drupal.org/node/2456025. $this->curlExec($curl_options); $this->assertResponse(403); // Ensure that the entity was not created. -- GitLab