How to contribute a patch to drupal.org

Lets say you have found a bug in someone else's contributed module. It happens! You could raise an issue in the issue queue for that module, or you could fix it yourself and contribute the fix back to the community. You are not always going to be able to fix it yourself, but if you can, you should, as this will help everyone, not just the module maintainer.

Raise an issue

Create an issue on drupal.org. You will need the issue number, which is the node ID of the issue.

The issue ID is the node ID

If you are attaching the patch to a comment on the issue, you will also need the comment ID.

The comment ID on an issue

Create the patch file

There are two main ways that you can use to create the patch file. The easiest and most straight forward is if you have the module under source control, like Git or SVN, as follows.

Git or SVN

  1. Make the changes to the module
  2. Run git status and you will see the module file has changed.
    1. git status
  3. Create the patch with this command:
    1. git diff > [description]-[issue-number]-[comment-number].patch

You can do the same thing with SVN.

Diff command

If you do not have the file under version control, you can use the diff command to create the patch file.

  1. Make the changes to the module
  2. Save with a different file name, so you have the original file and new file
  3. Create the patch with this command:
    1. diff original.module new.module > [description]-[issue-number]-[comment-number].patch

Contribute back

Make a comment on the issue and attach the patch file. Change the status to "needs review". Now the module maintainer is not only aware of the bug, but also has been given a solution. Even if your solution is not perfect, it is still a great help.


Conquer Drupal 8 Module Development

Don't struggle to conquer Drupal 8 module development. Action packed lessons where you will work along building your own real world modules.

20% launch discount available now!

Find out more


Add new comment