Drupal Lightning

How an upgrade from Drupal 8.2 to 8.5 took over 20 hours

And how it became a deep dive into understanding composer.json and your dependencies

Preface

  • Inherit site built in Drupal 8.3.x
  • Built using the Lightning distribution
    • Everything in git
    • No build process
  • Client filed ticket in January 2018
  • Work didn't begin till June 2018
    • Feature requests

How hard could it be?

Very

Have to vent on this. The lightning distribution for Drupal is absolute trash. Upgrades between versions are broken. Do not use. Period.

— Ashok Modi (@btmash) July 5, 2018

About presentation

  • Large chunk will be going through git logs
    • Looking at diff of composer.json
  • What it took to get there

Steps

Remove PHP version dependency

  • Server runs PHP 5.6
  • Locally run PHP 7.1
  • Add dependency in composer.json
  • "config": {
      ...
      "platform": {
        "php": "5.6"
      }
    },
    

Splitting the issues

  • Upgrading Drupal was not the solution
  • Upgrade Lightning
    • Upgrade 2.1.x to 2.1.8 ☺
    • Upgrade from 2.1.8 to 2.2.9*
    • Upgrade from 2.2.9 to 3.0.6 ☺
    • Upgrade from 3.0.6 to 3.1.5*

 

☺ There were minor issues in the upgrade

* There were major issues in the minor releases

Upgrade from 2.1.x to 2.1.8

  • Minor issues involving pinned releases of dependencies
    • css-selector needed to be upgraded in order to work correctly
      • Changed from "2.7" to "~2.7"
        • This means the last digit of the version can be updated
    • Drupal Console needed to be pinned down in order to work correctly
      • Paragraphs (1.x-dev -> 1.2)
      • Smart Trim (actually versioned)
      • Pathauto (1.x -> 1.0)

Upgrade from 2.1.8 to 2.2.10

  • This became a multi-part issue of its own
  • Needed to upgrade from 2.1.8 to 2.2.3 (Drupal 8)
    • Pin down version of Drupal core (8.4.0)
      • Pathauto
      • Workbench
      • Media Entity Image
      • Media Entity Document

Upgrade to 2.2.4

  • *MUST* run the content migration from workbench moderation to content moderation
    • Lightning update mentions it is optional - it is not
    • Lightning 3.0.x removes the non-core moderation and scheduling modules
    • Found out the hard way
    • Otherwise you run drush wbm2cm manually

Upgrade to 2.2.10

  • Mostly smooth
  • Needed to bring in own dependencies that were previously in lightning
    • Scheduled updates
    • Features
    • Config update
    • Core could finally be on full 8.4.8

Upgrade to 3.0.6

  • Technically still 8.4.8
    • What is the point?
  • Completely revised the structure within acquia/lightning
    • drupal/lightning_api
    • drupal/lightning_core
    • drupal/lightning_media
    • drupal/lightning_workflow
    • drupal/lightning_layout
    • each has its own composer.json file (and dependencies)!

2.2.x to 3.0.x

  • Mostly the dev dependencies were not downloading
    • More were added to composer.json

3.0.x to 3.1.x

  • Jumping directly to the latest 3.1.5 version would be a large migration
    • Untested
  • Upgrade first to 3.1.0
    • Pin down version of Drupal core to 8.5.3 (will get all necessary security updates)
  • Then set time for larger migration
    • TBD!!!

Helpful bits of information

  • Pin things fully in composer if need be:
    • acquia/lightning: "3.1.0"
    • drupal/core: "8.5.3"
    • drupal/console: "~1.0.1"
      • Will allow last number to change
    • drush/drush: "^9.2.1"
      • Will allow last 2 numbers to change
    • drush/drush: "<9.0.0"
    • drush/drush: ">8.9.9"
    • drush/drush: "9.2.*"
    • More ideas

Helpful bits of information

  • Drupal project gives a lot of nice goodies
    • Pre/post scaffold commands
    • Add your own command
      • Needed to update by .htaccess file after scaffold reverts back to what comes from drupal.org
      • Also removes .git dirs from my vendor and contrib modules
"scripts": {
  "post-drupal-scaffold-cmd": [
    "git apply patches/swlaw-htaccess.patch",
    "find docroot -name .git | xargs rm -rf",
    "find vendor -name .git | xargs rm -rf"
  ]
},

Helpful bits of Information

  • Pin your PHP
    • Composer will download the releases that comply with the necessary version of PHP
  • I found composer update fickle to be honest
  • Created my own command
    • Can type composer nuke to get rid of dled deps
    • Followed by composer install
"scripts": {
  "nuke": "rm -rf composer.lock bin/* vendor docroot/core docroot/modules/contrib docroot/profiles"
}

Helpful bits of information

  • Keep track of your own composer.json
    • You may need to add additional patches and contrib modules/libraries here
  • Absolutely track your external composer.json dependencies as well
    • You may run into conflicts
      • You may need to pin down something in your composer.json that the external vendor has not accounted for

Drupal Lightning

By btmash

Drupal Lightning

How an upgrade from Drupal 8.3 to 8.5 took over 20 hours. And became a deep dive into understanding composer.json and all your dependencies

  • 1,055