1

When I run contrib-module patches I download the patch file, put it in the modules folder, navigate to there with the Linux-bash and then do git apply patch patch_file_name.

I never ran a core-patch though and I believe it's a bit different as there isn't necessarily a single module to act upon.

So, is there a one single way to run Drupal core patches and how it should be done without damaging anything? Maybe just put it in the site root folder and run it?

I ask this here so people who write such a question in Google could find this info easily.

3

Drush make is a method to maintain patched releases of contrib and core. It is the only organized, non-custom, method I know of for patch management. The makefile is self-documenting. By "self-documenting", I mean that the makefile contains a list of modules, their versions, and URLs of applied patches.

Create a makefile of an existing Drupal site with:

drush generate-makefile mysite.make

Note, as far as I know drush generate-makefile will not detect applied patches. The example makefile demonstrates how to reference patches in your makefile.

|improve this answer|||||
  • This answer could have more detailing: Is it the only method? Do you always need to create the .mk file yourself?, and what is the meaning of "self-documenting" ? Thx. – JohnDoea Jul 12 '16 at 10:09
  • BTW, as I understand I could also do git apply path, in that same destination... – JohnDoea Jul 12 '16 at 11:02
1

You can use patch command (read here for more). For eg. put the patch file in the folder where the file is stored for which the patch was written, then apply the patch.

patch < file.patch

NOTE: for maintainability purposes, I follow these steps before and after the patch is successfully applied.

  • Make sure there is an issue in Drupal Core regarding the patch. If not then create one and upload the patch.
  • Download the patch from the issue. If you use patch naming guidelines or Dreditor for patch name suggestion, then the patch will also have issue id. Also you can keep track of the issue to check if a better solution is available or the issue is closed(fixed).
  • Make a folder in your Drupal installation inside sites folder or root folder and have a copy of the patch in there. This should be done so that if you update the Drupal Core, then your core changes will be removed and you can re-apply those patches using these copies.
  • Delete the original patch from Drupal installation after the patch is used.
|improve this answer|||||
  • This answer explains how to apply patches but does not answer the question as posed. – cilefen Jul 12 '16 at 3:43
  • I am sure Drush make will work but this answer is also valid for manual patch applying. So, is there a one single way to run Drupal core patches and how it should be done without damaging anything? Patch applying is same for drupal core patches. – Vishal Kumar Jul 12 '16 at 3:57
  • Generally you will need to do: patch -p1 < patch-file-name.patch – rooby Jul 12 '16 at 5:57
  • Worth noting that almost always, patches will be written to be applied from the root of the site, the same as the root of the module for a module patch. Consider core to be one huge module. – rooby Jul 12 '16 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.