I've read the "Diff vs. Patch" thread, but I guess I'm missing something. Perhaps that's because it's about creating a patch, not installing a patch. Could someone please explain:

  • Does a patch patch the SQL tables?
  • Is "patch" a MySQL command or just a descriptive suffix?
  • If this affects the MySQL database, is there a way to install it using phpMyAdmin?
  • Does a patch patch the module file?
  • If so, how? Is it a php program? Do I ftp it and point to it with a browser?
  • (What is it I'm not asking that I should be asking?)

I've searched the posts and cannot find anything that speaks to my dim wits. Any clues would be much appreciated!

FWIW, I'm using remote shared hosting (Debian), and, coming from older media, I am comfortable with (x)html and css but still very much learning PHP and know nada re MySQL.

Thanks!

Comments

Steven’s picture

A patch file is a text file containing the differences between two files, that's all. You can open them in any editor to see. Patches are not directly related to Drupal, PHP or MySQL.

You apply a patch using the 'patch' utility available on most Unices.

You can find a Windows port of GNU patch here:
http://unxutils.sourceforge.net/

--
If you have a problem, please search before posting a question.

loloyd’s picture

I am now having the same problem as media girl. And I think this native Win32 GNU ports of Linux directives is really the way to go, and it's complete(?) too. I have seen a lot of standalone Windows implementations to just grep or find for example, but never as this grouped into one.

Anyways, I've tried/attempted patching by hand and it was hell. The patch file was intuitive, though, and I was actually beginning to consider making a Windows patch program myself to make things easier until my mental *lightbulb* came on to search for this issue here in Drupal (Googling it only produced more requirements, or should I say, Win ports with another whole slew of requirements themselves; the cycle was getting annoying). Thank you very much, you have saved my day.

EDIT: Hey! You know what? I just realized something. Since these are all (welll, almost all) GPL anyway, why don't module developers just release or INCLUDE the patched version of their other required API or modules in their own module releases? This way, we don't have to contend with patches, which will make the better majority of our lives easier! But a bit extra work for the developer, though. Hehehe... well, maybe not. Since he/she won't have to deal with detailing the patch file itself! Yeah, that's it! I recommend that developers/contributors include the patched modules in their releases too! :-D

sprite’s picture

Steven:

Thank you very ever so much for providing the link above to windows ports of the GNU unix utilities.

For days I have read threads in vain and google searched with red eyes trying to find just such tools.

{{{ steven }}}

p.s. - if only the patches provided recently for various modules actually patched their originals successfully :(

[ no reflection on you steven :) ]

spritefully yours

orthoducks’s picture

It referred me to the following place, where I was able to get the utility:

http://sourceforge.net/projects/unxutils

orthoducks’s picture

I got the Windows patch utility, and it runs. Unfortunately, it doesn't do anything.

The utility's help display says that the format is

> patch [OPTION]... [ORIGFILE [PATCHFILE]]

When I did that, I got the command line back with no messages. No new file appeared in the directory and the original file was not changed.

One post in this thread said that the command syntax is

> patch example.module < example.module.patch

I tried that too, and got the same results.

Then I realized that I had been misspelling the source file's name. It didn't even tell me.

I tried again with the correct filename, and... guess what... still got nothing.

My patch looks easy to apply by hand, but I hope someone can help me figure out why the utility isn't working, or recommend another one.

grohk’s picture

1) no, patch is a unix program that works with files...but the syntax is much like the MySQL command for adding a table for a module.

2) Generically speaking a "patch" is a type of file, which the patch program can use to add things to another file automatically.

3) not really a database thing.

4) a patch as applied to a module and adds or deletes lines of code.

5) patch is a standard unix utility and is most likely already installed on your Debian host. you can patch modules on your machine and upload them, or you can patch them on your host machine itself by using SSH (Secure Shell).

If you are hosting on a Debian machine this should work, but backup your files first...I will use the spam patch for the comment module as an example. Upload the patch file into the directory of the module you wish to patch. Then shell into your account you will need to go to the directory that the original file and patch file are located.

patch comment.module < comment.module.patch

This patch is included with the Spam module in the optional folder and adds functionality to the core comments module.

Code Orange: Drink Your Juice

---
Code0range: Drink Your Juice

media girl’s picture

Thank you. I think I get it now.

--
mediagirl.org

the_other_mac’s picture

Thanks CodeOrange, that was just what I needed.

