Sorry, you need to enable JavaScript to visit this website.

How to upgrade your Drupal 8 site to Drupal 9

Do you need help with your Drupal website?

Fill in your email and query below and we can chat.

More info here

Submitted by abhaisasidharan on Mon, 09/07/2020 - 06:17
Drupal 9

Drupal 9 was released on June 3rd and I have been wanting to upgrade my site since then. And now I have. It was quite simple. All I had to do was follow the blog written by Dries on Drupal.orghttps://www.drupal.org/docs/upgrading-drupal/upgrading-from-drupal-8-to-drupal-9-or-higher.

Let me show you..

  # From the blog above.
  chmod 777 docroot/sites/default/
  chmod 777 -R docroot/sites/default/

  # FYI I use lando for development.
  lando composer require drupal/core-recommended:^9.0.0 drupal/core-composer-scaffold:^9.0.0 --update-with-dependencies --no-update
  lando composer update
  lando composer why drupal-composer/drupal-scaffold
  lando composer remove drupal-composer/drupal-scaffold

  # Making sure drupal/core-dev is under require_dev
  lando composer require drupal/core-dev:^9.0.0 --dev --update-with-dependencies --no-update
  lando composer update

  # Some dependencies were unmet so the blog recommends to do this.
  lando composer require "drupal/core:9.0.0 as 8.9.0" --no-update && lando composer update
  
  # Remove blt temporarily.
  lando composer remove acquia/blt --no-update
  lando composer update

  # Add the supported version of devel.
  lando composer require drupal/devel:^3.0 --no-update
  lando composer update
  lando composer remove drupal/devel_generate --no-update
  lando composer update

  # Remove drupal/console temporarily.
  lando composer remove drupal/console --no-update
  lando composer update

  # Need to include the right version = 4.
  lando composer require symfony/dom-crawler:^4 --no-update
  lando composer update
  lando drush updb
  
  # Debugging
  lando drush updb --debug

  # A patch is required for jsonapi_extras to work properly.
  # Here it is: https://www.drupal.org/files/issues/2020-06-12/jsonapi_extras-drupal9-compatibility-3147876-6.patch
  lando composer update drupal/jsonapi_extras
  
  git status
  git checkout -b 9.x

  lando drush cr
  
  # The service path.alias_manager does not exists. Instead use path_alias.manager.
  # I submitted patches for all incompatible modules that I use.
  grep -rn 'path.alias_manager' docroot/modules/contrib/
  lando drush cr
  grep -rn 'path.alias_manager' docroot/modules/contrib/
  clear
  grep -rn 'path.alias_manager' docroot/modules/contrib/
  lando drush cr
  lando composer install

  # Reverting file permissions.
  sudo chmod 600 docroot/sites/default/settings*
  git status
  sudo chmod 600 docroot/sites/default/services.yml
  lando drush ws
  sudo chmod 777 docroot/sites/default/files/
  sudo chmod 777 -R docroot/sites/default/files/

  # Copied the history to document it later here.
  history

Most of the contributed modules I have used have either had a Drupal 9 compatible release or a supporting dev version. But here are the ones that had deprecated code.

       "patches": {
            "drupal/ckeditor_lineheight": {
                "Change plugin path": "https://www.drupal.org/files/issues/2018-11-21/2956943_ckeditor_lineheight_library_path.patch"
            },
            "drupal/jsonapi_extras": {
                "Drupal 9 compatibility": "https://www.drupal.org/files/issues/2020-06-12/jsonapi_extras-drupal9-compatibility-3147876-6.patch"
            },
            "drupal/rest_menu_items": {
                "Drupal 9 compatibility": "https://www.drupal.org/files/issues/2020-06-10/dupal9-path-alias-3150452-2.patch"
            },
            "drupal/disqus": {
                "Drupal 9 compatibility": "https://www.drupal.org/files/issues/2020-06-10/D9-readiness-3143716-5.patch"
            },
            "drupal/fontyourface": {
                "Drupal 9 compatibility": "https://www.drupal.org/files/issues/2020-05-23/fontyourface-3042792-9.patch"
            },
            "drupal/login_security": {
                "Drupal 9 compatibility": "https://www.drupal.org/files/issues/2020-06-04/3042720-9_0.patch"
            }
        }

Feel free to use the patches and let me know if I missed something. I am still solving certain issues on the XML sitemap module, but overall it's looking good and some of the custom features I implemented are working quite well. Since I was already using PHP 7.4, it was quite easy to transition to Drupal 9. Feel free to ask questions (in the comments section) if you have problems upgrading.

Huzzah!