Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Goal:
Add a "patch" (software fix) to an existing issue, in the Drupal Core project or a contributed module, theme, or distribution.
Skills required:
Detailed steps:
- Set up prerequisites: Log in, Local development site (optional), and Git from Common Prerequisites for Contributors.
- Find an issue with status Active or Needs work in the Drupal core project, or a contributed module, theme, or distribution project that you are familiar with. If the issue already has an issue fork or merge request created, you should make a merge request instead of a patch. Also, if the issue is complex and you think many people might want to collaborate on the fix, you should use a merge request. If either of those is the case, follow the steps in the Create a merge request task instead of this task write-up.
- Read the issue, making sure you understand the Problem and the Proposed Resolution sections of the issue summary, or equivalent information. If the issue summary is incomplete or outdated, see the Write an issue summary task.
- Add a comment to the issue saying that you are creating a patch for the issue.
- Use Git to clone or update the repository for the project, and check out the version you are creating the patch for. Then make a local branch in your Git repository to work on the patch. See the "Prepare the local repository" section of Making a patch for details.
- If you are updating an existing patch, apply the existing patch to your working branch. Be sure to use
git apply --index
to stage the changes added in the patch, including new files. Then, commit the previous patch to your local working branch. - Edit the code base with the changes necessary to resolve the issue, following the idea in the Proposed resolution section of the summary. Make sure to follow the Drupal project coding standards, interface text standards, and documentation standards. If you are working in the Drupal core project, the page Figuring out what Drupal core code to patch may be helpful. If the issue needs an automated test to be written, see the task writeup on automated tests.
- If you are working in the Drupal core project, check locally that the patch or merge request passes the pre-commit checks, following the steps in running core development checks.
- Make a patch that contains the changes you made to the code base.
- If the issue already had a patch that you are updating, make an interdiff between the existing patch and your new patch.
- Attach the patch (and interdiff) to the issue. Change the issue status to Needs review. Add a comment that explains the changes you made, and modify the issue summary as necessary. Click Save on the issue, to save your files, comment, and issue field changes.
- Review your own work. Ensure that the patch contains the changes you intended, and that any changes in patch size or the diffstat (files updated, lines added, and lines removed) are related to changes you made.