Apply patches in Windows


Some functionalism, customizations or bug fixes can be added by applying a patch to or tweaking a module yourself.

Steps to apply a patch (in Windows):
  • Use Cygwin. During installation, from the Devel category choose cvs and patchutils. This means click on the circular icon next to it. Downloading takes quit a bit of time. Be patient.
  • Put the patch file in the same directory as the module it should be applied to. Don't work directly in a live site but on your local computer first. Personally I use the directory that opens when I open CygWin. Changing directory is awkward (see next step). I drag and drop the relevant module files and the patch file in this folder (c:\cygwin\home\user). Open the patch file first in an editor to see at the top what files will be affected by the patch (can be more than one). After patching I copy the files back to the module folder. Leaving a copy in the CygWin folder enables you to track all the patches you have applied.
  • Open Cygwin. You start in the c:\cygwin\home\user directory by default. If you don't use this folder as recommended in the previous step, go to the concerning module directory by typing after the $ prompt cd .. to go back one directory (in this case c:\, don't forget the space between cd and ..). You can also go to another drive (e.g. cd f:). From there you move down always one directory at the time. Type ls to list the content of the current directory.Type cd directory name to go to the next one. If there are spaces in the directory name put double quotes around it (e.g. cd "documents and settings").
    Examples of the cd command.
  •  After you reach the desired directory (check with ls) type the command patch < nameofpatchfile.patch. Don't worry, the file to be patched will be recognized automatically.
  • If everything went well you should see something like this:
    acer@acer-92342aa634 /cygdrive/f/drupal/simplenews
    $ patch < simplenews.367488.patch
    patching file simplenews.module
    Hunk #1 succeeded at 2230 (offset 7 lines).
Document your applied patches and tweaks. In case you upgrade a module to a new version, you have to repeat your previous actions. Always test case first.

Related Drupal pages:
drupal.org/patch/apply

Patches I applied:
  • To make HTML work with Simple News (HTMLmail).
  • To correct the "From:" in HTMLmail.
  • To increase decimals in CCK numbers module.
  • FCK editor to make Page Break for teaser and Universal Keyboard for arabic.
  • Views Live Filter. Ability to choice views/displays http://drupal.org/node/600358 and Double throbber http://drupal.org/node/538298#comment-2297730
  • IMCE file browser to show more thumbnails http://drupal.org/node/291470#comment-1148331
  • Language support on node import. http://drupal.org/node/267555#comment-2043540
  • The Feedback module has some visibilit issues in Webkit browser. http://drupal.org/node/730582#comment-3254772