How I upgraded my site from Drupal 9 to Drupal 10

Every Drupal website is different so every upgrade will be different. The steps I detail in this blog are very specific but might give you a direction when you get stuck upgrading a Drupal website from version 9 to 10.
Robert Roose
Door Robert Roose

How I upgraded my site from Drupal 9 to Drupal 10

Getting Started

I started by creating a Staging environment of my website. I use Cloudways to host my Drupal website so it was as easy as a few clicks in the Cloudways control panel

In this clone of my website I installed the Upgrade Status module by logging into the command line (i use MobaXterm), navigating to the directory which includes the index.php file of Drupal and typing:

composer require drupal/upgrade_status

I logged in on my cloned Drupal website and checked the info in the Upgrade Status module (admin/reports/upgrade-status). The Upgrade Status tells you what you need to do before you can upgrade

My Drupal version was already updated to the minimal required core (9.4.x) but I also had to update the PHP on my Cloudways server to 8.1 which was easily done by using the Cloudways control panel.

Updating modules

Next I looked for modules that were not compatible with Drupal 10. Luckily I didn't really need the incompatible modules so I just uninstalled them and removed the files and the directories from the modules/contrib directory by logging in via SCP (i use WinSCP).

I updated all the modules to the latest version by clicking on the version number in the Upgrade Status and opening them in a new tab. Here I copied the composer command to upgrade the module. I pasted the command into the command line and upgraded all the modules this way. As I had to upgrade 20+ modules this became a bit tedious.

Updating themes

Next I had to uninstall the themes that were deprecated in Drupal 10 such as Bartik, Seven, Stable and Classy. Navigating to 'admin/appearance' I could easily disable and uninstall Bartik and Seven. I installed Claro and set this as the admin theme.

But the Stable and Classy themes weren't showing up in the appearances/themes overview so I couldn't uninstall them. In order to make them show up I had to go into login with SCP (you can also use SFTP or FTP) and modify the the core/themes/classy.info.yml and core/themes/stable.info.yml and set hidden from true to false. After clearing the cache I was now able to uninstall both the Classy and Stable themes.

My own custom theme was depending on Classy so I needed to update the 'themes/my_theme/my_theme.info.yml' to change the base theme from classy to starterkit (which will replace the deprecated Classy and Stable themes). I also had to change the version of my theme from 9^ to 10^ to make it compatible for Drupal 10.

Updating Drupal

Now for the Drupal upgrade. I followed the instructions as detailed here and changed the directory and files permission with WinSCP as instructed. I run the following composer command:

composer require 'drupal/core-recommended:^10' 'drupal/core-composer-scaffold:^10' 'drupal/core-project-message:^10' --update-with-dependencies --no-update


And after that the actual upgrade command:

composer update

To update the database I navigated to 'mydomain.com/update.php'. I followed the instructions and waited for the database to be updated.

Troubleshooting

Going to the homepage I got a white screen of death (WSOD) with a unhelpful message telling me there was an error. I also got the same WSOD when navigating to any page on my website so I couldn't login to see a more detailed error message in the logs. In order to show a more helpful error message on the WSOD I had to turn on error messaging in my /sites/default/settings.php by adding the following code at the end:

$config['system.logging']['error_level'] = 'verbose';

 

The error message on the WSOD now told me something about the node_type plugin not existing. After some searching I found this solution by montogro. As I needed drush to export the configuration files I installed it via the command line by running the command:

composer require drush/drush

Next I run the following command:

drush cex

Now I could copy the files in my sites/default/files/myconfiguration directory to a folder on my local hard drive. I opened this folder with Visual Studio Code and searched for 'node_type'.

Just a montogro I found this being referenced in the Asset Injector module. I uninstalled the Asset Injector module with drush with the following command:

drush pm:uninstall asset_injector


After clearing the cache with drush cr I refreshed the homepage of my website and voila: It's working! I removed the error code I added to my settings.php and checked if everything worked correctly.

After I was sure the upgrade was successful I went back into my Cloudways control panel and pushed the staging files and database to the live environment.

This completed my journey to upgrade Drupal 9 to Drupal 10. Hopefully this will help you into making the upgrade for 9 to 10. Let me know in the comments if you have any comments or questions.

Related Drupal blog posts

The content of this field is kept private and will not be shown publicly.

Beperkte HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.