You are here

How to apply/test a module patch in Drupal

It's not going to be long, even if you're not a pro Drupal web admin/developer, that you will run into a situation when you want to apply a module patch (from the module's issue queue) to your site.  Imagine that you're using a module and you notice that it either has a bug or you wish it had some particular extra feature.  You look in the module's issue queue and notice that there's already an issue for that problem - and guess what - there's already a patch written to fix it!  Now here you are - unable to test the patch and unable to use it on your site and just move on because applying patches is not something you've ever done before.

Fear not!  It's actually not as bad as it seems at first glance: 

(But don't do this on a production site!  I'm definitely assuming you're going to be patch-testing on a local site copy)

  1. Download the version of the module that the patch should be applied to (if it's not already what's in your modules/ directory).  This really should be the latest dev version of the module, but go ahead and check the text in the message that includes the patch and/or what the 'version' on the issue was set to when the patch was made.  The reason this is important is because the patch may not apply properly if it was made for a different version of the module code than the one you currently have.  Make a copy of your module folder in case applying the patch messes anything up and you need to go back.
    1. If you are trying to get the latest dev version of the module, it's easiest to do that with git:
    2. open up Git and cd into your /modules directory
      (again, remember to rename the current module you're trying to fix to 'module_old' or something like that so this does not overwrite it if you need to go back)
    3. go to the 'Version control' tab of the module you want to apply the patch to
    4. copy the 'git clone' command for the latest branch
    5. paste that command into your git command prompt
    6. cd into the newly created git repo
    7. proceed with step #2 below
    8. Here's me with my latest feeds module I want to test a patch for:

  2. Next, save the patch you want to apply inside that module folder

  3. cd into the module directory (feeds for me)
    >> cd feeds/
  4. apply the patch (change file.patch to be the name of your specific patch)
    >> patch –p1 < file.patch
  5. Make sure there are no error messages in the output.  It will let you know which files have been added or modified
    (Another good way to check for more specific changes would be to use the 'git status' command if you're using git for this)

  6. Now go to your site and test that the bug you were trying to fix or the new feature you wanted to add works properly!  Whether it worked or not, go ahead and add your comments to the issue queue and help the community out.  It's always helpful to get those patches moving along!


More information on applying patches can be found on


Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.