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

let's get on with what Drupal 10 brings, a host of new features and improvements, making it the most powerful and flexible version of Drupal yet and how we can help you get there.

Sohail Lajevardi
Sohail Lajevardi

This year it was Nina’s first time at DrupalCon. Nina is one of our project managers who is young, eager and willing to learn more about the technical aspects of Drupal so she can use the knowledge to improve her day-to-day project management routines. Since DrupalCon is mostly attended by developers we wanted to interview Nina about how she experienced her first DrupalCon as a project manager.

Photo of Jessica Denkelaar
Jessica Denkelaar

After two years, it was finally time to continue Ramsalt’s one of the most exciting traditions and meet the Drupal community in person again at DrupalCon Prague 2022. Ramsalt had 11 of its team members joining the event in Prague and just as many were attending it virtually. Based on our team’s experience, we have picked out our top recommendations for you from this year’s big event.

Photo of Hansa Pandit
Hansa Pandit

More and more states in the EU are making Google Analytics illegal, and if that isn’t enough to make you look for an alternative web analytics software, here is another strong argument: 

Nina
Nina Holzapfel