How To Apply A Patch to a Drupal Module

Categories:

Sometimes, particularly when using a custom Drupal module, you may need to a apply what's called a 'patch'. A patch is simply a text file with a set of instructions saying which lines of code within a module need to be changed, added or deleted to get the module to function better or more accurately.

Oft times, patches are applied to make sure a module works correctly across Drupal distributions (versions).

Below are instructions for applying a patch. Once you get the hang of it, the whole process can take less than 2 minutes.

Instructions For Applying a Patch to a Drupal Module:

  1. Download the whole folder for a module to your Desktop (off of the server where you have it running)
  2. Create a text file (ending in .patch) using a patch for the respective module (you might have been brought to a webpage with lines of code to be copied and pasted from the pageinto the text file)
  3. Save it and place it in the module's folder
  4. Open up *Terminal
  5. Navigate to the folder (using cd)
  6. Run this command: patch -b < file_name.patch
  7. Upload the whole folder BACK to it's respective location on the server (and overwrite the original folder there)

*Note, this is a command line program for Mac used in conjunction with TextEdit (for editing the text file). Windows equivalents would be MS-DOS and NotePad.