To other Windows users (like myself) - your PC is Windows, but you are using a hosting service that probably isn't. Most cPanel webservers are Linux, so unless you specifically paid extra for Windows hosting, you actually have limited access to a Linux computer...

Next step, you'll need "shell access". Most host companies don't offer this by default but will turn it on for free, if you ask. Don't expect much help with using it though.

Next, you need "terminal software". That's typically a black textbox, looks a bit like a DOS box if you know what that it. I suggest downloading "Putty", which is free and widely available. There's loads of options, which you can ignore. In the opening screen of Putty, you need to enter your site name www.example.com, select "SSH", and click Open. Then you'll be prompted for your cPanel username and password. If it replies with something like "-jailshell-2.05b$", you've succeeded. You have "command line access" to a unix computer.

That "-jailshell-2.05b$" is a prompt. It's waiting for your instructions. Try typing "ls" (that's a lowercase L) and press enter. You'll get a list of words which you might recognise from your File Manager. You're in the same place, so to speak, but with the 'real' view instead of the 'Matrix' view :-) . I recommend you open cPanel's File Manager (or your FTP program if you use one), and move around in both of them simultaneously for a while. How do you move around by typing? Type "cd" followed by a space and a folder name that you can see above; e.g. "cd public_html". Did you move? Type "ls" again...

Play around for a bit. You'll need to know that "cd .." moves you back UP a level, and you can jump multiple levels by separating the folder names with / . If you didn't realise before, the public_html folder is a special one, because it's the top level of your website.

Ready to apply a patch? Navigate to the folder that has the main module file and patch file (which you upload using File Manager or FTP). Then, type the single line following Code Orange's example above. That's it.

jagmeister’s picture

Thanks very much, you contribution helped ALOT!

ellastelter’s picture

This was my first time to apply a patch, and these are the only instructions I found that got me there. Thanks!

jagmeister’s picture

Thank you very very much

Lam0r’s picture

I was hoping to find my answer in this topic but can someone please outline a simple tutorial on how to patch using windows? I have downloaded all the required tools but didnt get anywhere so far. Someone kindly post a quick guide to patch preferably using GNUpatch.

Bèr Kessels’s picture

There is avery usefull section in patch handbook.

[Ber | Drupal Services webschuur.com]

James@lovingit.co.uk’s picture

I didn't find that page anything but confusing, for those of us who just want to use a patch it would be nice to have simple instructions. I thought drupal was supposed to be easy to use?

Dublin Drupaller’s picture

I have been using drupal for a while and have still not worked out an efficient and failsafe way of applying a patch.

Usually, if a patch is more than just a few lines long, I ignore it...it took me a few hours once to go through that patch handbook page and was back at square one. So if it's a short few lines that need changing..I can manage that manually by opening the files side by side.

A seasoned programmer working on linux or unix will probably get it straight away...but not the average user methinks.

For what it's worth..it's pity the patched files aren't posted as well as the patch...as there are oodles of windows based programmes that will compare two files for you. I still haven't found any that will apply a patch.

Drupal is easy to use..and unfortunately, patches appear easy for seasoned developers and has become a standard way of distributing changes to modules, not relative newbie thickos like me.

please post back up here if you find anything useful that helps newbies apply patches.

Dub

DUBLIN DRUPALLER

___________________________________________________
A drupal user by chance and a dubliner by sheer luck.
Using Drupal to help build Artist & Band web communities.

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

likoma’s picture

For what it's worth..it's pity the patched files aren't posted as well as the patch

I'm in the boat with the others who don't have Shell access, no SSL, I've now tried CYGWIN, managed to actually get beyond "No such directory ... " to the point where it actually tried to patch a module only to then give more more HUNK errors than success.

My request: as Dublin Drupaller requests, would it be possible to post a patched module together with the patch to save those who can't patch hours of trying? Maybe it's not possible, maybe a patched module can't be uploaded and then downloaded or something, then that's fine. But after struggling with patching this entire Friday evening (I have a 2-year old, I'm home anyway on Friday nights ... ), I'm just hoping this is possible.

Thanks and best regards,

- Bradley

likoma’s picture

Allow custom sort order for nodes in taxonomies http://drupal.org/node/10839. I would like just the events to be sorted by date ASCending while the other nodes are DESCending.

Maybe there's another way? I'm coming from WordPress and there I can force a category template by creating a new file (e.g. category-3.php) and index.php will look for a category-X.php file for a category and if it doesn't find anything, it'll use index.php). Is there something like that for Drupal?

