Skip to main content

Tips for upgrading to Drupal 10

Submitted by daniel on

After successfully upgrading to Drupal 10 I thought I would share a few tips for others as well as my own reference.

Pre Upgrade Tasks

  1. Make sure your PHP requirements are in place. Drupal 10 now requires PHP 8.1.
  2. It is now recommended that any backend database is configured to set the to 'READ COMMITTED'.
  3. Install the excellent Upgrade Status Module that utilises the excellent PHPStan library. PHPStan is a tool for scanning your codebase and helping to identify areas that may need some attention.  

Upgrade Tasks

Go though the status page on the ugrade status module and:

  1. Remove any obsolete and unused modules
  2. Identify any contrib modules or themes that may need a major or minor version upgrades and where necessary upgrade
  3. Identify any contrib modules or themes that are not yet Drupal 10 ready and try to identify any possible fixes that exist in the community. if none exist consider starting a new ticket.
  4. Address any issues that Upgrade Status may highlight. Once you have done this module you can probably uninstall it as there is no need for it on a production site.
  5. Upgrade with composer

Useful Composer Commands

  1. Lets double check to see if there are any blockers to updating. Run composer show drupal/core-recommended to see if we are indeed running drupal/core-recommended. drupal/core-recommended restricts most dependencies to patch-level updates. This is designed to help ensure for maximum stability for any code updates.
  2. Add Drupal 10 dependencies  composer require 'drupal/core-recommended:^10' 'drupal/core-composer-scaffold:^10' 'drupal/core-project-message:^10' --update-with-dependencies --no-update
  3. If using core-dev also run composer require 'drupal/core-dev:^10' --dev --update-with-dependencies --no-update
  4. If using drush I would also recommend updating to version 11 to avoid dependency clashes. e.g. composer require 'drush/drush:^11' --update-with-dependencies --no-update
  5. Finally run composer update --update-with-all-dependencies. Hopefully if this goes smoothly you will see your code base being updated to drupal 10.

Navigate and login to your drupal site and clear the cache or alternatively use something like drush. Once logged in also run any database update. Alternatively you can use drush updb

Testing

This being a major software update, I would strongly advise you run and test your code locally. This should allow you to see if there are any obvious issues and to make sure that everything has gone smoothly.

When things don't go smoothly, try and nail down the source of any issue. A good place to start is by making sure that Database Logging is enabled and look to see if you can garner a little more info on any errors that you may be experiencing there. 

Don't Panic

Things can sometimes look hairly but don't panic. For popular contributed modules, in my experience you will often find others in the community already with a fix or patch that you may need to apply in order to get things working again in next to no time.

Where there is no fix, perhaps start by raising a ticket in the appropriate place and even stepping though the code to see if you can undertand the problem and even come up with an appropriate fix your self. Obviously this can take time. Once you have finished, consider posting your fix or patch on Drupal.org, where other can use and feedback on any issues or areas for improvement. You can also use this endpoint to add it to your build.

 

Add new comment

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.