Easy way to patch a file to a module?

It might happen to come across a patch file to solve an error or add a new possibility to one of the modules, all of which are comfortably delineated in the file that the problem is solved with the patch, but how to use the patch. Everyone was happy and they comment that their problem was solved with this patch- written underneath that file. But how can the patches are used? so simple! There is easy way to patch a file to a module. Follow up!

Open the Patch file with a text editor (Notepad ++ is simple and suitable).
Tip: I advise you to try patch on a website to test and then upload to your live site.
When you open the file, you will see these codes:

Easy way to  patch a file to a module?

Easy way to patch a file to a module?

diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc
index fb0664a..193c475 100644
--- a/modules/system/system.admin.inc
+++ b/modules/system/system.admin.inc

 

It tells you which file you should change, which is file ‘system.admin.inc’ you see at first line.

 

Easy way to  patch a file to a module?

 

@@ -911,12 +911,6 @@
  * Array sorting callback; sorts modules or themes by their name.
  */
function system_sort_themes($a, $b) {
-  if ($a->is_default) {
-    return -1;
-  }
-  if ($b->is_default) {
-    return 1;
-  }
+ // added a comment
   return strcasecmp($a->info['name'], $b->info['name']);
}

 

911.12 are the number of lines and line number of the code that has not yet undergone any changes! (Line number 911).

911.6 is still the number of lines and line number, but here are 6 lines less (that is, after applying the patch, 6 lines will be less).

What should you do?

First: The lines that are written with “-” should be deleted

Second: We need to add the lines that are written with “+” (add them without “+”)

Third: The lines that have no symptoms are unaltered. Those mean to help you get a better understanding of where you are (that is, usually write a few lines of code before and after where it should change. so we have our wrong percentage Lower when the Patch Apply).

That’s it; you learned an simple and easy way to patch a file to a module in Drupal.

Easy way to patch a file to a module?
4.6 (92.73%) 11 vote[s]

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *