Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
We support ini settings in PHP 5, but not in PHP 7.
We should add a <IfModule mod_php7.c>
to .htaccess where users can set default values for PHP 7.
Proposed resolution
Update .htaccess with the default PHP 7 settings that cannot be set at runtime.
Release notes snippet
PHP 5 sections have been removed from all .htaccess files. The root .htaccess file now has a section for PHP 7 settings. Follow the instructions in core/UPDATE.txt.
Comment | File | Size | Author |
---|---|---|---|
#64 | 2455465-64.patch | 2.69 KB | longwave |
Comments
Comment #1
benjy CreditAttribution: benjy at CodeDrop commentedComment #2
cosmicdreams CreditAttribution: cosmicdreams commentedso something like this:
Comment #3
benjy CreditAttribution: benjy at CodeDrop commentedI think we also need to handle input_encoding, output_encoding and internal_encoding, @see https://wiki.php.net/rfc/default_encoding
Comment #4
benjy CreditAttribution: benjy at CodeDrop commentedComment #5
cosmicdreams CreditAttribution: cosmicdreams commentedSo something like: http://stackoverflow.com/questions/12710842/php-internal-encoding ?
Comment #6
stefan.r CreditAttribution: stefan.r commentedComment #7
cosmicdreams CreditAttribution: cosmicdreams commentedComment #8
webchickCan we get a code comment that explains why we're setting those settings?
Comment #9
stefan.r CreditAttribution: stefan.r commentedYes we can...
Comment #10
benjy CreditAttribution: benjy at CodeDrop commentedDoes Unicode::check() need updating for these settings?
Comment #11
stefan.r CreditAttribution: stefan.r commentedI don't see why not, you opened an issue for that didn't you? #2455455: Fix outdated Unicode requirements check
Comment #12
benjy CreditAttribution: benjy at CodeDrop commentedlol, I couldn't remember if I'd created that issue or whether i thought it was happening here.
I did notice that the alignment is different to how we did it for the mod_php5 block. Is that a standard we follow?
Comment #13
stefan.r CreditAttribution: stefan.r commentedJust for reference, the PHP5 block looks like this (values all aligned vertically):
If it's a standard, that's the only place where it's being used as far as I can see ;)
Comment #14
benjy CreditAttribution: benjy at CodeDrop commentedPersonally I prefer how we have it in this patch.
Comment #15
stefan.r CreditAttribution: stefan.r commentedI do too, aligning vertically can actually be problematic and cause conflicts or changes to irrelevant lines when doing patches.
Comment #16
benjy CreditAttribution: benjy at CodeDrop commentedLooks good to me then.
Comment #17
stefan.r CreditAttribution: stefan.r commented@benjy could you review #2455455: Fix outdated Unicode requirements check as well? As you had created that issue to begin with :)
Comment #18
alexpottHere's the thing if these are introduced by PHP5.6 shouldn't we be setting these for PHP5 as well?
Relatedly I think we'll need to cope with the
always_populate_raw_post_data
setting - see #2456025: PHP warnings in PHP 5.6 because of always_populate_raw_post_data ini settingComment #19
stefan.r CreditAttribution: stefan.r commentedThis will still be fine on PHP <5.6?
Comment #20
alexpottJust use the section for php5 above.
Comment #21
Damien Tournoud CreditAttribution: Damien Tournoud at Centarro commentedPlease move *all* of those into a
.user.ini
file. They just don't belong into.htaccess
, and when there they only apply tomod_php
installation, which should be a infinite part of the PHP production installations nowadays (including all major cloud platforms, which are all using PHP-FPM).Comment #22
stefan.r CreditAttribution: stefan.r commentedCan't we do both .htaccess and .user.ini, so this still works with mod_php? See #2463967: Add .user.ini
Comment #23
stefan.r CreditAttribution: stefan.r commentedComment #24
stefan.r CreditAttribution: stefan.r commentedComment #25
stefan.r CreditAttribution: stefan.r commented@Damien Tournoud: in .user.ini files we cannot test for PHP versions, so if we were to ship a .user.ini along with Drupal, it may include deprecated settings for PHP7 users. Would this pose problem or does PHP7 not log any warnings if we use those?
Comment #26
xjmDiscussed with @alexpott. This issue can probably remain normal since sites can fix the .htaccess as needed, but it is a bug.
Let's update the issue summary to specifically explain the impacts of this.
Comment #28
mgiffordPatch no longer applies.
Comment #34
Darren OhRe-rolled patch
Comment #35
Darren OhComment #36
Darren OhComment #38
Darren OhComment #40
Darren OhComment #41
Darren OhUTF-8 is the default encoding in PHP7, so leaving out the encoding settings is fine.
Comment #42
Darren OhAttached wrong patch. Here is the right one.
Comment #43
Darren OhComment #44
Darren OhThe default values for PHP character encoding are correct, so they should not be set. However, .htaccess should contain a PHP7 section for settings that are required.
Comment #45
Darren OhComment #46
pbirk CreditAttribution: pbirk commentedThis installs cleanly against Drupal Core 8.8.0-dev. Marking RTBC.
Comment #47
Darren OhComment #48
demeritcowboy CreditAttribution: demeritcowboy commentedHi,
Is there a similar issue filed for the .htaccess that gets created in sites/default/files? I can't find one. The code is in includes/file.inc in file_htaccess_lines(). (In D8 this delegates to Drupal/Component/Phpstorage/FileStorage which has a similar function htaccessLines().)
Comment #49
Darren OhYes, the issue for the auto-generatated .htaccess in the files directory is #2820611: FileStorage generated .htaccess doesn't cover PHP 7.
Comment #50
demeritcowboy CreditAttribution: demeritcowboy commentedAh thanks.
Comment #51
alexpottI don't think this is a bug per-se. Nothing is broken by not having this in your .htaccess and as a change to the default .htaccess we should have a change record and some release notes because root .htaccess changes can require special upgrade steps.
Comment #52
Darren OhI created a change record.
Comment #53
DamienMcKennaMight this be something that could be backported to 8.7.x presuming it is included in 8.8.x?
Comment #54
Darren OhComment #55
Darren OhComment #56
alexpottThis is looking good but whilst we're here we could remove all the PHP5 stuff from .htaccess files at the same time. We can do this now we don't support PHP5.
Comment #57
alexpottIt'd be good to remove the PHP5 stuff from \Drupal\Component\PhpStorage\FileStorage::htaccessLines too.
Comment #58
DamienMcKennaMight it be worth splitting off the PHP5 removal into a separate issue as this one seems like a tiny shoe-in?
Comment #59
Darren OhAgreed. This is ready to go as is and can be back-ported to 8.7. We can remove PHP 5 support from 8.8 in a separate task.
Comment #60
Darren OhComment #63
Chi CreditAttribution: Chi commentedWe've got another copy of htaccess file that needs to be updated as well.
https://git.drupalcode.org/project/drupal/blob/8.8.x/core/assets/scaffol...
Comment #64
longwaveThis patch addresses #56, #57 and #63. There are no remaining references to mod_php5 in the codebase following this.
Comment #65
Darren OhPatch looks good. Now that Drupal requires PHP 7, this is a bug. It could have been fixed years ago if the scope of the issue had not been expanded unnecessarily.
Comment #66
alexpottAs this is a change in the root .htaccess we need to add a release note about this. I/e complete the @todo section.
Comment #67
Darren OhComment #68
Wim LeersI've actually often wondered about this! Glad to see this happening.
Comment #69
Chi CreditAttribution: Chi commentedComment #70
alexpottCommitted a585dd6a7e and pushed to 9.1.x. Thanks!
Going to ping a release manager about backport to 9.0.x and 8.9.x
Comment #71
alexpott@catch +1'd the backport.
Comment #75
andypostNeeds to fix version and publish
Comment #76
Darren OhDone.
Comment #77
andypostAdded version