This is no news anymore: preparing to upgrade to Drupal 9 is just a matter of... cleaning your website of all deprecated code.
No major disruption from Drupal 8. No more compatibility issues to expect (with dread)...
“Ok, but how do I know if my website's using any deprecated APIs or functions? How do I check for deprecations, identify them and then... update my code?”
2 legitimate questions that must be “haunting” you these days, whether you're a:
- Drupal 8 website owner
- developer currently working on a Drupal project
“How precisely do I check my website for deprecated code?”
Are there any analysis tools available? Tools that you could run to get a thorough and accurate deprecated code report?
Luckily, there are. And I'll be focusing on 2 of the most effective ones that you should consider integrating into your workflow: Drupal Check and the Upgrade Status module.
1. But What Is Deprecated Code? And What Website Elements Should You Audit?
A piece of code is considered deprecated if:
- there's an upgraded alternative for it already available
- it's no longer in use
With this real “dilemma” now solved, there comes another one:
“What parts of my website should I check for deprecated code?”
Make sure you scan your:
- Drupal core
- Drupal modules
Note: pay special attention to the contributed modules enabled on your Drupal 8 website; run a deep-scan and, if you get any deprecation warnings, make sure to alert those modules' maintainers to clean them up.
2. Drupal Check: Scan Your Database for Any Deprecations
A handy PHP analysis tool to grab and to run whenever you need to look for deprecated code in your database.
A command-line tool that Dries Buytaert recommends running the... automated way, closely integrated into your own workflow. What it'll do is track down instances of deprecated code for you.
Then, all there's left for you to do is to... remove them. And, depending on the context, to replace them with their upgraded alternatives.
3. The Upgrade Status Module: Determine Your Site's Readiness to Upgrade to Drupal 9
If the idea of working with a command line doesn't sound too... “tempting” to you, how about adding a user-friendly graphical interface to the equation?
It's particularly handy if you're a Drupal site owner and not a senior Drupal developer highly familiar with CLIs.
Install it, enable it and use it to evaluate your website and to assess to what degree it is ready (meaning up to date) for the Drupal 9 upgrade.
But let's delve head first into details on:
- what it takes to install it properly
- what parts of your website it will deep scan
- how you can narrow down its analysis to specific projects only
3.1. Use the Composer Package Manager to Install It
Since it ships with its whole collection of third-party PHP dependencies...
Another key requirement to set the stage for the Update Status module is to enable the Update Manager and the Git Deploy modules on your Drupal 8 website.
Once installed, you can access its user interface at /admin/reports/upgrade.
3.2. Check Up Your Codebase, Modules, and Themes
The great thing about this module is that you get to run your checks right in your admin UI and get a full report.
Another great aspect is that, when it comes to contributed modules, it will provide you any available updates... inline.
Once it's completed its scan it'll display either an “Errors found” or a “No known errors” message. To localize the identified deprecations on your website, just click “View errors”.
3.3. Run It on Specific Individual Projects, Too
Maybe you don't always need a full check. Maybe you'd like to scan only a specific project that you might be working on, to ensure that it's ready to upgrade to Drupal 9 when due time.
You can do that. The module allows you to cut down the time you'd spend on an unnecessary full-scan by focusing on one target project only.
Furthermore, to streamline things even more, it enables you to export each deprecated code report individually...
4. So, You'Ve Identified Your Deprecated Code: What Next?
In most cases, keeping your codebase up to date once you've detected the deprecated parts is just a matter of replacing those deprecations.
For the other few cases left, you'll need to carry out a more complex refactoring process.
Now that you know which are the tools to use for:
- running your audits
- spotting any deprecations in your codebase
… your website's smooth upgrade to Drupal 9 depends on you exclusively.