WordPress 2.5 has been out a few days, what am I waiting for? Actually for my Dreamhost hosted sites, the upgrade is a brainless click with its One Click install/upgrades. I am done.

Well not completely, the whole admin interface is different! It has that new car WordPress.com smell, the old blue is gone, we have pastels, and woah, all the stuff is in a different place. Its just an adjustment phase, like wiping the crud from your eyeglasses. Back up th

This post is not about the virtues of WP2.5 as they ought to unveil themselves through use (time to get serious about tagging though). I am thinking more about the fleet of 4 or 5 WP sites I have at NMC (#6 is in the oven) and the upgrade path for them. WP2.5 has in place upgrades for plugins and at NorthernVoice, Matt hinted that it might someday be a feature for the whole blog.

So for grins, and documentation, my typical steps are listed below.One problem is that an update requires deleting all core files and adding new ones, so users accessing your site while this is in progress, might see all kinds of strange things.

  • Back up the database (on NMC sites, I run a cron script that does this daily, thats different). I use the WordPress Database Backup plugin and store a copy on my server.
  • I already keep a master set of all my wp-content stuff (plugins, themes, etc) on my work machine, so no backup needed.
  • De-activate all plugins except one – Maintenance Mode. This is super handy, as it presents a notice if someone visits your site while you are “in maintenance mode” – they see a static page. Users with admin access can log in and see everything. You can test the new version before opening it up. Just dont forget! (yes, drupal as this built in, and I like it)
  • I delete ALL files from install directory except for wp-config and the wp-content directory. On some sites, I have a lot of other files not related to WordPress, so in those cases I am deleting al of the wp-xxxxx files (except config)
  • Upload new files, go to the upgrade URL, and you are almost home free (dont forget to turn back the setting for Maintenance Mode

But I ran into a situation recently that required another strategy– we were doing upgrades and repairs on our MySQL database, and even in maintenance mode, the site would hang and generate a database connection error of MySQL is offline. I came up with my own strategy for times when perhaps I know MySQL is not available (this may never happen to most readers).

I created a directory in my base directories named offline and put a single index.php file in there that provides a basic message– you can see one at http://sl.nmc.org/offline/.

Next, you need a manual switch. This is done in the main index.php file which is lovingly short:

The first statement just sets a flag, and the second one includes the WordPress engine, and starts it with a database call. So all we need is a way to skip that part, and load our static page. So my modified index.php file has statements that I turn off/turn on by toggling the // prefixes on certain lines. A // before a line treats it as a comment, or a note, and is not execute.

In normal WP mode, where all the databases are working and chugging along, my index.php looks like this- we just run everything through wp-blog-header.php:

And should my database be kaput, sick, or just not available, I can route any blog access (since all URLs to a blog are handled via this basic index.php file) bu adding the comment code to one line, and removing it from the other:

So all accesses to this blog will go to the holding pattern page.

Yeah, its manual and not elegant, but It Works.

And one more note for the drupal-istas- even with drupal’s maintenance mode, if the database is off kilter or off, you will not see your crafted message but a database error message that tells an admin somethings about checking the configuration settings, not what you want users to see.

I skirted this by hacking the /includes/database/mysql.inc file and commented out the typical database connection message around line 102, and write my own:

Comments

  1. Thanks for blazing the trail, Alan. Even with WP, I tend to hew to my philosophy of “never buy a low serial number,” so I’m slow to switch. The last time I did, though, I did get all my blogs onto the same version number, which made hopping between them much easier.

    I’m glad to see the [ advice | warning ] about admin interface changes…

  2. I didn’t even deactivate my plugins (forgot). Just did a full backup and then dragge that 2.5 folder sucker into my Filezilla. Like 2 minutes later I was upgraded Daddyo! Loving the admin area.

Leave a Reply

Your email address will not be published. Required fields are marked *