Skip to content

Update Drupal Core#

Background#

  • On Drupal 7, Pantheon developers would update Drupal core on all their sites. Pantheon developers did the hard work, resolved conflicts, then users could click a button to apply the update Pantheon installed.

  • On Drupal 8, we used Composer and an empty upstream because Pantheon didn't have an upstream for Composer-managed sites. We also used Github and a build process. For those reasons, we have to do the update and apply patches ourselves.

  • On Drupal 9 and 10, 11, we're still using GitHub and a build process, so we're still updating and applying patches ourselves.

  • In composer.json, we have "drupal/core-recommended": "9.2.0 as 8.9.0" which is needed for all contributed modules that have not officially been updated to D9 and were just updated via patches. (Note as of Feb 2024: Not sure if this part is still true)

Step-by-Step#

  1. Checkout develop:
    git checkout develop
  2. Pull code:
    git pull origin develop
  3. Create a new feature branch for the ticket:
    git flow feature start NPLD8-xxx
  4. Import config:
    ddev drush cim OR lando drush cim
  5. Run the update command:
    composer update drupal/core-recommended --with-all-dependencies 1. In composer.json, we have "drupal/core": "9.2.0 as 8.9.0" which is needed for all contributed modules that have not officially been updated to D9 and were just updated via patches. 1. If you update it to 9.2.1 and then rerun the command composer update drupal/core "drupal/core-*" --with-all-dependencies" it should work.`
  6. If you get a memory size error, update the memory limit for this session. The COMPOSER_MEMORY_LIMIT environment variable, with value set to -1, adds more memory to the current Terminal session. It will be used by all the composer commands you use in that session. Get more info.
    export COMPOSER_MEMORY_LIMIT=-1
  7. When the update command is done, run the database update command. This goes through all the updates, looks at any schema changes happening in the database, and lets you know what they all are.
    ddev drush updb OR lando drush updb
  8. Type yes to run the updates.
  9. Clear cache:
    ddev drush cr OR lando drush cr
  10. Export configuration to make sure there were no changes we need to commit. You don't have to do every time, but if there's a problem this is a good thing to check.
    ddev drush cex OR lando drush cex
  11. Check status.
    git status -s
  12. If there were changes, commit those changes.
  13. Test on your local environment.
  14. Push to multidev.
  15. Test on the multidev.
  16. Prior to merging into master and pushing code to Pantheon, take a database snapshot on Live in case updates don’t work. That allows you to roll back quickly.

See Code Review in GitHub for next steps.