If you run the rest
group of tests you can plenty of errors because PHP 5.6 will automatically pump out a warning if the always_populate_raw_post_data
is not set -1 see https://bugs.php.net/bug.php?id=66763.
Basically
you need both display_errors and display_startup_errors enabled to have a realistic chance to be affected by the deprecated message introduced in 5.6 other than having a some additional lines in your php error log.
Well our test infrastructure has a 100% chance.
tl;dr The default value for always_populate_raw_post_data in PHP 5.6 is doing more harm than good. Perfectly good code will spit out that error whenever it receives a request that has a (non-application/x-www-form-urlencoded encoded) payload. To fix it, explicitly set the value of always_populate_raw_post_data to -1 in your php.ini.
From https://www.bram.us/2014/10/26/php-5-6-automatically-populating-http_raw...
Drupal\rest\Tests\CreateTest
fails with:
Fatal error: Call to a member function uuid() on null in /Volumes/devdisk/dev/sites/drupal8alt.dev/core/modules/rest/src/Tests/CreateTest.php on line 328
FATAL Drupal\rest\Tests\CreateTest: test runner returned a non-zero error code (255).
- Found database prefix 'simpletest166449' for test ID 35.
[19-Mar-2015 23:55:10 Europe/Zurich] PHP Fatal error: Call to a member function uuid() on null in /Volumes/devdisk/dev/sites/drupal8alt.dev/core/modules/rest/src/Tests/CreateTest.php on line 328
- Removed test site directory.
- Removed 56 leftover tables.
And Drupal\rest\Tests\CsrfTest 20 passes 5 fails
We need to set always_populate_raw_post_data
to -1 and the warning goes away.
To test just run either test with php 5.6.
Comment | File | Size | Author |
---|---|---|---|
#29 | interdiff-2456025-21-29.txt | 1.3 KB | roderik |
#29 | php_warnings_in_php_5_6-2456025-29.patch | 1.45 KB | roderik |
#21 | php_warnings_in_php_5_6-2456025-21.patch | 1.42 KB | cilefen |
#8 | 2456025-8.patch | 2.97 KB | stefan.r |
#8 | interdiff-7-8.txt | 1.06 KB | stefan.r |
Comments
Comment #1
alexpottComment #2
klausiHighly obscure. So as the linked blog post points out we cannot use ini_set() to fix this. Which means we can only fix this for Apache as you did in your patch.
So people will run into this problem when they run the tests on Nginx for example. We should probably document at https://www.drupal.org/requirements/php#settings or https://www.drupal.org/requirements/php#drupalversions that Drupal 8 needs
always_populate_raw_post_data = -1
for REST.Maybe we should also document at the test cases that they will fail on PHP 5.6 when this setting is wrong?
Comment #3
stefan.r CreditAttribution: stefan.r commentedAdded a little warning in the test cases and got rid of vertical alignment which could be problematic down the line
Comment #5
stefan.r CreditAttribution: stefan.r commentedComment #6
klausiI think we should not change the indentation of the assigned values in this issue, let's leave it as is.
I think we should replace the "and" with "when".
How about we implement hook_requirements() in rest.install to check PHP 5.6 for this setting?
Comment #7
stefan.r CreditAttribution: stefan.r commentedComment #8
stefan.r CreditAttribution: stefan.r commentedComment #9
klausiWe should also check the PHP version here, since this is only a problem on PHP >= 5.6.0. We don't need to nag users if it does not concern them.
I don't think we need the REQUIREMENT_OK part, since this information is not that important and just clutters the status report page.
This comment should also be updated to use "when", same as the other one.
Comment #10
stefan.r CreditAttribution: stefan.r commentedComment #11
stefan.r CreditAttribution: stefan.r commentedComment #12
klausiThanks a lot, looks good to me now.
Did a bit of manual testing on Ubuntu 15.04 and hook_requirements() triggers as expected when the ini setting is wrong.
Comment #13
webchickCommitted and pushed to 8.0.x. Thanks!
Comment #15
BerdirSo this broke InstallUninstallTest in PHP 7. See #2454439-98: [META] Support PHP 7 for the fun details. We need an additional condition to not run this on PHP 7 since this ini setting no longer exists there.
No need to revert, we just need to extend it a bit. I'll open a issue tomorrow, but if someone wants to work on it, please do so.
Comment #16
stefan.r CreditAttribution: stefan.r commentedThe follow-up issue: #2496943: Add condition to ignore PHP 7 on rest requirements check
Comment #18
cilefen CreditAttribution: cilefen commentedThis has been reported in D7 #2524240: $HTTP_RAW_POST_DATA Deprecated in PHP 5.6, Causing Warnings in D7 Error Logs.
Comment #19
cilefen CreditAttribution: cilefen commentedComment #20
longwaveThere is a typo in the error message in this patch ("HP" instead of "PHP"), and shouldn't we take into account #2496943: Add condition to ignore PHP 7 on rest requirements check at the same time and make this apply to PHP 5.6 only, rather than 5.6 and up?
Comment #21
cilefen CreditAttribution: cilefen commentedThank you @longwave. The reason that happened is too silly to mention here.
Comment #26
danquah CreditAttribution: danquah at Reload commentedHi
I just walked through the following test on a Debian Jessie with PHP 5.6.9
All in all the patch seems to work as expected.
Comment #27
Liam MorlandComment #28
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedFrom #20:
Yeah, I agree we should incorporate that at the same time. Marking needs work for that.
Also a minor issue (and I think affects Drupal 8 too):
We usually like to leave the
/en/
out of php.net URLs in the user interface. That way we don't assume a language and the user gets sent to the correct language via whatever mechanism php.net uses to detect that.Comment #29
roderikIncorporated comments from #20 and #28. Also opened #2591919: Reference php.net 'international' URL in help text for D8 (indeed it affects Drupal 8 too).
Comment #30
Beanjammin CreditAttribution: Beanjammin at emedia.ca commentedI ran into this while doing a fresh D8 RC2 install on PHP 5.6.15 on Apache 2 with PHP being run via the CGI interface. The .htaccess configuration that is supposed to set always_populate_raw_post_data to -1 had no effect because it is inside a
<IfModule mod_php5.c> tag
and so will not be run when using anything other than mod_php on Apache. This resulted in the D8 install hanging at "Initializing" in the Install Site stage of the install.I think it would make sense to test for the PHP version and the configuration of always_populate_raw_post_data to -1 at the Verify Requirements stage of the install process to provide a warning and instructions on how to correct the problem in php.ini. This will help people using PHP 5.6.x with something other than Apache and mod_php.
Comment #31
Beanjammin CreditAttribution: Beanjammin at emedia.ca commentedComment #32
cilefen CreditAttribution: cilefen commented@Beanjammin This one has already been committed to Drupal 8. Please open a new follow-up issue for the additional work and link it here.
Comment #33
Beanjammin CreditAttribution: Beanjammin at emedia.ca commentedThanks for letting me know, with the issue still flagged as needing review it wasn't obvious that it had already been commited.
I have posted a patch to #2485847: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version
Comment #34
devurandom CreditAttribution: devurandom commentedThis causes the symptoms of issue #2501851: Install Fails on WAMP (Drupal\Core\Config\UnmetDependenciesException: Configuration objects) to appear on my Lighttpd 1.4 installation with PHP-FPM 5.6.14.
Comment #36
devurandom CreditAttribution: devurandom commentedP.S: php-fpm uses .user.ini files, where the php.ini settings can be overridden on a per-application / per-directory basis.
Comment #37
Justincletus CreditAttribution: Justincletus commentedHi, To which file to apply the patch on the directory..
Comment #42
hkirsman CreditAttribution: hkirsman commentedEdit: my bad. Sorry for spam.
Comment #43
Wim LeersThis was committed before 8.0.0. For a backport to D7, a new issue should be created.
Note this also introduced a small regression: #2931883: Unneeded always_populate_raw_post_data requirements check while on CLI.
Comment #44
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedIt's best not to just close issues that have a patch to review, without first making sure there is actually another issue open to track it. Otherwise, the patch tends to get lost.
In this case, there was #2524240: $HTTP_RAW_POST_DATA Deprecated in PHP 5.6, Causing Warnings in D7 Error Logs, but it was marked as a duplicate of this one. I reopened it now to discuss the Drupal 7 backport. I'm not sure this actually does make sense to backport, but in any case, discussion can continue there.
Comment #45
Wim LeersI agree in theory, but that requires that in practice D7 maintainers do file such issues. This hasn't moved forward since November 2015, >2 years ago, so rather than keeping things confusing for related D8 issues, I'd rather have clarity for D8, rather than ambiguity for both D7 and D8.
Comment #46
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI don't think it's specifically the responsibility of D7 maintainers to do that (and in any case, there are very few D7 maintainers still active, maybe like 5%). If we're going to ask them to do anything at all, I think closing old issues and then opening new ones for the same purpose is not high on the priority list :) It really should be up to whoever wants the issue closed to make sure there are followups created for whatever was keeping it open in the past.
Comment #48
ugintl CreditAttribution: ugintl commentedCan someone please tell me which patch is for D7?