Easiest Way to Create a Patch for Submission to WordPress Core?

I’ve submitted a few patches for WordPress core on Trac (one of which has been used) but every time I think about doing it I cringe because my setup for doing so is incredibly tedious.

Can someone please detail out the steps needed to submit a patch for core, and then the best way to streamline the process so it’s not so tedious? I work Mac OS X and PhpStorm currently but I’m thinking a shell script might be easiest? Or maybe a PHP Script that does all the rote work?

Read More

One of the issues is I don’t fully understand what I need to be starting with. Do I start with trunk? Do I have to download a new copy and add to/edit that copy with my code every time I want to create a patch?

Again, while I have done it working with SVN and patching is really outside my current skillset and I want to change that. Hoping you WordPress patching experts can come to my rescue. Thanks in advance.

UPDATE:

After @hakre’s answer I figure I should add more to the question:

  • Can I create patches from older version or must I use trunk?
  • If I’m working on a project using the released version (3.0.1) can I modify it and create a patch for core or do I have to download and set up a pristine and new copy of trunk and newly make my modifications there?
  • Can I do with shell scripts so I can encode the login into the script and just run the script to recreate everything I need and/or to create the patch?
  • And what are the pitfalls?

All of these questions seem to be assumed by those who know how WordPress’s SVN works and as such are always glossed over in any discussion.

Related posts

Leave a Reply

3 comments

  1. The easiest way to create a patch is described here:

    http://wordpress.org/download/svn/

    Can I create patches from older
    version or must I use trunk?

    You should create the patch against the same version you want it applied against.

    In other words, don’t expect a patch created against WP 3.0.1 to apply cleanly on WP 3.1-alpha.

    If I’m working on a project using the released version (3.0.1) can I modify it and create a patch for core or do I have to download and set up a pristine and new copy of trunk and newly make my modifications there?

    You don’t have to set up a new installation for each new patch. You can just use svn revert to get back to a pristine copy.

    Also, the database doesn’t have to be clean each time. Actually, it’s better if you have some modifications, to simulate a live environment.

  2. Eclipse PDT + Subclipse + X

    I’m using Eclipse that has SVN Integration. I think PHP Storm does so as well. I go into one of my trunk projects which are basically a checkout from WordPress svn repository.

    Then I edit the files I need to edit. Eclipse shows which are modified, I right-click a directory, select Team->Create Patch and I get offered all changed files I can select for the diff. Then I can choose between copying to clipboard or saving to disk. I save all patches I create with the ticket number into a directory I have on my harddisk.

    Then I go into the Browser and upload the patch.

    I could also do this with a MyLyn Trac integration, that is even more comfortable, but you need XML-RPC right in trac so you need a trac admin to contact. It works pretty well but I do not have it configured in every project and use that mainly when I make ticket rundowns.

    So really, checkout Eclipse if you like. It’s huge and slow so you need either a big computer. On small ones I made good experiences with Fedora Linux. Eclipse runs well on it. I know you’re a PHP Storm fan but, well, I really like my Eclipse and it comes with a lot of extensions that really rock. Even for PHP :). But PHP Storm should basically do the checkout / patch stuff as well.

    WordPress Eclipse 1×1

    Ah and I have a tool in my OS that saves all directories I’ve used. So I can save the patches and upload the files fast because they are always from the same directory which I have in the recent list then.

    Integration Example: PHP Code Sniffer, Eclipse and WordPress