DEV Community

Nevin Katz
Nevin Katz

Posted on • Updated on

My Experience with a Drupal 8/9 Update Part 1: The Local Environment

Part 1 | Part 2 | Part 3

Monday night was one of those nights that I couldn't look away. I kept trying to upgrade my Drupal 8 site using a number of strategies, all to no avail. By the end of a long night I was soundly defeated by Drupal and its nefarious sidekick, Composer.

At least they seem adversaries in those moments. In the best of times, they are great allies that just get a little cantankerous sometimes.

One day later and I am back at it again - working on upgrading a multiple-website system from Drupal 8 to Drupal 9.

In this article I am listing out the Drupal migration tips and tricks that I wish I had known at the outset of this journey.

While this will not entail a complete rebuild along the lines of Drupal 7 to Drupal 9,, one challenge is that this is a Drupal multisite system where 20+ sites have to be upgraded.

Jargon

For those of you new to the jargon, Drupal is a content management system with endless possibilities but also endless headaches at times. Composer is a dependency manager that helps to keep Drupal's various dependencies all straightened out.

Symfony is a popular PHP framework that you're not supposed to have to adjust - it's like node_modules in that regard. It was throwing errors during the direct upgrade and the core reason I am changing my approach from a direct migration to a ground-up build.

Approach

My strategies:

  • Starting at Drupal 9.0.1 since it is closest to Drupal 8.9.17.

  • Using Lando for my local setup.

  • Starting with a Vanilla Site, then will make a backup.

  • settings.php file and directory structure is modeled after our current site, which resides on Acquia Cloud.

  • git repo comes from our current site; I swapped in new vendor, the web directory, and other key directories that are all 9.0.1.

Starting with a Drupal 9 instance

At first, I was trying a direct upgrade from Drupal 8 to Drupal 9. Because this introduced too many complications, I have switched to building a 9.0.1 site from the ground up.

Once I'm ready I plan to add the contrib modules and import my database.

My approach of building the D9 site from the ground up and then adding in assets is for several reasons:

  • We want to switch our local systems from Acquia Dev Desktop to Lando, and this is a good opportunity.
  • Upgrading a D8 install directly to D9 introduces issues with symfony dependencies that are hard to parse out.
  • lightning modules upgrades got especially tough, so starting with D9 allows me to reinstall the correct versions more easily.

Key Takeaways Thus Far

A few things I have learned:

If your webroot is not toplevel you have to update it in multiple places in composer.json.

You get into a chicken-and-egg situation with composer you can update all at once with composer require resource1:x.x.x resource:y.y.y --with-all-dependencies

Sometimes obliterating composer.lock and vendor directories are a great way to go.

I'll probably update this post as I find out more. Hope this helps other Drupallers out there.

General Updates

Below are some updates I posted throughout the day (8/3/21).

  • My local blank hub site is working. Yay!

  • I am now gradually adding modules with Composer and listing out the ones that do not install. For those, we will see if we can turn them off on our 20+ live sites before the code upgrade.

  • Overall my trust in Composer is returning after the debacle yesterday.

  • After installing the required modules, I then installed the theme. This requires changing some compatibility in their .yml files. Backing up the site while the base theme is installed has been critical. Replacing core:'8.x' with core_version_requirement: ^8 || ^9 in the theme.info.yml files seems necessary but not sufficient.

  • I just installed the Upgrade Status module, which tells me that none of my modules are ready for Drupal 10. Who cares about 10? I'm still trying to get to 9! It also may help me to figure out why my themes are incompatible. This way I can learn about why they don't work without enabling them.

  • Well, well, well. Even though the themes are in the green now, I am back to getting a symfony error related to a dependency injection. This is what drove me to switch strategies, but now I have a better idea of what triggers it. It seems to be a theme issue.

The error from admin/reports/dblog is below.


Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "path.alias_manager". Did you mean this: "path_alias.manager"? in Drupal\Component\DependencyInjection\Container->get() (line 151 of /app/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php).

  • After a bit of searching I ran across this resource, which was the key. I had to change path.alias_manager to path_alias.manager in three places.
  • It worked! The Porto theme now shows up.
  • Importing the database from our hub site still causes errors.
  • It is amazing what I am learning by re-adding all the site assets. I now see that I have needed some profiles in our profiles directory. On the update.php page Now I see a bunch more missing modules that I thought were optional.
  • All modules are added. The lightning media and entity_embed_link module had to be added manually to get to the update screen.
  • I am now going through 112 database updates.
  • Getting a white screen, but running lando logs indicated it was due to one line of deprecated code in the theme. I am changing entity_load_multiple_by_properties to loadByProperties in my porto.theme file.
  • The first site works!
  • Just tested on the remote site is still a work in progress. I will need make some changes to settings.php but we are moving along. That's all for now!

Elsewhere

Part 2 | Part 3

7 Tips on Upgrading from Drupal 8 to Drupal 9

Discussion (0)