Try a WordPress Trac patch

Last Revised: October 2, 2021

You may not be a developer, but you know how to program and like to test if some patches of wordpress code can work, so it is more than reasonable that you collaborate in the Community by checking if the patches that have been created work and fulfill their mission.

To do these tests you will need a WordPress installation with Varying Vagrant Vagrants or you can create a virtual machine with Subversion. In any case you will have at your disposal the system prepared to be able to apply and reverse them.

NOTE: This example is based on the VPS with SVN manual on this site.

Find tickets to try

The first thing will be to find tickets that have a patch pending testing. To do this we can do a search in the Trac of tickets with [has-patch].

Download the patch

The first thing we will do is go to the folder where we have the installation of our WordPress.

cd /webs/wordpress-svn/

In order not to mess up the configurations, the first time we will create the folder for the changes.

mkdir /webs/wordpress-svn/patch/

When we have it, we will enter it and download the patch we want to try.

cd /webs/wordpress-svn/patch/

To know the URL that we have to download, we will visit a ticket of the Trac and in the area of attached files we will look at the URL that has the file. Both .diff and . patch files can be downloaded.

Apply the patch

Now that we have downloaded the file, we have to apply it to the current configuration of the WordPress development. To do this we will return to the root folder of the configuration and there we will execute the patch.

cd /webs/wordpress-svn/
patch -p 0 < patch/47912.diff

This will return a message that will tell us what files or changes have occurred. It should look something like the following:

user@wordpress-svn:/webs/wordpress-svn# patch -p 0 < patch/47912.diff
patching file src/wp-includes/formatting.php
Hunk #1 succeeded at 2273 (offset 3 lines).
patching file tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php

The normal thing would be to test the error before applying the patch, apply it, and then run the same thing again to verify that the system works.

If you try the change, whether it works or not, it is highly recommended to comment on it in the comments of the Trac ticket.

IMPORTANT: If the patch does not work, it is necessary to return to the Trac ticket and add a keyword that says [needs-refresh] so that the person or persons responsible apply an update based on the latest available code. Sometimes there is very old code thought for obsolete versions and you have to update it to the most current versions.

Remove all applied changes

If we’ve made changes and applied multiple patches, we may think it’s a good idea to roll back the changes for future testing. To do this we will execute the command that will do it to us.

cd /webs/wordpress-svn/
svn revert . -R && svn update

About this document

This document is regulated by the EUPL v1.2 license, published in WP SysAdmin and created by Javier Casares. Please, if you use this content in your website, your presentation or any material you distribute, remember to mention this site or its author, and having to put the material you create under EUPL license.