Upgrade Drupal core or module to a specific version

Intro

Upgrading Drupal is a critical task for maintaining a secure and feature-rich website.

This article guides you through the process of upgrading either the Drupal core or a specific module to a particular version.

You'll learn the essential steps to ensure a smooth and successful update, including best practices for backing up your site, running database updates, and verifying the new version is working correctly.

 

Setup:

Web server running on Ubuntu 18.04, 20.04, 22.04, LAMP stack
Drupal 8,9,10,11
Installed Drush, Composer

 

 

Case 1: Upgrade Drupal module to a specific version

For this example we are going to upgrade Drupal Devel module
 

In our setup, we have Drupal installation with installed Devel module (drupal/devel), current version is 5.3.1 and we are planing to upgrade it to 5.4.0

 

Composer command for the upgrade:

composer require $name_of_the_module:version$
Upgrade Drupal module to a specific version
composer require 'drupal/devel:^5.4' --with-all-dependencies

Composer command to upgrade Drupal module drupal/devel to a specific version 5.4
New Version can be checked on Drupal Devel Protect page

Upgrade Drupal module drupal/devel to a specific version 5.4
Upgrade Drupal module drupal/devel to a specific version 5.4

After a successful upgrade, you'll need to run specific Drush commands to complete the process.

drush updb
drush cr

 

 

Case 2: Upgrade Drupal Core to a specific version

To upgrade Drupal core to a specific version, a Composer command must be executed that specifies the core packages and all their dependencies.
We are going to upgrade current Drupal to Drupal 10.5.3 version.

 

Composer command for the upgrade:

composer require drupal/core-recommended:10.5.3 drupal/core-composer-scaffold:10.5.3 drupal/core-project-message:10.5.3 --update-with-all-dependencies
Upgrade Drupal Core
composer require drupal/core-recommended:10.5.3 drupal/core-composer-scaffold:10.5.3 drupal/core-project-message:10.5.3 --update-with-all-dependencies

Upgrade Drupal Core to specific version 10.5.3

Result of upgrading Drupal Core to  version 10.5.3
Result of upgrading Drupal Core to version 10.5.3

After a successful upgrade, you'll need to run specific Drush commands to complete the process.

drush updb
drush cr

 

Summary

Upgrading Drupal core or a specific module to a new version is a crucial maintenance task, best performed using Composer, which involves backing up your site, running the update, and then executing database and cache updates to ensure a smooth transition.