Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Upgrading to Drupal 9

Upgrading to Drupal 9

For most Drupal Developers and users, the idea of moving a project from one major version of Drupal to another can be daunting, with modules and themes having to being changed significantly or rebuilt completely, and data being migrated from the old site to the new one.

This was no more so than the move from Drupal 7 to 8, but luckily this has changed for Drupal 9 and an upgrade can be done with minimal changes and not a data migration in sight!

In this talk, we'll look at some of the changes to Drupal's tools and processes that have made this possible, and how to move your Drupal site to Drupal 9.

https://www.oliverdavies.uk/talks/upgrading-your-site-drupal-9

71c9ebde850996d2533c5df4df2c93c6?s=128

Oliver Davies

April 22, 2021
Tweet

Transcript

  1. Upgrading to Drupal 9 Oliver Davies, Inviqa

  2. @opdavies

  3. The D7 release cycle • One long-running branch • Minor

    versions for bug fixes (7.80, April 2021) • No big, new features • Long time for changes to get committed to core @opdavies
  4. The D8 release cycle • Semantic versioning for core •

    Minor release (new features) every 6 months • Patch release (bug fixes) every month • Multiple supported versions of core (8.9, 9.0, 9.1) @opdavies
  5. @opdavies

  6. Drupal 8 vs Drupal 9 • No new functionality •

    Deprecated code removed • PHP required version increased • Major versions of dependencies updated @opdavies
  7. Previous upgrade issues • Lots of breaking changes • Core

    released, but contrib takes time to catch up @opdavies
  8. Contrib improvements • Minimal code changes required • Single release

    can support multiple versions of core • Semantic versioning enabled for contrib projects @opdavies
  9. @opdavies

  10. The difference is deprecated code @opdavies

  11. Deprecation example function drupal_set_message($message = NULL, $type = 'status', $repeat

    = FALSE) { @trigger_error('drupal_set_message() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Messenger\MessengerInterface ::addMessage() instead. See https://www.drupal.org/node/2774931', E_USER_DEPRECATED); $messenger = \Drupal::messenger(); if (isset($message)) { $messenger->addMessage($message, $type, $repeat); } return $messenger->all(); } @opdavies
  12. How do I find it? @opdavies

  13. Drupal Check • Developed by Matt Glaman • "Built on

    PHPStan, this static analysis tool will check for correctness (e.g. using a class that doesn't exist), deprecation errors, and more." • https://github.com/mglaman/drupal-check @opdavies
  14. composer global require mglaman/drupal-check @opdavies

  15. drupal-check web/modules/custom @opdavies

  16. @opdavies

  17. Upgrade Status module @opdavies

  18. @opdavies

  19. PHPUnit Bridge • Drupal 8 uses Symfony's PHPUnit Bridge •

    Includes a 'Deprecation Helper' • Displays deprecation notices in test output @opdavies
  20. @opdavies

  21. Fixing deprecations - drupal_set_message($text); + Drupal::messenger()->addMessage($text); @opdavies

  22. @opdavies

  23. Composer • Dependency management tool for PHP • My preferred

    way to manage Drupal codebases • composer.json lists your dependencies and version constraints • composer.lock stores the installed dependencies and versions • Separate packages for core-recommended, core-dev and core-composer-scaffold @opdavies
  24. composer require drupal/admin_toolbar:^2.0 @opdavies

  25. composer install @opdavies

  26. composer update drupal/admin_toolbar @opdavies

  27. Always add '--no-dev' in production @opdavies

  28. An Example: Dransible https://github.com/opdavies/dransible @opdavies

  29. @opdavies

  30. Upgrading Dransible • Remove Drush (temporarily) • Update from Drupal

    8.8 to 8.9 • Add Upgrade Status module • Update contrib modules to D9 compatible versions • Remove incompatible contrib modules (if possible) • Fix deprecations in custom code • Upgrade from Drupal 8.9 to 9.0 @opdavies
  31. composer update drupal/core-* --with-dependencies @opdavies

  32. composer require drupal/upgrade_status @opdavies

  33. @opdavies

  34. @opdavies

  35. @opdavies

  36. @opdavies

  37. @opdavies

  38. @opdavies

  39. composer update drupal/core-* --with-dependencies @opdavies

  40. @opdavies

  41. @opdavies

  42. There were some autowiring gotchas... @opdavies

  43. Error: Class 'Symfony\Component\Config\Resource\ClassE xistenceResource' not found in Symfony\Component\Depen dencyInjection\Compiler\AutowirePass->createTypeNotFou ndMessage()

    @opdavies
  44. composer require symfony/config:^4 @opdavies

  45. Cannot autowire service "Drupal\simple_message\Display SimpleMessage": argument "$messenger" of method "__con

    struct()" references interface "Drupal\Core\Messenger\ MessengerInterface" but no such service exists. You sh ould maybe alias this interface to the existing "messe nger" service @opdavies
  46. Fixing autowiring services: Drupal\simple_message\DisplaySimpleMessage: autowire: true tags: - { name:

    event_subscriber } @opdavies
  47. Fixing autowiring services: + Drupal\Core\Messenger\MessengerInterface: + alias: messenger + private:

    true Drupal\simple_message\DisplaySimpleMessage: autowire: true tags: - { name: event_subscriber } @opdavies
  48. The big deal about Drupal 9 is... that it should

    not be a big deal Dries Buytaert @opdavies
  49. Drupal 10 • Released around June 2022 • Drupal 9

    EOL around November 2023 • Symfony 4 EOL in November 2023 • Another easy upgrade @opdavies
  50. Thanks! References: • https://www.drupal.org/docs/understanding-drupal • https://dri.es/drupal-9-0-0-released • https://dri.es/drupal-10-target-release-date-and-drupal-9-end-of-life • https://github.com/opdavies/dransible

    Me: • https://www.oliverdavies.uk @opdavies