Updating Your Sites Code

Once you've learned about the availability of updated code, you have to actually install those updates. This process continues to get better but is still cited as one of the most difficult parts of maintaining a Drupal site. You can make this process easier through a variety of techniques, though some of them can be difficult to learn.

Several practices in building your site will help you when you have to update the site:

Use a test site. Creating a separate test site and doing the upgrade on that site will make the real update much easier.

Choose modules and module versions from a site where you are confident that the maintainer will provide stable updates. One signal that a maintainer will provide stable updates is the use of drupal.org's Official Release system. Beyond that you often must just read the project page and release notes for the module to understand the site's commitment.

■ Try not to modify the code (commonly called hacking core), but if you do, be sure you contribute the patch back to the community. Drupal is based on a modular and easily overridden system, which makes it easy to change things without having to edit code. If you edit code directly and don't merge your change into the code on cvs.drupal.org, you are simply creating pain for yourself in the future when you update and lose all the changes you made.

Beyond that, you simply must get the updated code and install it on the server. There are many different techniques for doing this, but following are steps for two valuable methods. The standard documentation for updates is available in every installation in UPGRADE.txt.

Manage Drupal via CVS Checkout

CVS is a revision-control system used by the Drupal project for Drupal core and all of the contributed code for the project. It's possible to use the command-line tool to easily create, update, and verify your Drupal installation. First, use this command to get a copy of the code to create an installation:

cvs -d:pserver:anonymous:[email protected]:/cvs/drupal \ co -r DRUPAL-6 -d path/to/webroot/ drupal


This example code is split across two lines using the \ character, which should be interpreted properly by your shell. In general, though, the \ is unnecessary, and this command should be entered on a single line.

This command will download the latest copy of Drupal core from the DRUPAL-6 branch. There are several benefits to this technique, such as the ease of updating Drupal when a new version comes out. You can choose between updating to the latest version on the DRUPAL-6 branch or taking the more reliable route of updating to a specific version of core, such as 6.4 with the version tag drupal-6--4

cd path/to/webroot cvs up -r DRUPAL-6--4

By updating this way you rely on the revision-control system to merge together the changes from drupal.org with any changes you may have made locally. While hacking core is generally not recommended, it is occasionally necessary, and cvs up makes it easier to manage. There is also a simple command to see if your site has been changed:

cd diff -up

This handy command creates a diff of all of the changes that you have made. A diff is a comparison of your local copy and the corresponding files on the server, which can be used to identify changes. These changes can be output into a patch file and then shared with other users. Patch files form the basis of improvements to Drupal and are used in the Drupal issue queue. If you make a change to your installation that is generally useful for other sites, you should add that patch file to the Drupal core issue queue at http://drupal.org/project/issues/drupal. If your changes are included into core, then you no longer need to worry about them when you upgrade.

These commands and practices also apply to Drupal's contributed modules and themes, though the repository location, paths, and branch names are slightly different. You can find more information about using CVS at


Manage Drupal with drush

The drush module aims to provide useful commands for Drupal (dru) to power users who often work on the command-line shell (sh). To use drush, you need command-line access to your server and a command-line-enabled version of PHP. drush provides one very handy command to update modules installed on your site:

drush -l d6.example.com pm update

This command will update any of your modules if there are new versions of the module available on drupal.org. To use drush you must enable Update Status and several additional drush modules, such as the drush package manager and one of the helpers for the package manager such as wget support. While drush has many more features that are worth exploring, this module update feature is very handy for updating a site with a large number of modules. You still need to run update.php manually and to configure and test your site based on the updated modules, but it automates a lot of the tedious work.

The major benefit of these approaches is how they can reduce the busy work of finding the module page, finding the link to the tar file, downloading it, unpacking the tar file, and placing it into your Drupal installation. The easier that this process can be, the sooner you are likely to do it. The sooner you do it, the safer the site.

Was this article helpful?

0 0

Post a comment