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.
By permutations on
How do I apply a patch to Drupal to my personal copy of Drupal? I don't have CVS installed on my server, and I don't have command line access.
I guess what I need is a link to the .patch file syntax so I know what it means and can apply the changes manually (unless there's some other way to do it).
Comments
Apply, then upload
You don't need to patch on the server! Patch a copy locally (you have local commandline access, haven't you?) then upload it to your server.
Via Google: Patch file syntax
missing piece here
Apply locally. Yeah, okay. How? If I'm not going to do manual editing, I need to install some sort of software locally. What software? I don't think CVS runs on Windows, but maybe it does - I'll look. If not, I can install Cygwin and use CVS within that (I'm pretty sure). I've used Cygwin before and it works well. I have a Linux box, but none of my data is on there so it would be easier to use Cygwin.
Patch for Windows
You don't need Cygwin. There are multiple native implementations. Via Google: Patch for Windows.
Be sure to read that page esp. Installation and Usage. Otherwise you may be puzzled by the error messages you'll get (I was).
Good luck!
Both
Cygwin and GnuWin32 will do it for you -- If you are familiar with the command line and with Cygwin, it's a pretty easy job using Cygwin. You don't need to use CVS in Cygwin -- just use the "patch" command.
Cheers,
bonobo
-------
http://www.funnymonkey.com
Tools for Teachers
-------
http://www.funnymonkey.com
you realize you just made
you realize you just made this page the first hit in google for patch file syntax right?
I don't know if this is what you're asking, but
this handbook page could also be helpful. It has instructions on applying a patch in Windows using Cygwin.
http://drupal.org/node/32875
Cheers,
bonobo
-------
http://www.funnymonkey.com
Tools for Teachers
-------
http://www.funnymonkey.com
Thanks for the link and guidance
I didn't see the responses to my question right away. I should have checked back - would have saved me some time. In searching around for a solution I discovered the GNU diffutils, and installed those. It seemed easier than Cygwin - though I've used Cygwin before.
However, I'm getting an error on two of the hunks in the patch, so I'm installing Cygwin now anyway. I'm pretty sure the error is because my version of the file doesn't match the version that was patched (specified in the patch file), but maybe the heuristics in the Cygwin version of the patch utility are better.
Thanks for your help.
The line endings
Could be the end of line encoding. Took me some time, getting increasingly frustrated, doing patches by hand, before I found this:
There's an easier way
I messed about with the patch utilities and so on and none of them worked for the files I was trying to use - I kept getting unexpected end of file or hunk errors, so I finally gave up and decided to have a peek inside the files themselves.
In my case I was trying to patch a module. I opened both the .module file and the .patch file in a text/code viewer on my desktop. In my case it was Dreamweaver code view but I suspect notepad or some HTML viewer would do just as well.
Turns out the syntax of the patch is fairly straightfoward. The lines you want to look at have - or + in front of them. My patch had this for example:
-define('CONTACT_HOURLY_THRESHOLD', 3);
+define('CONTACT_HOURLY_THRESHOLD', 100);
So what I did, after making a backup of the .module file, was take the Find and Replace function to Find, in the .module:
define('CONTACT_HOURLY_THRESHOLD', 3);
and Replace it with
define('CONTACT_HOURLY_THRESHOLD', 100);
I did this with all the plus/minus statements in the patches I had, saved the .module file, uploaded it to the right place on the server, and tried running the module. Bingo - all fixed.
Hope that helps.
Chandra
----
www.whatdoesthatmean.com
Yes, patch files are designed for easy manual patching
Here's one more tip for patching by manual editing: If you are applying a patch that has several changes in the same file, start with the last one and work your way back.
If you start with the first change, then as you add and remove lines the line numbers will change. By starting with the last change you avoid changing the line numbers of previous changes.
Thankyou!
Chandra - Just wanted to drop a line and say thank you! Finally someone put it in simple terms.
Regards,
----
www.ozlady.com
many thanks for explaining
many thanks for explaining that! :D
In Chandra We Trust
In Chandra We Trust
Great thanks!
7 years on and your post is still helping people! Thanks for this straightforward explanation, this is just what I was looking for!
instructions for linux
backup the original filemanager.module file if you like, then copy the patch to the same directory as the original filemanager.module then issue this command:
GNU/Linux PATCH Command
the PATCH command: there is no space between the "p" and the "0" [zero]
See more: http://linux.about.com/od/commands/l/blcmdl1_patch.htm
Works like a bomb...
how to manually apply patch?
I only need to make a few minor changes to a module. The diff file (patch) in question is in unified output format and I am hoping someone can help me read it.
example:
@@ -234,11 +254,18 @@
What do the 11 and the 18 refer too, and how do they relate to -234 and +254?
: )
: )
...
I think -234 , 11 means from the 11th character (from the left) on line 234.
Almost there!
This thread has been great, but I have a patch with something a little different than the previous example. (I'm on Mac OS X, so I'm doing this manually.)
The previous response answered the first pair, which are preceded by the minus. In the patch I'm attempting to apply manually, the second pair is preceeded by a plus.
@@ -119,0 +121,27 @@
+
+ function myCustomCleanup(type, value) {
+ switch (type) {
+ case "get_from_editor":
Does this mean I should remove 119, character 0, to 121, character 27 inclusive, and replace all that with the + lines that follow?
No, you just need to add in
No, you just need to add in each line with a + in front (but remove the plus sign)
Pre-patch, the line number you'd be adding on is 119. Post-patch, the initial line number is 121
What's interesting is apparently you're not using a patch produced in the unified diff format. If it was, you should have 3 lines at the beginning and ending of each section (a section is started by the @@ line). That would make it easier for you to know where the changes should go, by showing you some "landmarks"
What do the 11 and the 18
That's incorrect.
Line 234 is the approx starting line number on the file that you're about to edit. The original count of lines in this section will number 11 lines total.
Line 254 is the approx starting line number after previous changes have been applied to this file. The count of lines in this section after modification will total 18.
For example, if this was the only change to this file, from your patch, then the line number would still start at 234. But apparently 20 new lines have been added earlier in the patching process, which tells you what line number you should be on now.
Thanks for help in applying Bartik IE Gradient Patch
This post was helpful in manually applying the patch for header gradients in IE for the Bartik theme. Thanks!
This helps
Look at this:
http://drupal.org/node/32875
What about Mac OS X ?
What about Mac OS X ?
found this explanation for
found this explanation for using either xcode or terminal:
Applying patches on Mac OS X - http://drupal.org/node/60818
reads like something very straightforward (think all the same I'll do it manually using textwrangler for now)...
Thanx, exactly what I
Thanx, exactly what I needed. I used it successfully indeed.
Don't apply patches manually if your site is on Linux or Mac OSX
Make your life easier by using a shell command. If you don't use ssh, you're missing out. I know very little ssh (wget, cd, ls, mv, rm, patch, tar -zcf/zxf), but these little commands make my life so much easier.
It's as simple as:
patch -b < file_name.patch
Notes
Putting the patch file in the directory of the file you want to patch simplifies the process because you don't have to issue the -p option to the patch command. The -pN option just tells the command where to look for the files, and if you have them in the same directory as the patch file, you can leave this option out.
I like the -b option because it creates a backup of the original file(s) that are modified by the patch command (they will have a .orig extension added). If anything goes wrong on the site, it's easy to restore the files to their original state.
The problem with webhosts
My drupal site webhost allows sftp access but not shell access :( so unless someone knows of a patching application that can work over sftp I will have to do manual patching. I suppose another alternative (which is what I will probably do) is grab a local copy of the site, apply the patch to that, and then overwrite the live site.
-----
what is in a sig?
Thank you!
MikeyLikesIt,
Thank you so much for the clean cut directions. Terminal is pretty cool. Here are slighly more detailed directions for newbies - there are always so many 'thoughtless' steps in most any technological/computer process.
I just:
1) downloaded the whole folder for a module to my Desktop (off of the server where I had it running)
2) created a text file (ending in .patch) using a patch for the respective module
3) placed it in the module's folder
4) opened up Terminal
5) navigated to the folder (using cd)
6) ran your command
7) uploaded the whole folder BACK to it's respective location on the server and overwrote the original folder there
works great!
Thank you!
How to apply a patch to Drupal site modules ?
Hi Memeshift,
Can you guide me on using the Terminal and command line to apply the patch to the module and uploading the patched file.
What do I need to type to apply the patch.
Thanks,
Hanly
adobe air patch tool
I found this earlier...it's an Adobe Air desktop application that allows you to synch your dev modules with your live Drupal site.
http://devzone.zend.com/article/3447-Synchronizing-Drupal-Modules-with-A...
It's just an example script to illustrate the capabilities of adobe air with Drupal, but, I thought it might be cool to have an equivalent to patch Drupal modules.
In other words, the Drupal user just launches the Drupal app, selects the patch(es) and the module(s) he or she wants to patch and the "drupal air" app does all the leg word for them...such as
(a) Admin login
(b) Make an automatic backup of the modules to be patched on the local drive and/or the complete site + database,
(c) apply the patches
(d) display the results (such as any error messages) to screen
(e) offer the option to restore the backed up module files in case something goes awry.
what do you guys think?
Is there no patch software
Is there no patch software with a GUI? I thought the command line thing ended in 1994 with MSDOS.
tortoiseSVN is lifesaver
i am half-geek, i could code, but when i can use ready-to-use GUI instead on shell i am MUCH happier!
tortoiseSVN perfectly does the job:
http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-patch.html
select your patch file, right click, tortoiseSVN>apply patch
now select the folder where the files to be patched are, in the small window with the files list right click>patch all!
voilta!