Tips & tricks when upgrading to the latest Drupal 8 before going for Drupal 9

Drupal developer
Drupal upgrade slide

This post will save you some headaches when upgrading Drupal core from 8.7 to 8.9 addressing some common challenges.

Drupal 9.0.0 has been released simultaneously with Drupal 8.9.0. Drupal 8.9 is a long-term support version that will be supported until November 2021. Versions of Drupal 8 prior to 8.8.x are end-of-life and do not receive security coverage. Upgrading an existing site that’s not yet running on the latest core 8.8 or 8.9 can be challenging due to some new changes in Drupal core.

If your site version is below 8.7 make sure you upgrade to 8.7 first because the process would be a lot smoother if you are on Drupal 8.7

Upgrading from Drupal 8.7 or 8.8 to 8.9

  1. Make sure you have Pathauto 1.6 or greater. You can run: composer require drupal/pathauto:^1.6
  2. Remove/replace old dev packages composer remove --dev webflo/drupal-core-require-dev The webflo/drupal-core-require-dev provides the require-dev dependencies of drupal/core as a standalone package.
  3. Remove the deprecated drupal-scaffold composer remove drupal-composer/drupal-scaffold Drupal-composer scaffold provides a composer plugin for placing scaffold files (like index.php, update.php, …) from the drupal/core project into their desired location inside the web root. The purpose of scaffolding files is to allow Drupal sites to be fully managed by Composer, and still allow individual asset files to be placed in arbitrary locations.
  4. Remove Drupal core strict composer remove webflo/drupal-core-strict Drupal-core-strict is a virtual package, that causes you to get exactly the versions of Drupal core's dependencies as they are specified in Drupal core's composer.lock file
  5. Add drupal/core-dev composer require --dev drupal/core-dev:^8.8
  6. Prepare your composer.json for the new scaffold plugin. Make sure you have the following block in the extra section of your composer.json.
"drupal-scaffold": {
  "locations": {
    "web-root": "web/"
  }
}

7. Run composer require drupal/core-recommended:^8.8 drupal/core:^8.8 drupal/core-composer-scaffold:^8.8 --update-with-dependencies

"drupal/core:^8.8" is added because the composer may not be able to resolve the dependency tree. The drupal/core-recommended is the new recommended project template for Drupal 8 projects. Once the above command is successful, you can run composer remove drupal/core to remove the package.

8. drush updatedb -y

9. drush cex -y

Update settings.php

Check settings.php files for the $config_directories variable and replace it with $settings['config_sync_directory'] = '../config/sites/default';

if you see an error like the one below after running composer command:

Installation failed, reverting ./composer.json to its original content. [RuntimeException] Could not delete /.../web/sites/default/default.services.yml:

You can resolve this with: chmod +w web/sites/default and run the composer command again.

Strange errors

If everything goes well and you see the site breaking on some pages like /admin/modules or any other page with this error in the log

Drupal\Core\Extension\Exception\UnknownExtensionException: The module does not exist or is not installed. in Drupal\Core\Extension\ExtensionList->getExtensionInfo() (line 346 of /app/web/core/lib/Drupal/Core/Extension/ExtensionList.php).

You can resolve that by running drush ev "\Drupal::configFactory()->getEditable('core.extension')->set('profile', 'standard')->save();" locally. This command enables the standard profile.

Note that you will need to run the same command on production before you can import configurations.

Do you have other tips or have questions, don’t hesitate to contact Fred.

Latest news

Drupal 9 reached its end of life (EOL) on November 1, prompting the need for an upgrade plan. Upgrading from Drupal 9 to Drupal 10 is expected to be smoother, thanks to smaller, incremental updates and faster iterations. Drupal recommends fully updating your Drupal 9 site with the latest module and theme versions before transitioning to Drupal 10.

Pierre Aryee
Perry Aryee

Drupal has been a robust choice for building and maintaining websites for decades. Like all other CMS systems, technological advancements and security requirements continually evolve at rapid speed and older software versions will be taken off the market.
 

Nina
Nina Holzapfel

The fastest way to resolve a problem is to write a good support ticket. Learn how to write to get your problem fixed as soon as possible. 

Yngve W. Bergheim
Yngve W. Bergheim

Liker du å jobbe direkte med kunden i tverrfaglige team og bruke designmetodikk som arbeidsmetode? 

Photo of Eir Husby
Eir Husby