A Plan for Upgrading from Drupal 8 to Drupal 9

The Drupal 8 to Drupal 9 upgrade is simple, but it involves more than just flipping a switch. Here is a roadmap to help you out.

With Drupal’s new versioning and release planning came the promise of easy upgrades between major versions. No more major database overhauls. No more rewriting business logic just to keep things working. No more major investments in expensive migrations to maintain feature parity.

Upgrading to Drupal 9 from Drupal 8 provides the first test of these promises. Have the promises been fulfilled? 

Yes.

Is it as simple as flipping a switch?

No.

When moving to Drupal 9 from Drupal 8 (which reaches end-of-life on November 2, 2021), planning is required. The larger your codebase, the more you need to take into account. Here is a roadmap to get you started.

Create a module inventory

The Drupal 9 codebase is very similar to the Drupal 8.9 codebase, but it removes the code marked as deprecated. This deprecated code can range in impact depending on what you are using and what APIs you have taken advantage of. 

You need to look at three things: custom modules, contrib modules, and themes. Create a list in whatever format will work best for your team.

To get started, we suggest installing the Upgrade Status module. Enable it in a development environment. This will give you a good baseline of the information you want to track. To get this information into a spreadsheet, install this patch for the module.

Organize the sheet to easily filter your contrib and custom modules because the work process will differ for each category.

Custom modules

Get drupal-check installed and running on a development environment or as part of your CI workflow. This will show you where the work is to get your custom codebase compatible with Drupal 9. 

The benefit of adding it to your CI workflow is to make sure you aren’t introducing any new incompatibilities. A VS Code extension is also available.

For each module that has a Drupal 9 compatibility issue, create a ticket in your ticketing system. Enter the details. Some things will need minor changes, like a different function call. Others might need deeper refactoring. Identify those as early as possible. Now is also a great time to check the contrib space and see if you even need these custom modules anymore.

Contrib Modules

Organize the contrib modules on which you are dependent into groups that represent levels of effort. Ask the following questions:

  • Which have a D9 release, and which does not?
  • For modules with a D9 release, are they minor updates or major updates?
  • Which modules are we currently forking/patching that may need more hand-holding to get to their D9 release?
  • Will this contrib module even have a D9 release? Is there a different module that will take its place?

Your groups might look like this:

  • Group 1: D9 minor tagged release available
  • Group 2: D9 major tagged release available
  • Group 3: D9 minor dev release available, not forked
  • Group 4: D9 major dev release available, not forked
  • Group 5: D9 major or minor release available, forked modules
  • Group 6: D9 release is not yet available

Themes

If you use any contrib base or sub-themes, keep them on your list to track and treat them as modules. 

Twig has its own deprecations moving from Twig 1 to Twig 2. Make sure your templates are not using functions in Twig templates that are not supported in version 2. The Upgrade Status module should flag these for you. Many projects won’t require any changes, but it is best to check early so you are not surprised.

Add any flags as tickets to your ticketing system.

Updating modules and code

Fixing your custom codebase is all work you are going to have to do sooner or later. Start adding some of the tickets you created into your sprints or general workload. Pick away at them. There is no substitute for rolling up your sleeves and getting to work.

For contrib modules, the latest releases will often support both Drupal 8 and Drupal 9, so they can go ahead and be updated. That represents the lowest level of effort. This is where you want to start.

Focus on your custom modules and the easy contrib updates first. This allows time for some of the more difficult contrib work to be completed by the module maintainers and the wider community. By the time you get to them later, it may be a trivial update. Keep your contrib module inventory up to date during your transition period.

If you are done with all of your custom code and low-hanging fruit, dedicate some time inside the issue queues of contrib modules your website depends on. There are a lot of ways to help out to speed up the overall process. Review patches and leave feedback. Submit your own patches. The work you do not only helps your own organization but potentially countless others.

While doing this work, be sure and stay up to date with the latest Drupal 8 minor releases. When the time comes and all of your code is ready, you’ll be able to upgrade to Drupal 9 with minimum hassle.

What to avoid

As you go through this process with each custom module, you’ll inevitably find other things that need improvement—features that were left half-baked, technical debt, cleaner comments, newer solutions, etc.

It will be tempting to fix everything since you’ll be touching the code anyway. But take heed. Avoid. You will be stumbling down a rabbit hole that will delay the completion of your true goal. 

Take note of these things. Create tickets. But stay focused on Drupal 9 readiness. If each code change and pull request becomes huge, full of unrelated changes, it will slow things down.

Summary

When you compare the process for upgrading from Drupal 8 to Drupal 9 to the process for upgrading from Drupal 7 to Drupal 8, it looks like night and day. 

D7 to D8 required a host of dedicated resources and time. The amount of work required inevitably made it a big project. In contrast, D8 to D9 can be done alongside regular work. Your developer team might be able to slot it into their roadmap without additional overhead.

  • Create an inventory of your code
  • Use drupal-check and Update Status to start updating your code
  • Keep Drupal 8 up-to-date during this transition period
  • Upgrade to Drupal 9

Drupal 8 reaches end-of-life on November 2, 2021, which means that Drupal 8.9 will no longer receive security updates. This will sneak up on you quickly if you aren’t tracking it. At this point, there is no value in delaying. Start your move to Drupal 9.

Get in touch with us

Tell us about your project or drop us a line. We'd love to hear from you!