I should probably post this elsewhere now that I'm so far off topic.

Thanks,

- Bradley

stevem’s picture

How're yeh Dub?

Here's how I solved this particular problem. (No shell, no ssh, no help from hosting provider without paying extra).

1. Read the instructions and download the tar file from here:
http://www.psychogenic.com/en/products/PHPsh.php

2. I'm going through a proxy, so I checked my proxied IP address and used that. If you don't have access to your own proxy, you can check your proxied IP address by going to http://www.whatismyip.com/

I put phpsh.php in the root directory, and used the interface to cd into 'modules'. Then I ran the patch command from the INSTALL.TXT file that came with the module. Simple as that.

The only glitch I can forsee is that your web-hosting provider might not have the patch utility in your $PATH variable, in which case you could try '/sbin/patch' or '/usr/sbin/patch'.

Or try running 'find / -name patch -type f > wherethefisit.txt' and then ftp down the wherethefisit.txt file and see if it was found anywhere.

Hope that helps.

Cheers

Ex-dub

-- "It was only a PIG!" --

rasor’s picture

Thanks, SteveM

kennywalker’s picture

Check out Beyond Compare and you'll find a Windows program that compares and gives you a ton of options for how to impliment the changes. You can get it bundled with Multi-Edit and you'll then have a great text editor too. ;)

sepeck’s picture

diff and patch are not Drupal. diff and patch are generic common *nix developer tools that have several working ports to windows via cygwin or other win32 binaries. The problem is that no one can figure out how to make it easier. The command line tool is as easy as the instruction provided. It may be that you are missing some of the necessary background information/training to make undertanding easy.

I suggest you download one of the tools provided (http://www.tortoisecvs.org/ looks nice) and set up a source tree on your local system (http://drupal.org/node/635 - I know these instructions for Tortoise work as I used them last week to setup on a new system) and play with it for a bit. Read their manual. It will get you where you need to go.

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

Taran’s picture

But, generally speaking, it's good practice to have the patched file available to users. Sure, patch and diff ain't Drupal tools, but devs are supposed to keep users from having to become devs.

Patch practices are a pain to most users, and most people just want to download something and work. This will be a continuous battle, as users will always say, "why not just have the patched file?". There's a logic to that which is not able to be argued effectively, because the user request will not change.

;-)

KnowProSE.com
OpenDepth.com

keve’s picture

grefft’s picture

I am running a mac with OS X 10.3. Unfortunately, I'm not really proficient with using UNIX programs on my system and I did not install the developer's tools. What is the best way to apply a patch on OS X? I downloaded a program called Diff'n Patch but it gave me errors that I couldn't decypher which had something to do with line endings.

Any help would be greatly appreciated.

Steven’s picture

For info on how to apply a patch, see the diff and patch section in the handbook. The commands there can be run from the command line.

The problem with line endings has to do with the different ways of storing line endings in a text file. There are 3 standards: Unix, DOS and Mac. There are various utilities to convert between them (look for things like "dos2unix").

--
If you have a problem, please search before posting a question.

elife’s picture

if you get it sorted, please let me know! I'm using OSX 10.4.5

DigitalWheelie’s picture

I still see no clear way of applying patches, and now I'm on OSX 10.5.8.

Eeeep!

VMII’s picture

http://drupal.org/patch/apply

located at the bottom are mac os instructions. I can't verifiy them I don't use a mac.

tostinni’s picture

Patch can sometimes come with some SQL update, in this case they modify updates.inc file, then you can run update.php to update your database.

Most of the time, patch didn't have to modify your database and generally it happens when an new version is rolled out.

hansrossel’s picture

Hi,

It's the first time I'm confronted with this patch command and it looks very complex, and after a lot of reading I still don't get it working. Its certainly no click and run this thing!

I'm trying to install the i18n patches. The hosting company gives me access via cpanel to cronjobs, but not to the command line of Unix (or whatsoever).

So I thought that using the patch command as a cron job (and just let the cron run once) would install the patch.

I used as cron command:
patch -p0 -u < http://www.example.com/modules/i18n/patches/i18n_taxonomy_module.patch

and let it run once

Unfortunately I get the message
/bin/sh: line 1: http://www.example.com/modules/i18n/patches/i18n_taxonomy_module.patch: No such
file or directory

What am I doing wrong??
Why is this cron not doing its job?

Thanks for helping me out,

Hans

mogens’s picture

