Don’t make the same mistake I did this morning when downloading the latest version of WordPress.
This morning WordPress 3.0.4 security update become available. I therefore needed to update a few hundred sites.
Fortunately I have set up our server to use a shared version of WordPress and since this release requires no database changes it is a simple matter of running the update on one test site first to check it is okay and then updating the master copy to update all the other sites.
Step 1: Download WordPress
I downloaded the file latest.zip from http://wordpress.org/download/ using the command
wget http://wordpress.org/download/latest.zip
Step 2: Unzip Files to the New Location
I unzipped the latest.zip file to a folder /wordpress-3.0.4 on our server.
Step 3: Set up the Test Site To Use Latest Version
I set up the test site to get its version of wordpress from the wordpress-3.0.4 folder.
The site behaved properly however it still reported it was running version 3.0.3.
I checked the version file wp-includes/version.php and this had the variable:
$wp_version = '3.0.3';
Surely, WordPress has not forgotten to update this file when the release 3.0.4?
I checked the wordpress 3.0.4 folder and found it was identical to the wordpress-3.0.3 folder. Oops
I then decided to check the zip file. I found I had 2 zip files:
latest.zip (containing WordPress 3.0.3) latest.zip.1 (containing WordPress 3.0.4)
What I had done is unzip the latest.zip file instead of the latest.zip.1 file. Dohh!
The wget command had seen that there was already a latest.zip file in the local folder so had created a new version latest.zip.1 and I had not noticed this.
So the moral of the story is to do one or all of the following:
- Pay more attention
- Have a checklist to follow when doing a WordPress upgrade
- Write a script that performs the download reliably
- Learn how to use the wget command properly
Below is an abbreviated and paraphrased version of the wget manual that explains I should have used “wget -r” if I want to replace (or clobber) an existing file.
Wget Parameters
If a file is downloaded more than once in the same directory, Wget’s behavior depends on a few options, including -nc, -r and -N. In certain cases, the local file will be clobbered, or overwritten, upon repeated download. In other cases it will be preserved.
When running Wget without -N, -nc, or -r, downloading the same file in the same directory will result in the original copy of file being preserved and the second copy being named file.1. If that file is downloaded yet again, the third copy will be named file.2, and so on. This was why I ended with latest.zip.1
When -nc is specified, this behavior is suppressed, and Wget will refuse to download newer copies of file. Therefore, ””no-clobber”” is actually a misnomer in this mode—it’s not clobbering that’s prevented (as the numeric suffixes were already preventing clobbering), but rather the multiple version saving that’s prevented.
When running Wget with -r, but without -N or -nc, re-downloading a file will result in the new copy simply overwriting the old. This is the behavior I wanted
Revised Upgrade Procedure
Anyway, I now have all my client sites running 3.0.4 and have improved my upgrade process
- Remove any zip files from the local folder
- Download latest.zip
- Check downloaded file exists and is of suitable size 3MB
- Unzip file
- Rename wordpress folder to reflect version: mv wordpress ./wordpress-M.m.n – where M is major version, m is minor version and n is the revision number (e.g wordpress-3.0.4)
- Point ‘beta’ folder at the new version
- Log on as admin on the test site that use ‘beta’ version of wordpress
- Run wp-admin/upgrade.php to see if WordPress applies any databases changes
- Check out the pages on this test site which exercises a selected set of around 40 different plugins and ensure they behave correctly – issues tend only to arise with more complicated plugins like membership sites
- Run script to backup all databases
- Point ‘release’ folder (the master copy) at the new version
- Only if database changes are necessary then run script to access wp-admin/upgrade.php on every site
- Run script to backup all databases










