Upgrading from Drupal 8 to Drupal 9

Drupal 9

There is already basic article on upgrading Drupal 8 to Drupal 9, however, there is a bit more to consider, with my current setup of Drupal using composer.

Prerequisites

First install the Upgrade Status module. After installing go to Reports -> Upgrade Status and click on the check manually link scan your site for Drupal 9 readiness. Under the Drupal core and hosting environment, make sure you meet the following requirements:

Upgrade to Drush 10

Run the following composer commands to update to Drush 10

composer remove drush/drush
composer require drush/drush:^10

Scan installed modules

  1. Select all the projects, including the uninstalled modules, under Contributed projects and click the Scan selected at the bottom
  2. After scanning, analyze each project whether it is compatible with Drupal 9 or not
  3. Check each modules if it can be updated to be compatible with Drupal 8 & 9 and update them - remember to run update.php
  4. Those modules that are not ready for Drupal 9 or incompatible, uninstall them and remove them using composer

Note: When updating to Webform 6.x, make sure to install jquery_ui_checkboxradio

Replace Drupal Scaffold

  1. Temporarily add write access to protected files and directories
    chmod 777 web/sites/default
    find web/sites/default -name "*settings.php" -exec chmod 777 {} \;
    find web/sites/default -name "*services.yml" -exec chmod 777 {} \;
  2. Remove the old drupal-scaffold
    composer remove drupal-composer/drupal-scaffold
  3. Update the composer.json file and add locations and file-mapping configurations in "extra"
    "drupal-scaffold": {
        "initial": {
            ".editorconfig": "../.editorconfig",
            ".gitattributes": "../.gitattributes"
        },
        "locations": {
            "web-root": "./web"
        },
        "file-mapping": {
            "[web-root]/.htaccess": false
        }
    }
  4. Add new core-composer-scaffold
    composer require 'drupal/core-composer-scaffold:^8.8.1'

Remove patches for Drupal core

Open composer.patches.json and remove any patches for drupal/core and save the file

Update sync directory configuration

Open your settings.php replace:

$config_directories['sync']

with:

$settings['config_sync_directory']

Update your custom themes

Open your theme's [theme].info.yml file and replace:

core: 8.x

with

core_version_requirement: ^8.8 || ^9

Open your theme's [theme].theme file and replace:

'path.alias_manager'

with:

'path_alias.manager'

Open your theme's [theme].libraries.yml and replace:

css/print.css: { media:print }

with:

css/print.css: { media: print }

Upgrade Drupal 8 to Drupal 9

  1. As per the article, we'll "need to pull in both the Drupal 9 version of core-recommended and dev-dependencies packages as dependencies. We use --no-update to avoid a chicken-and-egg problem with mutual dependencies":
    composer require drupal/core-dev:^9.0.0 --dev --update-with-dependencies --no-update
    composer require drupal/core:^9.0.0 --no-update
  2. Then, perform the update to the code itself:
    composer update
  3. Run any pending database updates, required if you update module code and that module needs to update the database by visiting update.php and check the Status report page.
  4. When complete, restore read-only access to the sites/default directory:
    chmod 755 web/sites/default
    find web/sites/default -name "*settings.php" -exec chmod 644 {} \;
    find web/sites/default -name "*services.yml" -exec chmod 644 {} \;

Install other Drupal 9 modules

Once you have Drupal 9 up and running, you can now install other modules that are Drupal 9 compatible

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.