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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

benjy’s picture

cosmicdreams’s picture

FileSize
367 bytes

so something like this:

benjy’s picture

Issue summary: View changes

I think we also need to handle input_encoding, output_encoding and internal_encoding, @see https://wiki.php.net/rfc/default_encoding

benjy’s picture

Issue summary: View changes
cosmicdreams’s picture

stefan.r’s picture

Status: Active » Needs review
FileSize
491 bytes
cosmicdreams’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Needs work

Can we get a code comment that explains why we're setting those settings?

stefan.r’s picture

Status: Needs work » Needs review
FileSize
671 bytes

Yes we can...

benjy’s picture

Does Unicode::check() need updating for these settings?

stefan.r’s picture

I don't see why not, you opened an issue for that didn't you? #2455455: Fix outdated Unicode requirements check

benjy’s picture

lol, 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?

stefan.r’s picture

Just for reference, the PHP5 block looks like this (values all aligned vertically):

<IfModule mod_php5.c>
  php_flag session.auto_start               off
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_flag mbstring.encoding_translation    off
</IfModule>

If it's a standard, that's the only place where it's being used as far as I can see ;)

benjy’s picture

Personally I prefer how we have it in this patch.

stefan.r’s picture

I do too, aligning vertically can actually be problematic and cause conflicts or changes to irrelevant lines when doing patches.

benjy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me then.

stefan.r’s picture

@benjy could you review #2455455: Fix outdated Unicode requirements check as well? As you had created that issue to begin with :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#2456025: PHP warnings in PHP 5.6 because of always_populate_raw_post_data ini setting
+++ b/.htaccess
@@ -41,6 +41,16 @@ AddEncoding gzip svgz
+# PHP 5.6 and up introduces default encoding settings. Set these to UTF-8
+# to comply with Drupal's Unicode requirements check.
+# See https://wiki.php.net/rfc/default_encoding.
+<IfModule mod_php7.c>

Here'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 setting

stefan.r’s picture

Status: Needs work » Needs review
FileSize
868 bytes

This will still be fine on PHP <5.6?

alexpott’s picture

Status: Needs review » Needs work
+++ b/.htaccess
@@ -41,6 +41,22 @@ AddEncoding gzip svgz
+<IfModule mod_php5.c>
+  php_value default_charset "UTF-8"
+  php_value php.input_encoding "UTF-8"
+  php_value php.internal_encoding "UTF-8"
+  php_value php.output_encoding "UTF-8"
+</IfModule>

Just use the section for php5 above.

Damien Tournoud’s picture

Please move *all* of those into a .user.ini file. They just don't belong into .htaccess, and when there they only apply to mod_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).

stefan.r’s picture

Can't we do both .htaccess and .user.ini, so this still works with mod_php? See #2463967: Add .user.ini

stefan.r’s picture

Status: Needs work » Needs review
FileSize
905 bytes
stefan.r’s picture

FileSize
905 bytes
stefan.r’s picture

@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?

xjm’s picture

Category: Task » Bug report
Issue tags: +Needs issue summary update

Discussed 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.

mgifford queued 24: 2455465-utf8-24.patch for re-testing.

mgifford’s picture

Status: Needs review » Needs work

Patch no longer applies.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Darren Oh’s picture

Version: 8.5.x-dev » 8.6.x-dev
FileSize
1.21 KB

Re-rolled patch

Darren Oh’s picture

Status: Needs work » Needs review
Darren Oh’s picture

Issue tags: +#fldc18

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Darren Oh’s picture

Issue tags: +fldc19

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Darren Oh’s picture

Darren Oh’s picture

FileSize
1.24 KB
955 bytes

UTF-8 is the default encoding in PHP7, so leaving out the encoding settings is fine.

Darren Oh’s picture

Attached wrong patch. Here is the right one.

Darren Oh’s picture

Issue tags: +Novice
Darren Oh’s picture

Issue summary: View changes

The 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.

Darren Oh’s picture

Issue summary: View changes
pbirk’s picture

Status: Needs review » Reviewed & tested by the community

This installs cleanly against Drupal Core 8.8.0-dev. Marking RTBC.

Darren Oh’s picture

Issue summary: View changes
Issue tags: -Novice +Usability
demeritcowboy’s picture

Hi,
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().)

Darren Oh’s picture

Yes, the issue for the auto-generatated .htaccess in the files directory is #2820611: FileStorage generated .htaccess doesn't cover PHP 7.

demeritcowboy’s picture

Ah thanks.

alexpott’s picture

Category: Bug report » Task
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs release note, +Needs change record

I 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.

Darren Oh’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record

I created a change record.

DamienMcKenna’s picture

Might this be something that could be backported to 8.7.x presuming it is included in 8.8.x?

Darren Oh’s picture

Issue tags: -Needs release note
Darren Oh’s picture

Issue tags: +Needs release note
alexpott’s picture

Title: Add mod_php7 check to htaccess » Add mod_php7 check to htaccess and remove php5 code
Status: Needs review » Needs work
Issue tags: -Usability

This 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.

alexpott’s picture

It'd be good to remove the PHP5 stuff from \Drupal\Component\PhpStorage\FileStorage::htaccessLines too.

DamienMcKenna’s picture

Might it be worth splitting off the PHP5 removal into a separate issue as this one seems like a tiny shoe-in?

Darren Oh’s picture

Status: Needs work » Reviewed & tested by the community

Agreed. 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.

Darren Oh’s picture

Issue tags: -Needs release note

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 42: add-mod-php7-to-htaccess-2455465-42.patch, failed testing. View results

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Chi’s picture

longwave’s picture

Status: Needs work » Needs review
FileSize
2.69 KB

This patch addresses #56, #57 and #63. There are no remaining references to mod_php5 in the codebase following this.

Darren Oh’s picture

Category: Task » Bug report
Status: Needs review » Reviewed & tested by the community

Patch 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.

alexpott’s picture

As this is a change in the root .htaccess we need to add a release note about this. I/e complete the @todo section.

Darren Oh’s picture

Issue summary: View changes
Wim Leers’s picture

I've actually often wondered about this! Glad to see this happening.

Chi’s picture

alexpott’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Patch (to be ported)

Committed a585dd6a7e and pushed to 9.1.x. Thanks!

Going to ping a release manager about backport to 9.0.x and 8.9.x

alexpott’s picture

Status: Patch (to be ported) » Fixed

@catch +1'd the backport.

  • alexpott committed a585dd6 on 9.1.x
    Issue #2455465 by stefan.r, Darren Oh, cosmicdreams, longwave, benjy,...

  • alexpott committed 2376077 on 8.9.x
    Issue #2455465 by stefan.r, Darren Oh, cosmicdreams, longwave, benjy,...

  • alexpott committed c73845e on 9.0.x
    Issue #2455465 by stefan.r, Darren Oh, cosmicdreams, longwave, benjy,...
andypost’s picture

Status: Fixed » Needs work
Issue tags: +Needs change record updates

Needs to fix version and publish

Darren Oh’s picture

Status: Needs work » Fixed

Done.

andypost’s picture

Added version

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.