Problem/Motivation

Removes PHP 7 code paths from Drupal 10 now that PHP 8.0 is the minimum version.

Proposed resolution

Leave legacy tests alone as they can be removed in the issue that removes the legacy code.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
FileSize
13.26 KB
alexpott’s picture

Now that #3186524: Fix htaccess files for PHP 8 has landed we can remove the PHP 7 stuff from htaccess too.

longwave’s picture

+++ b/.htaccess
@@ -27,11 +27,6 @@ AddEncoding gzip svgz
 # PHP 8, Apache 1 and 2.
 <IfModule mod_php.c>

Wonder if we want to update or even remove this comment now to avoid having to update it again - the module is now called mod_php so I suspect it won't change name in PHP 9?

longwave’s picture

I think all these have their own longstanding issues somewhere?

core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php
149:    if (version_compare(PHP_VERSION, '5.4.0', '<')) {

core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
239:    if (function_exists('imagerotate') && (version_compare(phpversion(), '7.0.26') < 0)) {

core/tests/Drupal/Tests/Component/Utility/XssTest.php
436:    if (version_compare(PHP_VERSION, '5.4.0', '<')) {

Otherwise this catches everything that I can see apart from legacy tests which I agree we will deal with elsewhere.

alexpott’s picture

Re #5 yep they do.

RE #4 - yep I think removing the comment is a good idea.

longwave’s picture

Some more references, do we want to fix/remove any of these here?

  1. example.settings.local.php:
     * If you are using PHP 7.0 it is strongly recommended that you set
     * zend.assertions=1 in the PHP.ini file (It cannot be changed from .htaccess
     * or runtime) on development machines and to 0 in production.
    
  2. core/lib/Drupal/Core/Routing/Router.php:
        // PHP 7.4 introduces changes to its serialization format, which mean that
        // older versions of PHP are unable to unserialize data that is serialized
        // in PHP 7.4. If the site's version of PHP has been downgraded, then
        // attempting to unserialize routes from the database will fail, and so the
        // router needs to be rebuilt on the current PHP version.
        // See https://www.php.net/manual/en/migration74.incompatible.php.
        catch (\TypeError $e) {
    
  3. core/lib/Drupal/Core/Database/Install/Tasks.php: (the linked issue is closed)
        // @todo https://www.drupal.org/project/drupal/issues/3110839 remove PHP 7.4
        //   work around and add a better message for the migrate UI.
        $profile = $install_state['parameters']['profile'] ?? NULL;
    
  4. core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php:
                  // Get the response body as a string. Any errors are silenced as
                  // tests should not fail if there is a problem. On PHP 7.4
                  // \Drupal\Tests\migrate\Functional\process\DownloadFunctionalTest
                  // fails without the usage of a silence operator.
                  $body = @(string) $response->getBody();
    
  5. core/tests/README.md
    * PHP 7.1 or higher
    

Probably time to revive #3001920: Investigate PHP 7.3 workarounds as well.

alexpott’s picture

Thanks @longwave - yep let's fix all these here.

Re #7.2 my initial thought was to leave it because you might be coming from a site running on 7.3 and upgrading to PHP 8 at the same time - but that'd requiring going via update.php which is going to rebuild the router - so yep we can remove this.

Re #7.4 \Drupal\Tests\migrate\Functional\process\DownloadFunctionalTest still fails on PHP 8 so the PHP version is irrelevant.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks - this all looks sensible to me and I can't find any remaining references to PHP 7* so this is RTBC.

* there are references to PHP 5 and even one reference to PHP 4 but those seem out of scope for fixing here

  • catch committed 94ee839 on 10.0.x
    Issue #3255350 by alexpott, longwave: Remove PHP 7 code from Drupal 10
    
catch’s picture

Status: Reviewed & tested by the community » Fixed

All looks good, think it's fine to leave PHP 5 removal to the existing issues.

Committed 94ee839 and pushed to 10.0.x. Thanks!

Status: Fixed » Closed (fixed)

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