Your Guide to Migrating to Drupal 9
The time has come to prepare to update your site as the 2020 release of Drupal 9 draws near. While in the past, the massive changes between Drupal versions made developers cringe at the thought of migrating, the process has gotten much simpler over the past few iterations. If you’re running a relatively recent version of Drupal, like Drupal 8 or even 7, upgrading to a new major version shouldn’t be much different than upgrading to a new minor one (i.e. going from Drupal 8.7 to 8.8). There is potential for challenges to arise, however, if you’re using deprecated code.
So, what is deprecated code and why does it matter now?
The introduction of Drupal 8 overhauled how Drupal updates were introduced, eliminating the need for complex migrations and delivering minor updates every six months. Every minor update, however, led to the creation of deprecated code—code that should no longer be used because an improved version exists. Drupal 9 not only promises new features, modules, and capabilities, but includes a major code clean up.
While every Drupal update is different, a constant from one to the next is that not every user updates immediately or at the same time. It’s common practice for Drupal to support deprecated code for some time after an update is announced to ensure continuity of service. As Drupal 9 is rolled out, however, some deprecated code will no longer be supported. But fear not—you have until Drupal’s official roll-out date—June 2020—to scrub that obsolete code. The key is to start now to give yourself enough time.
Detecting Deprecated Code
There are several ways to find out if you’re using outdated code on your site. Your first plan of attack should be running drupal-check, a command-line utility that tests modules to flag instances of deprecated code. Alternatively, Drupal 8.8, the version that was released in October 2019, offers a “Drupal 9 Readiness” contributed module, a graphic user interface (GUI) tool that users can run to determine the steps they’ll need to follow to prepare their site for Drupal 9.
Finally, if you already have a project on Drupal.org, you can use its testing infrastructure to detect any deprecated code. Either run a static deprecation analysis on your code or configure your existing tests to fail when calling up deprecated code. You can set up both tests using your drupalci.yml configuration file.
Making Necessary Updates
If you do determine that your site depends on some deprecated code, there are relatively simple ways to update it. Most of the time, making a code update is as simple as running the search-and-replace function to identify old code and swap it for the latest version.
However, depending on the specific modules you’re running, some deprecations may require more complex and detailed update processes.
Updating the code can be complicated. You’ll have to check Drupal’s API documentation for instructions on how to update specific deprecations. But there is an easier way: Engaging a Drupal hosting partner can help you pinpoint any changes you’ll have to make and help you carry them out as well. Going this route can save you the headache of searching for outdated code and making time-consuming modifications.
Chances are your host partner has already made it a priority to get familiar with the necessary updates, ready to tackle them for your site. That leaves you with more bandwidth to focus on other operations. What’s more, your hosting partner can also help test your updated code to ensure things are running smoothly before the release of Drupal 9 and before deprecated code is sunsetted.
Overall, a hosting partner can be a valuable asset during any migration, minor or major. But when it comes time to upgrade to Drupal 9, you don’t want to be caught without one—especially if you’re dealing with deprecated code.
If you have more questions about deprecated code, or anything else Drupal related, please feel free to contact us and ask!