If I compare my present self to the me that was five years ago, I would see a lot of changes in the way I dress, in the way I speak and most importantly, in my professional life and the position I have gained in my career. For me, I am proud of all the changes. I deserve a pat on the back.
The same is true for software, if humans change over time, the software they build is bound to change too. And that is what we are going to be talking about today.
Drupal is 20 and its 9th edition has rolled out with the 10th being on the horizon. The software has undergone a lot of changes in its existence, there have been a lot of versions of Drupal and all of them have been outstanding. Like me, Drupal also deserves a pat on its virtual back.
Updating is often associated with moving forward and what possible harm can be experienced in doing that. So, it is evident that people are going to want to move towards the latest version of Drupal by updating to Drupal 9.
With the last Drupal upgrade, being a major version, and the massive amounts of work and effort it required, some of us are hesitant and they are probably right. However, it isn’t needed.
According to Drupal.org,
Drupal 9 brings forward all the features from Drupal 8 and carries on its continuous innovation with new features twice a year.
What this means is Drupal 9 is equal to Drupal 8 minus the deprecated APIs, making it a minor version upgrade. So, logically the upgrade would not mandate an overhaul of your site’s infrastructure and it doesn’t. The image below describes this notion pretty well.
In this blog, I would not be talking about the upgrade process itself, wherein we look everywhere from Drupal core to custom code, but the tools that would be needed for it. So, let’s start assembling the upgrade tooling and prepare for Drupal 9.
Drupal 9 readiness cannot be talked about without the mention of upgrade status. It is the paramount tool necessary to make the upgrade successful.
So, what does it do?
It performs just about every major function required to make you ready for the upgrade.
What might those entail?
Makes you update to a current version
For the upgrade, you need to be on the latest version of Drupal 8, which can be either Drupal 8.8 or Drupal 8.9. Upgrade status not only checks the version you are on, but also suggests you to update so it doesn’t skip your mind.
Makes you check system necessities
The upgrade also has specific system requirements, from Apache to php to MySQL, each one of these needs to be updated to a version that would align with the upgrade. And guess what? Upgrade status checks whether you meet the requirements or not.
Makes you focus on contributed projects
From system requirements, let’s move on to contributed modules. This upgrade tool has the ability to integrate itself with Update Status to remind you about the contributed projects and their update. Usually a D8 project is compatible with D9, so when you update them, they would still work fine with your Drupal 8 site.
Makes you address other compatibility issues
You would think that these three should be enough, but that’s not it. There are a whole bunch of Drupal 9 compatibility issues, which need to be addressed through a phpstan run. And upgrade status can do that as well.
Upgrade status can also integrate itself with drush. You would need to install it with Composer. If I had to describe upgrade status and its work as a Drupal 9 upgrade tool, I would simply say that it is a tool that checks whether you are prepared and ready to hit the final update button.
The next important tool to migrate to Drupal 9 is Drupal check. PHPStan was developed as a static analysis tool that can run standalone PHP executable from the command line.
What does that accomplish?
The accomplishments are on the lines of deprecated code. Drupal check would report any and all deprecated code being used on your site. In other words, it would check the correctness of your project by highlighting all the errors.
For a seamless upgrade, you need your system to be 100% Drupal 9 compatible, this includes the custom code, the custom modules, the contributed modules and the migration code, if you are upgrading from Drupal 7 to Drupal 8.
But this sounds similar to Upgrade Status.
Yes, it does. There are some similarities between Drupal check and upgrade status in the fact that both work towards establishing Drupal 9 compatibility. However, I would say that upgrade status does so at a much larger scale.
Upgrade Rector and Drupal Rector
Would you prefer using an automated mechanism to catch the unwanted deprecated APIs before the D9 upgrade or would you prefer to do it manually? I am pretty sure your answer would resemble mine and be the former choice.
And those automated deprecation checks and code fixes come with Upgrade Rector. This also allows you to make patches for both custom and contributed projects through suggestions. In essence, Upgrade Rector is Drupal’s integrated UI for Drupal Rector.
So, what is Drupal Rector?
Before I get into Drupal Rector, let’s understand the story of Rector a bit. It is a tool that automated PHP code upgrades and comprehended PHP to make room for complex edge cases.
Now, Drupal Rector took that concept and implemented it on Drupal. Its predecessor was Drupal 8 Rector. The goal here was to efficiently automate code updates from Drupal 8 to 9.
What does it do?
As a set of Rector rules, Drupal Rector upgrades a deprecated API used in Drupal. You would have noticed that I did not use the plural form as in deprecated APIs because that isn’t the scope of this tool as of yet.
Don’t be disappointed. Why?
It is because the deprecated API it targets accounts to about a quarter of all API deprecations. So, using this tool would save you a ton of time and effort and eliminate any chance of human oversight since the process is automated.
Of course, there are future plans for the automated tool. The hope is to integrate it with Drupal.org and create Rector rules for as many as 15 most common deprecated API uses.
There is a chance that you might be using an Integrated Development Environment (IDE) or code editor to develop your Drupal code.
What should you do if that is the case?
The answer is use an IDE or code editor which can comprehend and identify deprecations easily and effectively.
Why is that important?
There are two reasons for that;
- One is related to visibility. If your IDE understands deprecations, it would very much make them visible even during the development process.
- And secondly, it would cancel calls to deprecated methods and further inform you of the right call to make.
PHPStorm is one example of an IDE tool that comes quite handy when considering an upgrade to Drupal 9.
Drupal.org Testing Support
For further deprecation checks, the drupal.org testing support also provides ways to identify the unwanted.
You can do this by executing your module’s test suite and configuring it to fail upon reaching a deprecated code path, you would have to widen your test coverage for the most optimal results. There is also the option of using PHPStan to generate a build artifact that would not impede the testing of your project.
Again, there are some similarities between this tool and upgrade status and Drupal check because of the PHPStan run.
The Module Upgrader is a tool more focused on projects that are on Drupal 7. Following a command-line script with the ability to scan the source of a D7 module, it can accentuate code that isn’t compatible with Drupal 8 or 9.
How does it work?
- It flags the code which needs to be updated;
- It highlights the API changes, if necessary;
- It can also convert the D7 code to D8 or 9 in an automated manner.
What is the outcome?
You would be left with updated modules that would not have any deprecated APIs in their code. Once that happens, you become one step closer to actually upgrading to Drupal 9. Remember that a Drupal 8 module without any deprecations is a good enough Drupal 9 module, because the only difference between the two is the deprecated APIs.
The name is clear enough, Migrate Tools is a module that provides additional tools for running as well as managing migrations to Drupal 8.
It works with Drush and provides commands for easy management.
- You can get see the list of migrations and their status;
- You can perform import and rollback operations;
- You can stop a running operation with ease;
- You can list fields available for mapping and view messages pertinent to migrations.
These may seem small functionalities to have, but they can add a lot of convenience to make the easiest upgrade of the decade a lot more easy.
The Migrate Plus project comes with extensions to the core migration framework functionality and examples. It can be easily implemented as configuration entities that are adaptive in terms of loading, modifications and then being saved.
For a better understanding of the Drupal 9 upgrade, you can read our blog Drupal 9 upgrade: FAQs and all your questions would be answered. And to learn more about Drupal 9, check out:
There you have it, all the necessary tools that would be required to kickstart your upgrade process, which needs to happen before November 21, 2021. To end this blog, here is a recent discussion that happened in DrupalCon North America 2021 that would highlight the same for you.