diff --git a/upgrading-to-drupal-9/README.rst b/upgrading-to-drupal-9/README.rst new file mode 100644 index 0000000..e624dc2 --- /dev/null +++ b/upgrading-to-drupal-9/README.rst @@ -0,0 +1,4 @@ +Upgrading to Drupal 9 +##################### + +https://www.oliverdavies.uk/talks/upgrading-your-site-drupal-9 diff --git a/upgrading-to-drupal-9/images/10-years-tweet.png b/upgrading-to-drupal-9/images/10-years-tweet.png new file mode 100644 index 0000000..53c8915 Binary files /dev/null and b/upgrading-to-drupal-9/images/10-years-tweet.png differ diff --git a/upgrading-to-drupal-9/images/2019_minor_release_schedule.png b/upgrading-to-drupal-9/images/2019_minor_release_schedule.png new file mode 100644 index 0000000..136c432 Binary files /dev/null and b/upgrading-to-drupal-9/images/2019_minor_release_schedule.png differ diff --git a/upgrading-to-drupal-9/images/broadbean-drupal-flow-2.png b/upgrading-to-drupal-9/images/broadbean-drupal-flow-2.png new file mode 100644 index 0000000..da80f78 Binary files /dev/null and b/upgrading-to-drupal-9/images/broadbean-drupal-flow-2.png differ diff --git a/upgrading-to-drupal-9/images/broadbean-website.png b/upgrading-to-drupal-9/images/broadbean-website.png new file mode 100644 index 0000000..37d7bf1 Binary files /dev/null and b/upgrading-to-drupal-9/images/broadbean-website.png differ diff --git a/upgrading-to-drupal-9/images/dransible-repo.png b/upgrading-to-drupal-9/images/dransible-repo.png new file mode 100644 index 0000000..e4b6468 Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-repo.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/1.png b/upgrading-to-drupal-9/images/dransible-screenshots/1.png new file mode 100644 index 0000000..eb1423d Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/1.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/10.png b/upgrading-to-drupal-9/images/dransible-screenshots/10.png new file mode 100644 index 0000000..02a76d7 Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/10.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/2.png b/upgrading-to-drupal-9/images/dransible-screenshots/2.png new file mode 100644 index 0000000..2408190 Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/2.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/3.png b/upgrading-to-drupal-9/images/dransible-screenshots/3.png new file mode 100644 index 0000000..bf9f4b5 Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/3.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/4.png b/upgrading-to-drupal-9/images/dransible-screenshots/4.png new file mode 100644 index 0000000..524bbca Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/4.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/5.png b/upgrading-to-drupal-9/images/dransible-screenshots/5.png new file mode 100644 index 0000000..cc69481 Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/5.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/6.png b/upgrading-to-drupal-9/images/dransible-screenshots/6.png new file mode 100644 index 0000000..5f5f9fb Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/6.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/7.png b/upgrading-to-drupal-9/images/dransible-screenshots/7.png new file mode 100644 index 0000000..8abc7cf Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/7.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/8.png b/upgrading-to-drupal-9/images/dransible-screenshots/8.png new file mode 100644 index 0000000..5c5068c Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/8.png differ diff --git a/upgrading-to-drupal-9/images/dransible-screenshots/9.png b/upgrading-to-drupal-9/images/dransible-screenshots/9.png new file mode 100644 index 0000000..b572f5b Binary files /dev/null and b/upgrading-to-drupal-9/images/dransible-screenshots/9.png differ diff --git a/upgrading-to-drupal-9/images/drupal-association.png b/upgrading-to-drupal-9/images/drupal-association.png new file mode 100644 index 0000000..cf93e83 Binary files /dev/null and b/upgrading-to-drupal-9/images/drupal-association.png differ diff --git a/upgrading-to-drupal-9/images/drupal-check-output.png b/upgrading-to-drupal-9/images/drupal-check-output.png new file mode 100644 index 0000000..c7c7ab7 Binary files /dev/null and b/upgrading-to-drupal-9/images/drupal-check-output.png differ diff --git a/upgrading-to-drupal-9/images/drupal-check-upgrade-status-comparison.png b/upgrading-to-drupal-9/images/drupal-check-upgrade-status-comparison.png new file mode 100644 index 0000000..58b0e34 Binary files /dev/null and b/upgrading-to-drupal-9/images/drupal-check-upgrade-status-comparison.png differ diff --git a/upgrading-to-drupal-9/images/logo-composer-transparent.png b/upgrading-to-drupal-9/images/logo-composer-transparent.png new file mode 100644 index 0000000..e0782d0 Binary files /dev/null and b/upgrading-to-drupal-9/images/logo-composer-transparent.png differ diff --git a/upgrading-to-drupal-9/images/matt-stauffer-tweet.png b/upgrading-to-drupal-9/images/matt-stauffer-tweet.png new file mode 100644 index 0000000..3f27a45 Binary files /dev/null and b/upgrading-to-drupal-9/images/matt-stauffer-tweet.png differ diff --git a/upgrading-to-drupal-9/images/multiple-versions.png b/upgrading-to-drupal-9/images/multiple-versions.png new file mode 100644 index 0000000..f5fcfe3 Binary files /dev/null and b/upgrading-to-drupal-9/images/multiple-versions.png differ diff --git a/upgrading-to-drupal-9/images/override-node-options-2012-4.png b/upgrading-to-drupal-9/images/override-node-options-2012-4.png new file mode 100644 index 0000000..2b69070 Binary files /dev/null and b/upgrading-to-drupal-9/images/override-node-options-2012-4.png differ diff --git a/upgrading-to-drupal-9/images/override-node-options-2020-2.png b/upgrading-to-drupal-9/images/override-node-options-2020-2.png new file mode 100644 index 0000000..5af45b7 Binary files /dev/null and b/upgrading-to-drupal-9/images/override-node-options-2020-2.png differ diff --git a/upgrading-to-drupal-9/images/phpunit-deprecation.png b/upgrading-to-drupal-9/images/phpunit-deprecation.png new file mode 100644 index 0000000..4d7343e Binary files /dev/null and b/upgrading-to-drupal-9/images/phpunit-deprecation.png differ diff --git a/upgrading-to-drupal-9/images/semver.png b/upgrading-to-drupal-9/images/semver.png new file mode 100644 index 0000000..56512f7 Binary files /dev/null and b/upgrading-to-drupal-9/images/semver.png differ diff --git a/upgrading-to-drupal-9/images/timmillwood-ono.png b/upgrading-to-drupal-9/images/timmillwood-ono.png new file mode 100644 index 0000000..be4eda4 Binary files /dev/null and b/upgrading-to-drupal-9/images/timmillwood-ono.png differ diff --git a/upgrading-to-drupal-9/images/title.png b/upgrading-to-drupal-9/images/title.png new file mode 100644 index 0000000..3110bf9 Binary files /dev/null and b/upgrading-to-drupal-9/images/title.png differ diff --git a/upgrading-to-drupal-9/main.style b/upgrading-to-drupal-9/main.style new file mode 100644 index 0000000..1465bdc --- /dev/null +++ b/upgrading-to-drupal-9/main.style @@ -0,0 +1,110 @@ +pageSetup: + firstTemplate: coverPage + height: 18cm + margin-bottom: 0cm + margin-gutter: 0cm + margin-left: 0cm + margin-right: 0cm + margin-top: 0cm + size: null + spacing-footer: 2mm + spacing-header: 2mm + width: 32cm + +pageTemplates: + coverPage: + frames: [] + [12%, 10%, 76%, 75%] + showFooter: false + showHeader: false + + titlePage: + alignment: TA_CENTER + frames: [] + [8%, 8%, 85%, 60%] + showFooter: true + showHeader: false + + standardPage: + frames: [] + [3%, 3%, 94%, 92%] + showFooter: true + showHeader: false + + imagePage: + alignment: TA_CENTER + frames: [] + [12%, 10%, 76%, 80%] + showFooter: true + showHeader: false + +linkColor: #24608a + +styles: + normal: + fontSize: 28 + textColor: #383745 + + bodytext: + alignment: TA_LEFT + + heading: + alignment: TA_CENTER + fontSize: 24 + spaceAfter: 16 + textColor: #24608a + + heading1: + parent: heading + alignment: TA_LEFT + + title: + fontSize: 250% + parent: heading + + bullet-list: + commands: [] + [LEFTPADDING, [0, 0], [1, -1], 10] + [RIGHTPADDING, [0, 0], [1, -1], 0] + [VALIGN, [0, 0], [-1, -1], TOP] + colWidths: ["20", null] + textColor: #aaaaaa + + bullet-list-item: + spaceBefore: 14 + spaceAfter: 0 + + titleslideinfo: + alignment: TA_CENTER + fontSize: 120% + parent: normal + + footer: + alignment: TA_RIGHT + fontName: stdMono + fontSize: 18 + textColor: #24608a + rightIndent: 16 + spaceBefore: 0 + + literal: + backColor: #eeeeee + fontName: stdMono + + code: + backColor: #eeeeee + borderWidth: 0 + fontSize: 24 + parent: literal + spaceBefore: 4 + + blockquote: + parent: normal + fontName: stdItalic + + attribution: + parent: normal + textColor: #666666 + + smaller: + textColor: red diff --git a/upgrading-to-drupal-9/slides.rst b/upgrading-to-drupal-9/slides.rst new file mode 100644 index 0000000..9faf64e --- /dev/null +++ b/upgrading-to-drupal-9/slides.rst @@ -0,0 +1,454 @@ +.. footer:: @opdavies + +Upgrading to Drupal 9 +##################### + +| + +.. class:: titleslideinfo + +Oliver Davies, Inviqa + +.. raw:: pdf + + PageBreak imagePage + +.. image:: images/10-years-tweet.png + :width: 22cm + +.. raw:: pdf + + TextAnnotation "Recently, I passed 10 years working full-time with Drupal and PHP (I'd been working with it for a few years prior to this too)." + TextAnnotation "Worked with Drupal 6, 7, 8 and 9." + TextAnnotation "Worked on a number of D6 to D7, and D8 to D9 upgrades" + + PageBreak standardPage + +The D7 release cycle +==================== + +* One long-running branch +* Minor versions for bug fixes (7.73) +* No big, new features +* Long time for changes to get committed to core + +.. raw:: pdf + + TextAnnotation "Before we get into the D9 stuff." + TextAnnotation "D7 and earlier..." + +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.8, 8.9, 9.0) + +.. raw:: pdf + + TextAnnotation "Drupal 8 onwards..." + TextAnnotation "Minor release = new functionality" + TextAnnotation "Patch release = bug fixes" + TextAnnotation "Change from 'it will be ready when it's ready' (D7) to a fixed release cycle and schedule, and what makes it in time will be added." + +.. raw:: pdf + + PageBreak imagePage + +.. image:: images/2019_minor_release_schedule.png + :width: 20cm + +.. raw:: pdf + + PageBreak standardPage + +Drupal 8 vs Drupal 9 +==================== + +* No new functionality +* Deprecated code removed +* PHP required version increased +* Major versions of dependencies updated + +.. raw:: pdf + + TextAnnotation "Different to previous major version updates" + TextAnnotation "Symfony upgraded from 3 to 4." + +Previous upgrade issues +======================= + +* Lots of breaking changes +* Core released, but contrib takes time to catch up + +.. raw:: pdf + + TextAnnotation "Lots of breaking changes, large rebuilds and migrations" + TextAnnotation "6(?) months between D7 core and Views being released, prevents adoption" + TextAnnotation "Jeff Geerling blog post 'Did breaking backwards compatibility kill Drupal?'" + +Contrib improvements +==================== + +* Minimal code changes required +* Single release can support multiple versions of core +* Semantic versioning enabled for contrib projects + +.. raw:: pdf + + TextAnnotation "Need to fix deprecation notices, and replace deprecated code with the suggested replacements" + TextAnnotation "Modules, themes and distributions can now work with multiple versions of Drupal core in the same release" + TextAnnotation "`core` key replaced with `core_version_requirement`" + + PageBreak imagePage + +.. image:: images/multiple-versions.png + :width: 20cm + +| + +.. image:: images/semver.png + :width: 20cm + +.. raw:: pdf + + PageBreak titlePage + +The difference is deprecated code +================================== + +.. raw:: pdf + + TextAnnotation "Code that has been replaced by newer code and marked to be removed." + TextAnnotation "Not removed immediately to keep backwards compatibility." + TextAnnotation "A backwards compatibility break would require a major version change rather than a minor one." + + PageBreak standardPage + +Deprecation example +=================== + +.. code-block:: php + :startinline: true + + 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(); + } + +.. raw:: pdf + + TextAnnotation "drupal_set_message has been replaced by a Messenger service, this should be used instead." + TextAnnotation "Works but triggers an error in 8.9, breaks in 9.0." + TextAnnotation "To ensure D9 compatibility, update all of the deprecated code." + + PageBreak titlePage + +How do I find it? +================= + +.. raw:: pdf + + PageBreak standardPage + +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 + +.. raw:: pdf + + PageBreak titlePage + +composer global require mglaman/drupal-check +============================================ + +drupal-check web/modules/custom +=============================== + +.. raw:: pdf + + PageBreak imagePage + +.. image:: images/drupal-check-output.png + :width: 22cm + +.. raw:: pdf + + PageBreak titlePage + +Upgrade Status module +===================== + +.. raw:: pdf + + PageBreak imagePage + +.. image:: images/drupal-check-upgrade-status-comparison.png + :width: 12cm + +.. raw:: pdf + + PageBreak standardPage + +PHPUnit Bridge +============== + +- Drupal 8 uses Symfony's PHPUnit Bridge +- Includes a 'Deprecation Helper' +- Displays deprecation notices in test output + +.. raw:: pdf + + PageBreak imagePage + +.. image:: images/phpunit-deprecation.png + :width: 23cm + +.. raw:: pdf + + PageBreak standardPage + +Fixing deprecations +=================== + +.. code-block:: diff + + - drupal_set_message($text); + + Drupal::messenger()->addMessage($text); + +.. image:: images/logo-composer-transparent.png + :width: 10cm + +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`` + +.. raw:: pdf + + TextAnnotation "Used by the majority of PHP frameworks and projects (Symfony, Laravel, Drush, Drupal Console)." + + PageBreak titlePage + +composer require drupal/admin_toolbar:^2.0 +========================================== + +composer install +================ + +composer update drupal/admin_toolbar +==================================== + +Always add '--no-dev' in production +=================================== + +.. raw:: pdf + + TextAnnotation "Prevents development dependencies from being installed, and potential security exploits from being added." + +An Example: Dransible +===================== + +https://github.com/opdavies/dransible + +.. raw:: pdf + + PageBreak imagePage + +.. image:: images/dransible-repo.png + :width: 20cm + +.. raw:: pdf + + PageBreak standardPage + +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 + +.. raw:: pdf + + TextAnnotation "Without removing Drush, 8.9.0-beta2 rather than 8.9.2" + TextAnnotation "Updated Admin Toolbar module to a D9 compatible version" + TextAnnotation "Removed Config Installer as no longer needed" + TextAnnotation "Fixed deprecation warnings in custom code" + TextAnnotation "Installed Drush 10, removed and uninstalled Upgrade Status module" + + PageBreak titlePage + +composer update drupal/core-* --with-dependencies +================================================= + +composer require drupal/upgrade_status +====================================== + +.. raw:: pdf + + PageBreak imagePage + +.. image:: images/dransible-screenshots/1.png + :width: 22cm + +.. image:: images/dransible-screenshots/2.png + :width: 22cm + +.. image:: images/dransible-screenshots/3.png + :width: 22cm + +.. image:: images/dransible-screenshots/4.png + :width: 22cm + +.. image:: images/dransible-screenshots/5.png + :width: 22cm + +.. image:: images/dransible-screenshots/6.png + :width: 20cm + +.. image:: images/dransible-screenshots/7.png + :width: 22cm + +.. image:: images/dransible-screenshots/8.png + :width: 22cm + +.. raw:: pdf + + PageBreak titlePage + +composer update drupal/core-* --with-dependencies +================================================= + +.. raw:: pdf + + PageBreak imagePage + +.. image:: images/dransible-screenshots/9.png + :width: 22cm + +.. image:: images/dransible-screenshots/10.png + :width: 20cm + +.. raw:: pdf + + TextAnnotation "Only 6 files changed rather than hundreds or thousands" + TextAnnotation "Vast majority of the changes in composer.lock (to be expected)" + TextAnnotation "Half of the changed files are project specific. Could have been 2 or 3 files changed on some projects." + + PageBreak titlePage + +There were some autowiring gotchas... +===================================== + +.. raw:: pdf + + PageBreak + +Error: Class 'Symfony\Component\Config\Resource\ClassExistenceResource' not found in Symfony\Component\DependencyInjection\Compiler\AutowirePass->createTypeNotFoundMessage() + +composer require symfony/config:^4 +================================== + +.. raw:: pdf + + TextAnnotation "Composer tried installing version 5 by default, so locked to 4.x." + + PageBreak + +Cannot autowire service "Drupal\simple_message\DisplaySimpleMessage": argument "$messenger" of method "__construct()" references interface "Drupal\Core\Messenger\MessengerInterface" but no such service exists. You should maybe alias this interface to the existing "messenger" service + +.. raw:: pdf + + PageBreak standardPage + +Fixing autowiring +================= + +.. code-block:: yaml + + services: + Drupal\simple_message\DisplaySimpleMessage: + autowire: true + tags: + - { name: event_subscriber } + +Fixing autowiring +================= + +.. code-block:: diff + + services: + + Drupal\Core\Messenger\MessengerInterface: + + alias: messenger + + Drupal\simple_message\DisplaySimpleMessage: + autowire: true + tags: + - { name: event_subscriber } + +.. raw:: pdf + + PageBreak titlePage + +.. + + The big deal about Drupal 9 is... that it should not be a big deal + + -- Dries Buytaert + +.. raw:: pdf + + TextAnnotation "Dransible updated in 1-2 hours." + TextAnnotation "No big rewrite." + TextAnnotation "Smallest core update PR ever!" + + PageBreak standardPage + +Drupal 10 +========= + +- Released around June 2022 +- Drupal 9 EOL around November 2023 +- Symfony 4 EOL in November 2023 +- Another easy upgrade + +.. raw:: pdf + + TextAnnotation "Need to keep up to date with dependencies." + +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