Drupal 8 User Guide: 13.6. Updating a Module

Drupal 8 User Guide: 13.6. Updating a Module


Updating a Module
with Joe Shindelar This tutorial covers how to update
a contributed module by using the administrative interface and running the Database update scripts or by using Drush. By the end of this tutorial, you’ll know how to update
a contributed module and run the Database update scripts. Before doing this,
you should make sure that you have a contributed module
that’s been installed and there’s an update available for it. You have a development
version of your site that you can test this on first, that you’ve created a full site backup
before proceeding on the live site. If you want to use the user interface, the core Update Manager module
must be installed. And finally, if you want to use Drush, Drush must be installed. See the written version of this tutorial for links to each
of these prerequisites. Note that if you’re using Composer
to manage your site’s dependencies, you’ll want to follow the tutorial on
using Composer to update the code and then come back here for
instructions on running the Database updates script. Before you start, you’ll want to check for any module-specific
update instructions. This is typically necessary
while updating modules that involve the usage
of third-party libraries, but it’s also always a good idea
to read and understand all module-specific requirements
before proceeding with an update. To find the instructions,
check the module’s project page. So, for the Google Analytics module, I can check the project page. I might read the existing documentation. One good place to look
is by clicking on the release, which you’re going to update to, which will take you
to the project’s Release notes. Here you can browse
through the Release notes and see if there are any
special instructions about updating. And finally, you can also
download the files that you’re going to be using
during the update, and look for an update.txt,
a readme.txt, or an install.txt file in that code that might contain
additional instructions. Modules can be updated using
either the administrative interface or with Drush. If you’re updating a custom module
rather than a contributed module, or if you see a message saying, “Installing modules and themes
requires FTP access to your server,” or if the following steps
do not work for some reason to obtain the new module files, follow the steps in the manual
installation tutorial then continue here with the step
for running Database updates. To use the administrative interface
to update a contributed module, first, put your site
into maintenance mode. Click on Configuration. Then, under Development,
click on Maintenance mode and check the box, Put your site
into maintenance mode, and click Save configuration. Once your site is in maintenance mode, in the Manage administrative menu, navigate to Reports, and then Available updates, and then Update. This page shows you a list
of all the modules that need updates. Find and check the box for each
module you want to update in the list. Then click Download these updates. On the next screen, click Continue. Once that’s complete, you’ll need to
run the Database updates script. If you obtained
the new module files manually, or used Composer to download, start with this step and reach
the Database updates page by typing in, /update.php
in your browser. Click on Run database updates. From the updates page,
click Continue. If there are any updates to be run, you’ll have the opportunity
to review them and then execute them at this time. If there aren’t any, you’ll be taken to the final step,
which is this page. From here, you can return to
the administrative section of your site by clicking on administration pages. After that’s complete, you can
put your site back into online mode or take it out of maintenance mode by unchecking
Put site into maintenance mode and clicking Save configuration. Finally, it’s a good idea
to clear the cache after performing updates,
just for good measure. Alternatively, you can use Drush
to update a module. First, find the project name
for the module you wish to update. One easy way to do that is by looking at the URL
for the module’s project page. The last segment
of the module’s project page URL, for example, in this case,
google_analytics is the name of the module
I’d like to update. Then, in my terminal,
I can run the Drush command, drush pm-update and the name of the project
or multiple projects, separated by a space,
that I would like to update. Run the command and then
follow the instructions on the screen. The drush pm-update command will take care of downloading
the new code and running any Database
update scripts, if required. In this tutorial we learned
how to update a contributed module using the user interface provided by
the Upgrade Manager module and alternatively, using
the drush pm-update command.

Leave a Reply

Your email address will not be published. Required fields are marked *