Simply Static v1.3 Retrospective

The more I work on Simply Static the more I realize just how little I know about WordPress plugins. Last week I learned that when your plugin is getting upgraded via those handy links they give you to upgrade plugins that your plugin gets disabled, all of the files are overwritten, and then your plugin is re-enabled. You might think that the scary part is that your files get overwritten, but no. It’s that your plugin gets disabled. When your plugin gets disabled, it doesn’t get any of WordPress’ handy notifications for things like: hey, we’re upgrading some plugins right now. Maybe yours!

No, you don’t get to hear that. When your plugin is disabled, it’s like it’s in stasis.

So that means, for instance, if you wanted your plugin to add a new database table when someone installed v1.3.0 (hypothetically speaking of course), that your plugin has no way to know that it was upgraded unless you’re checking for being upgraded all the time.

Another thing I ran into is that MySQL doesn’t like having hyphens in table names. Normally this wouldn’t be an issue, except that I was prepending my plugin slug to the table name so that it would be unique. My plugin slug was ‘simply-static’. So, with the release of v1.3.0, I changed the plugin slug to ‘simply_static’. Go underscores!

That worked fine until it didn’t.

My plugin slug was also used as the key to store all of the settings for the plugin. Changing the slug meant that I’d need to migrate all of the settings from the old key to the new key. No problem, I thought. I’ll do the migration when I’m checking if my plugin is being upgraded.

You can imagine how well that went.

Since the plugin wasn’t properly checking for upgrades, none of the settings got transferred over, and worse yet there weren’t any default settings either, so the plugin got into a super weird state until you deactivated and reactivated it.

I feel like I should’ve caught these issues in testing, and I did test upgrading the plugin, except that it turns out that since I didn’t know how WordPress was actually upgrading plugins that I wasn’t testing it in the way I should have.

All of the above happened to coincide with me getting sick and with the wordpress.org repo having some issues of it’s own. So that meant that my plugin was completely unusable for the better part of a week for any unfortunate soul that happened to upgrade.

As far as lessons learned, I learned that there is definitely some lackluster WordPress documentation on how to handle plugin upgrades. I also learned that I need a test plan. Even aside from the upgrading debacle, there was an issue where URLs weren’t being replaced. A single click on any link on my test site would’ve exposed that issue.

Onward and upward, I guess.