This post will save you some headaches when upgrading Drupal core from 8.7 to 8.9 addressing some common challenges.
Drupal 9.0.0 has been released simultaneously with Drupal 8.9.0. Drupal 8.9 is a long-term support version that will be supported until November 2021. Versions of Drupal 8 prior to 8.8.x are end-of-life and do not receive security coverage. Upgrading an existing site that’s not yet running on the latest core 8.8 or 8.9 can be challenging due to some new changes in Drupal core.
If your site version is below 8.7 make sure you upgrade to 8.7 first because the process would be a lot smoother if you are on Drupal 8.7
Upgrading from Drupal 8.7 or 8.8 to 8.9
Make sure you have Pathauto 1.6 or greater. You can run: composer require drupal/pathauto:^1.6
Remove/replace old dev packages composer remove –dev webflo/drupal-core-require-dev The webflo/drupal-core-require-dev provides the require-dev dependencies of drupal/core as a standalone package.
Remove the deprecated drupal-scaffold composer remove drupal-composer/drupal-scaffold Drupal-composer scaffold provides a composer plugin for placing scaffold files (like index.php, update.php, …) from the drupal/core project into their desired location inside the web root. The purpose of scaffolding files is to allow Drupal sites to be fully managed by Composer, and still allow individual asset files to be placed in arbitrary locations.
Remove Drupal core strict composer remove webflo/drupal-core-strict Drupal-core-strict is a virtual package, that causes you to get exactly the versions of Drupal core’s dependencies as they are specified in Drupal core’s composer.lock file
Add drupal/core-dev composer require –dev drupal/core-dev:^8.8
Prepare your composer.json for the new scaffold plugin. Make sure you have the following block in the extra section of your composer.json.
7. Run composer require drupal/core-recommended:^8.8 drupal/core:^8.8 drupal/core-composer-scaffold:^8.8 –update-with-dependencies
“drupal/core:^8.8” is added because the composer may not be able to resolve the dependency tree. The drupal/core-recommended is the new recommended project template for Drupal 8 projects. Once the above command is successful, you can run composer remove drupal/core to remove the package.
8. drush updatedb -y
9. drush cex -y
Check settings.php files for the $config_directories variable and replace it with $settings[‘config_sync_directory’] = ‘../config/sites/default’;
if you see an error like the one below after running composer command:
Installation failed, reverting ./composer.json to its original content. [RuntimeException] Could not delete /…/web/sites/default/default.services.yml:
You can resolve this with: chmod +w web/sites/default and run the composer command again.
If everything goes well and you see the site breaking on some pages like /admin/modules or any other page with this error in the log
DrupalCoreExtensionExceptionUnknownExtensionException: The module does not exist or is not installed. in DrupalCoreExtensionExtensionList->getExtensionInfo() (line 346 of /app/web/core/lib/Drupal/Core/Extension/ExtensionList.php).
You can resolve that by running drush ev “Drupal::configFactory()->getEditable(‘core.extension’)->set(‘profile’, ‘standard’)->save();” locally. This command enables the standard profile.
Note that you will need to run the same command on production before you can import configurations.
Do you have other tips or have questions, don’t hesitate to contact Fred.
Written by Fred Agbemenya
Developer at Ramsalt Lab