Updating to Drupal 9 from Drupal 8

Drupal 8 is now end of life, and if you haven’t already upgraded your site to Drupal 9, now is the time to do so! We’ve finished the process with most of the sites we manage, and here are some notes on how to prepare and go about the upgrade.

  1. Check to see that your hosting account provides the Drupal 9 minimum requirements. We’ve had one instance where we needed to reach out to our host to provide a database at a later version.
  2. Back up everything. Make sure that your development version of the site you are upgrading isn’t tied to any production resources (database, files, etc.).
  3. Make sure any custom modules and themes aren’t using any depreciated code. There is a drupal-check program that you can run against your code with instructions. For the most part, we only have come up against a few instances of depreciated functions, such as the need to use EntityTypeManager over the depreciated EntityManager, which is a very easy fix.
  4. You probably will need to update your custom modules and themes *.info.yml file for Drupal 9 compatibility. Basically, this just requires adding the line core_version_requirement: ^8 || ^9 to the end your *.info.yml file. Note, this line needs to be exact, as running update.php will choke if this line is in unexpected format.
  5. Update your site, modules and themes to a latest version of Drupal 8. This way you can address some upgrade issues while still in Drupal 8, which is probably going to be easier.
  6. Try and delete any depreciated modules. I say “try” because even after going through the steps of deleting modules, they were still apparently recorded in a Drupal website I was upgrading.
  7. Of particular note is the “Kint” module, which was part of older versions of the Devel module. Try and delete it, It’s likely going to give you headaches, but see #9 if you missed it (or can’t get rid of it).
  8. Another note is that Swift Mailer is depreciated, so you will need to delete it and use a replacement. We’ve been successful using Symphony Mailer, which also replaces MailManager. For what we do, the alpha version seems to work fine.
  9. On running update.php after moving to Drupal 9, should you get a “Missing or invalid module” error on a module that you deleted, you can get around it by creating a directory named for the modules with a *.info.yml file. (h/t byacoubi).

For example, your directory would be named “kint” and it would include a file kint.info.yml with the following:

name: 'Kint'
description: 'description'
type: module
version: 'XXXX'
core: 8.x
core_version_requirement: ^8 || ^9. // note, this is different than byacoubi's example

Once you get past the update.php process, you can go back and delete it from your list of modules and delete the directory.

Hopefully, this list will get you past most of the issues with the Drupal 9 from Drupal 8 upgrading process. Onward!