Preparing your site for Drupal 9


Drupal 9 was released on June 3rd and it's the greatest Drupal release ever and still the easiest to upgrade to if your site is up-to-date in the latest 8.x version.

Drupal 9.0 doesn't really include any new feature in comparison with 8.9; however, this is part of the greatness of the version because no new features mean no new unknown bugs. The only differences from 8.9 to 9.0 is that 9.0 removes all the backwards compatibility layer for all of the stuff that has been deprecated during the whole lifecycle of Drupal 8 so that we can keep the drop always moving to bring new great features in the upcoming releases. Also, Drupal 9 includes upgrades for several dependencies included in core with Symfony (3 => 4.4) and Twig (1 => 2) among the most important ones.

The release cycle will keep being the one we already saw for Drupal 8: one minor release each 6 months. This enables in Drupal the possibility of adding new big features frequently so, you definitely should upgrade to Drupal 9 soon even if Drupal 8 support will still be available until November, 2021.

So, with all this in mind, how could I upgrade my site to Drupal 9? Keep reading...

How to upgrade to Drupal 9

The very first step you should take to upgrade your site to Drupal 9 is to upgrade Drupal core to the latest Drupal 8 version (i.e. 8.9) and to upgrade all of your contrib projects to their latest version compatible with Drupal 8. Keep in mind that Drupal now supports semantic versioning so you're not really only looking for 8.x versions for your contrib projects.

Once you have everything up-to-date, you need to install Upgrade Status module in order to get a report about your Drupal 9 compatibility. When you install this module, you'll get a new menu entry located at /admin/reports/upgrade-status. In this page, you'll have a list of all the modules and themes installed on your site and you can scan them looking for potential issues about Drupal 9 compatibility. This scan could happen either through the UI or through drush command (drush us-a project). In my experience, big modules won't play well with UI soI had to run a couple of modules through drush command.

I recommend you to scan to all of the projects in one of the big groups (custom or contrib) at once and then start working on the fixes. For the purpose of this article, I'll assume you'll scan initially all your contrib projects. Once you run this analysis, you can have the following situations:

All of your contrib projects are ready for Drupal 9

If this is your situation, be happy. You have nothing to do on contrib land. Move to custom modules.

Some of your contrib projects aren't ready for Drupal 9 yet

If this is your situation, Upgrade Status will report what are the missing changes needed for these projects. The first thing you need to do is to go to the project page. There you'll find what are the expectations for this project releases respect Drupal 9 compatibility. Possible scenarios are:

  • There will be Drupal 9 support in current major branch
  • There will be Drupal 9 support in another major branch

If there will be support in next major branch (see screenshot), you need to ensure that (if needed) there will be a upgrade path. You can find this either in the project page or in the issue queue.

If there is support in next major branch and there's already a release, you should try installing it in your site to know if it fixes the issues you found. Every time you install a new version, you need to run database updates and re-run the Upgrade Status scan.

If either you didn't find support for next major branch or you updated and you still find incompatibilities, it's your time to start searching in the issue queue. It's highly probable that there's already an issue trying to land Drupal 9 compatibility in this project. You can read the comments and test the patches if needed. Remember that patches are created against project's dev branch so they may not apply to your current version and you may need to switch to dev version. Be kind and leave a comment in the issue queue when you test a patch so that people can know whether it worked or not for you (again, once added a patch, run db updates if needed and re-run Upgrade Status). If you tested a patch that was in Needs Review status and nobody has previously tested and it worked for you, feel free to mark it as RTBC (Reviewed and Tested By the Community) so that maintainers know it's working.

If you tested one patch and it worked on the dev version of the project but it doesn't apply on the version you had in your site, it's up to you if you want to switch to the dev version or to wait for next release. It's also sometimes useful to ask the maintainers to release a new version so that people can use the projects in a more stable way.

If there was no patch or the patches don't work to make the project compatible with Drupal 9, you may also help to make it compatible. You can follow Drupal contribution guidelines to help to this project. Maybe it's also time for you to take a look at the great Rector project to automate some of the work required for compatibility. If you contribute a patch, don't forget to set issue status to Needs Review so that other people can help to review the patch and hopefully land it in the project.

Your objective in this contrib projects stage is to have all of your projects compatible with Drupal 9. Once done this (or in parallel, it's totally up to you) you can move to your custom modules and themes.

For your custom projects, you can also use Rector to help with some of the work needed and you can follow the instructions given by Upgrade Status to upgrade your modules. If you need some help to know how to make the changes, the Change Records is an excellent resource to start looking for help.

Let's assume all of your contrib and custom projects are now Drupal 9 compatible according to Upgrade Status. This module also gives you information about the PHP and MySQL versions needed so, you need to ensure you meet these requirements on your hosting platforms:

  • If webserver is Apache, it should be 2.4.7 or superior.
  • PHP 7.3 or higher
  • MySQL or Percona >= 5.7.8 or MariaDB >= 10.3.7

One more thing to check is Drush: even though the only Drush version supported on Drupal 8 since 8.4 is Drush 9; you may still have Drush 8. Drush 8 is not compatible with Drupal 9 so you need to upgrade to Drush 10 to take advantage of latest features on Drush.

Once everything is done, it's your time to let the magic happen. Follow the instructions in the official documentation to do the packages update with composer.

Summary and Conclusion

It may sound like a lot of work, but in reality it's all about ensuring your site doesn't contain deprecated code that won't work with Drupal 9. You don't need to run to do the upgrade if your site is complex, but it's highly recommended you start thinking on doing it to keep taking advantage of the new features that will be included in Drupal 9.1 (to be released in December, 2020) and following minor upgrades. So, if you have some time, this is a good time to start thinking in your site upgrade to Drupal 9.

Feel free to leave any suggestions or questions in the comments section.

Hide Image
Submitted by kporras07 on Sat, 07/11/2020 - 03:12