Applying patches in Drupal

Administrator's picture

patches in drupal, drupal london, social networking, web design london

Sometimes there may be issues with a module that have been fixed by users but not yet committed to the latest release. These community-supplied patches can be found in the 'Issues' section of a module page.

To commit these patches, download the .patch file from the relevant issue page. It's worth opening this file in a text editor program and checking the code - it's best if you understand the change that's being made. Upload this file to your webspace - it'll be easier to update/locate if you place it in the same directory as the module you're updating.

The next step is to log in to your server via SSH, using Putty or a similar program. Use the cd command to navigate to the module directory. Once there, input the following:

patch -b < filename.patch

This will update the .module file with the patch changes. The -b option creates a backup file of the original module, in the format module_name.module.orig.

To reverse a patch, use the following command:

patch -R < filename.patch

Resources:
http://drupal.org/patch/apply
http://drupal.org/patch/reverse

64 people like this