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)
- 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.
- If you are trying to get the latest dev version of the module, it's easiest to do that with git:
- 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)
- go to the 'Version control' tab of the module you want to apply the patch to
- copy the 'git clone' command for the latest branch
- paste that command into your git command prompt
- cd into the newly created git repo
- proceed with step #2 below
- Here's me with my latest feeds module I want to test a patch for:
- Next, save the patch you want to apply inside that module folder
- cd into the module directory (feeds for me)
>> cd feeds/
- apply the patch (change file.patch to be the name of your specific patch)
>> patch –p1 < file.patch
- 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)
- 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 drupal.org.