Issue #2456025 by stefan.r, alexpott, klausi: Rest tests fail on PHP 5.6 because of always_populate_raw_post_data ini setting

8.0.x
webchick 2015-05-19 15:49:00 -07:00
parent fc15f5d8e7
commit ce86b59eba
4 changed files with 30 additions and 0 deletions

View File

@ -39,6 +39,9 @@ AddEncoding gzip svgz
php_value mbstring.http_input pass php_value mbstring.http_input pass
php_value mbstring.http_output pass php_value mbstring.http_output pass
php_flag mbstring.encoding_translation off 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
</IfModule> </IfModule>
# Requires mod_expires to be enabled. # Requires mod_expires to be enabled.

View File

@ -0,0 +1,23 @@
<?php
/**
* @file
* Install, update and uninstall functions for the rest module.
*/
/**
* Implements hook_requirements().
*/
function rest_requirements($phase) {
$requirements = array();
if (version_compare(PHP_VERSION, '5.6.0') >= 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 <a href="https://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data">PHP manual</a> for information on how to correct this.'),
);
}
return $requirements;
}

View File

@ -308,6 +308,8 @@ class CreateTest extends RESTTestBase {
* The body for the POST request. * The body for the POST request.
*/ */
public function assertCreateEntityOverRestApi($entity_type, $serialized = NULL) { 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->httpRequest('entity/' . $entity_type, 'POST', $serialized, $this->defaultMimeType);
$this->assertResponse(201); $this->assertResponse(201);
} }

View File

@ -80,6 +80,8 @@ class CsrfTest extends RESTTestBase {
$curl_options = $this->getCurlOptions(); $curl_options = $this->getCurlOptions();
// Try to create an entity without the CSRF token. // 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->curlExec($curl_options);
$this->assertResponse(403); $this->assertResponse(403);
// Ensure that the entity was not created. // Ensure that the entity was not created.