It's That (Deprecated) Time Again! Starting Your Drupal 10.x Preparation

If you’ve been a reader for a while (THANK YOU) then there will be a lot of similarities in this post to some of what I’ve written over the last few years. The TLDR is that Drupal 10 is coming out in a few months (currently targeted at 06/2022) and there will be, just like in Drupal 9, deprecations that must be resolved prior to you updating your codebase. Given that roughly 20% (or 200k) of the sites being reported on Drupal.org are still running Drupal 8 (even thought it went EOL in November 2021)… there’s a lot of sites that haven’t completed the LAST update. I want to help you get ahead of the curve so you can do the Drupal 10 update ASAP this year when it drops.

By the way, thanks to Kristen Pol for getting me started thinking about this with her tweet yesterday!

Reviewing Your Project and Code

A few things you can do right now for your codebase are very simple and easy.

The first is to make sure you are running PHP 8.x. Drupal 10 will require at least PHP 8.0.2 when it releases (given that PHP 7.4 will be going EOL very soon). I’ve talked about updating to PHP 8 with composer already on the blog, and thankfully it’s a pretty painless experience in almost all cases! Update your codebase and all your environments to PHP 8.x ASAP.

The next thing is to make sure you have the 3.x branch of Upgrade Status installed on your project and scan. Fair warning, I imagine there will be additional deprecations coming in the months prior to D10 releases, so what you see today may not be the final state. But it should give you an overview of what is coming. It should also help you start to anticipate which modules in your codebase (if any) will be a blocker to a D10 update. And, if your experience is anything like mine in D9, there may even be some modules you need to remove (or patch) to get them to work.

Upgrade Status will likely find something that you need to fix, so anything you can do now to fix things (and keep on top of those fixes) will certainly cut down on the technical debt moving forward.

One example I found for GovCon today is the render function I’m using in one of my views plugins:

see https://github.com/Drupal4Gov/Drupal-GovCon-2017/blob/develop/docroot/modules/custom/capitalcamp_glue/src/Plugin/views/field/AttendeePhoto.php#L30. However, in this case, as Upgrade Status recommends, I’ll hold off on doing anything with this for now (as it may continue to shift or change upstream before I get to it).

Some Specifics I Ran Into Today

The first thing I stumbled into while trying to test my site was this error:

Upgrade Status should be used on a Drupal 8 site to detect deprecated APIs present. It does not in itself know about deprecated APIs and Drupal 9 does not have Drupal 8's deprecated APIs anymore. 

As it turns out, I had the 2.x branch of Upgrade Status installed (from when I was doing the D9 upgrade). So if you see a similar error, check your composer file and update into 3.x!

I also discovered an issue where Upgrade Status was causing my Lando instance to die if I tried to scan too many projects simultaneously. I’ve reported this, and we’ll see what the maintainers say.

Finally, I want to call out that even after scanning all of my projects (both custom and contrib) only 1 project in my entire codebase is compatible with D10 as of today (shoutout to the Link Icon module for that distinction)! That’s ok and it doesn’t concern me. I’m going to monitor the situation, and hopefully I may even be able to contribute some fixes to modules in the coming months if Drupal Rector doesn’t fix everything automatically (and it may). The things to note now are:

  • what in my custom code do I need to do (if anything). at minimum you probably need to increment the core supported version to include ^10 if there are no other problems

  • what contrib modules have problems, and does it look like the maintainers are actively working to resolve them via their issue queues.

  • if there are modules that are not active, and have issues, what is our plan for upgrading to D10 without these modules?

Getting ahead of the curve will make the transition that much easier in a few months.

Good luck!

Related Content