PATCH doesn't know about URLs - it only knows about files. So you have to download the file first, then apply the patch using your local copy of the file.

i.e.
wget http://www.example.com/modules/i18n/patches/i18n_taxonomy_module.patch > i18n_tax_module.patch
patch -p0 -u < i18n_tax_module.patch

WGET is a command to get a web page. We use the redirect command > to pipe the result into a file. We then use the temporary file we created with WGET to run the patch command.

Also, you don't need CRON to do this. CRON is for running a command at regular intervals. PATCH is something you do once, and then you're done.

-- christian

-- christian

mbelos’s picture

I agree, patch does not fetch files over HTTP, but you can do this in a single line. For example:

wget -qO- <URL> | patch -p0 -u

So for instance I wanted to apply the patch at: http://drupal.org/files/issues/1015946-10.patch, so I ran this command in linux:

wget -qO- http://drupal.org/files/issues/1015946-10.patch | patch -p0 -u

BTW I'm aware that the post I'm replying to is very old, but this might still be useful or relevant for people to use these commands :)

---
Funke Labs
W: http://www.funkelabs.com.au
Ultimo, NSW, Australia

VMII’s picture

If you would take the time to read this thread, and search drupal.org for "apply pacthes" you would be presented with enough documentation to understand how this is done.

dpknauss’s picture

enough said.

hansrossel’s picture

You are replying to a comment of 2005... There is (fortunately) a lot more info now on drupal.org than back in 2005 and its indeed easy with www.cygwin.com. Quite funny to read my struggle with patching back then.

rob6111’s picture

start>run>cmd

cd ...

patch -p0 < patchfile.patch

kobocms’s picture

Why are we patching rather than just making the new files available?

I just don't understand how it is easier to patch instead of re-downloading the amended file. Can someone explain the benefits to me? I guess there are file size issues, but come on - we are talking a difference of kilobytes so does that matter?

Here we all are looking for programs to make patches, apply patches and many are failing.

VMII’s picture

patches are supplied so that developers/maintainers can see exactly what is being changed without having to read the entire file. when the patch is approved it would get rolled into a release.

arbitrairly allowing new files to be created without the code being looked over first is how bugs and security exploits can get missed in inspection. It is only necessary to see what is being changed and how.

kobocms’s picture

Ok, I keep forgetting that there are teams of developers and maintainers working on the same file. I am used to our office where we are all assigned to the one file - no one else touches it. Thank you for the clarification.

drecute’s picture

If you want to apply a patch, Netbeans CVS plugin does this for you easily. You dont even need any knowledge of what a CVS is. Just open the file you want to apply a patch to (i.e the original file), then on the menu, click versioning -> apply diff patch. Provide the .patch file and click patch. Simply, that's all.

Download from here http://www.netbeans.org/downloads/index.html.

Sun Certified Professional
http://sinati.com

mattwmc’s picture

I am going to throw in my two cents because I am trying to "install" a patch now.

The patch should read:

Find this line:

etc etc etc

and replace with this

a b c

Not

--- content.module 26 Jan 2009 14:45:34 -0000 1.301.2.96
+++ content.module 14 Feb 2009 01:15:48 -0000
@@ -420,16 +420,8 @@
     // Special case for 'view' op, we want to adjust weights of non-cck fields
     // even if there are no actual fields for this type.
     if ($op == 'view') {
-      foreach ($type['extra'] as $key => $value) {
-        // Some core 'fields' use a different key in node forms and in 'view'
-        // render arrays.
-        if (isset($value['view']) && isset($node->content[$value['view']])) {
-          $node->content[$value['view']]['#weight'] = $value['weight'];
-        }
-        elseif (
blah blah blah

You gotta be kidding me with this, lol.

VMII’s picture

erm, except that patch files aren't necessarily meant to be read by humans. You must be patching manually :shiver:

mattwmc’s picture

lol! Yeah, I have been.

I see a couple posts above about the Netbeans plugin.

Next time, I'll try that.

VMII’s picture

actually there are multiple programs that allow one to to use .patch files -- cygwin for windows for example. There are others mentioned in http://drupal.org/patch/apply

ahmedhanyfawzy’s picture

I wrote small blog post describing how to install the patch using the linux path utility ; linked here.

loopy1492’s picture

Is there any way I can run a patch with a command on my template.php file?

Or maybe there's a patching module I could download?

loopy1492’s picture

I did not find the article on applying patches manually yesterday.

http://drupal.org/node/534548