detail-cloud

Drupal 8 to Drupal 9 upgrade

Technology
22.10.2021
Fathima
Fathima
Senior Drupal Developer

Drupal 9 is a significant step forward in the evolution of Drupal projects from previous major releases. 

Drupal 9 constitutes all the features of Drupal 8, however is cleaner, more secure and packed with updated technology. The main standout feature of Drupal 9 is its ability to easily update from Drupal 8. Moreover, it also provides an even better security system, accessibility, and is multilingual in nature.

Getting into the finer details, there have been other efficiencies gained in D9. All deprecated code has been eliminated. Layout Builder and PHPUnit modules are added and are replaced instead of the Place Blocks and SimpleTest modules respectively. Drupal 9 further comprises major version updates to many of Drupal core's dependencies,   including Symfony and Twig.

Say goodbye to time-consuming and painful migrations like Drupal 7 to Drupal 8.  

Minimum requirements for a Drupal 9 upgrade
  • Our current site must be updated to the latest minor version ie Drupal 8.8+
  • Our PHP version must be PHP 7.4 or later.
  • We must upgrade contributed modules into the latest version.
  • Modify your custom module and custom theme. Removed the deprecated functions from your custom codes to make them compatible with the Drupal 9. We can use the upgrade status module to help with this.
Now we can check how we can upgrade Drupal 8 to 9.

Run below command to give Write access to the the following files:

chmod 777 web/sites/default

chmod 666 web/sites/default/*settings.php

chmod 666 web/sites/default/*services.yml

Then we need to type below comments to pull in both the Drupal 9 version of core-recommended and dev-dependencies packages as dependencies 

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

If you have drupal/core-dev installed:

composer require 'drupal/core-dev:^9' --dev --update-with-dependencies --no-update

Then update the composer 

composer update 

This will display a lot of dependency issues. Please check for patches and apply these patches to fix the issues.

Then run the below command 

composer require "drupal/core:9.0.0 as 8.9.0" --no-update && composer update

Update the DB using below comment: 

Drush updatedb

It also may display some errors, most of the cases due to deprecated functions. So we need to fix them one by one.

Give back the read only permissions using below commands.

chmod 755 web/sites/default

chmod 644 web/sites/default/*settings.php

chmod 644 web/sites/default/*services.yml

After successful upgrade change "drupal/core": "9.0.0 as 8.9", into  "drupal/core": "^9.0.0 ,in your composer.json file for the future drupal update.

After the upgrade don’t forget to verify and test your site.

Is it time to upgrade your site?

While Drupal 8 to 9 upgrades are not as complex a process as the full-rebuild required from Drupal 7 to 9 there’s still a lot to be done to make sure your site is upgraded. If your site is compatible and ripe for a Drupal 9 upgrade, please contact the Digital Garden team who call help assist.