WordPress Plugin: Versioning


After losing a significant amount of writing work earlier tonight due to some WordPress bug (or maybe user error; who knows), I decided that all of my posts should be versioned.

I save my work constantly, so it’s dumb that accidentally saving a truncated post should wipe out hours and hours of work.

So I searched around on the internet and found the WordPress Versioning Plugin, which I downloaded and immediately installed.

Unfortunately, the plugin didn’t work.

So I’ve been tinkering around with it for a few hours, and I’ve fixed it.

You can download the new plugin module here:

http://benjismith.net/files/wp-versioning.tar.gz

Here are the changes I made:

Bugs Fixed:

  • The PHP was coded with the assumption that REGISTER_GLOBALS would be set to TRUE. That’s a dumb assumption, so I changed the code to use the $HTTP_GET_VARS global array.
  • For any querystring parameters, I’m now using mysql_escape_chars() to prevent SQL injection attacks.

Better UI:

  • More aesthetically-pleasing table layout.
  • Betterly-named column headers
  • Snapshots are now displayed in a format that preserves both the html markup and the newlines in the post, making it a little easier to choose which snapshot to rollback to.

New Features:

  • It’s now possible to delete snapshots, to keep from clogging up the database with a bunch of unnecessary snapshots

I’ve decided to call the new version 19.2 (which, you’ve got to admit, is a significant upgrade from the original author’s 1.0 Beta version).

At some point, I may implement a better visual diff, so that sequential snapshots are easier to differentiate. For now, I’m not too concerned. I’m just happy that my posts will no longer suffer from mistaken deletions, either due to bugs in the WordPress software itself or because of one of those pesky ‘Problem Between Chair And Keyboard’ bugs.

If you have any questions, let me know.

socially-bookmark this article:
Add 'WordPress Plugin: Versioning' to Del.icio.us Add 'WordPress Plugin: Versioning' to digg Add 'WordPress Plugin: Versioning' to FURL Add 'WordPress Plugin: Versioning' to blinklist Add 'WordPress Plugin: Versioning' to My-Tuts Add 'WordPress Plugin: Versioning' to reddit Add 'WordPress Plugin: Versioning' to Feed Me Links! Add 'WordPress Plugin: Versioning' to Technorati Add 'WordPress Plugin: Versioning' to Socializer 

15 Responses to “WordPress Plugin: Versioning”

  1. Scott Says:

    I just wanted to say thanks for updating this plugin. I just installed it and tested it. You should post this to the plugin repository over at the wordpress page.

    If you decide to revisit this plugin and work on it some more I did notice that when you delete a post and then go in and delete all revisions of the post it still leaves a reference to it in the revisioning management page. It doesn’t affect its functionality though so I’m happy :)

  2. Jen Says:

    I have to agree–it works perfectly in 2.0.4 (with the exception of the minor bug Scott reported).

    I can’t thank you enough for updating this plugin!

  3. benji Says:

    No problemo. I’m glad it worked out well for you guys.

  4. Mike Says:

    Thanks a lot, this will surely prove to be extremely useful!

    I’ve installed the plugin and found the admin part works perfectly. No sweat. Excuse my ignorance here, but is there any easy way I could go about displaying the different versions of a post to visitors?

  5. benji Says:

    Mike says:
    “is there any easy way I could go about displaying the different versions of a post to visitors?”

    Not really. The way the versioning works is that, every time you make an edit, it saves a copy to the versioning table. Then, to revert, it copies an older version back into the live database.

    But the blog pages visible to the user are always rendered from WordPress’s core tables. If you wanted to display data from the versioning table to the user, you’d have to hack into the core WordPress functionality.

  6. Mike Says:

    I see.

    Presumably though I could run a standalone SQL query to gather the data (not the most elegant option) in a template file? I’ll pop my programming hat on and see what I come up with.

    Thanks for your response, the plugin is working beautifully.

    Mike

  7. dirkhaim Says:

    hi,
    I am getting this error on wp2.0.10 when clicking ‘Choose Rollback Snapshot’ in the admin area:
    Could not successfully run query (SELECT * FROM wp_versions WHERE post_ID = ORDER BY post_version DESC ) from DB: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ORDER BY post_version DESC’ at line 1

    Also, how can I diff two versions?

    Thanks.

    ———
    http://www.tinyways.com

  8. Jeff Says:

    Hi!

    I tried using this plugin for the first time, and got this error the first time I clicked “Choose Rollback Snapshot”:

    Could not successfully run query (SELECT * FROM wp_versions WHERE post_ID = ORDER BY post_version DESC ) from DB: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ORDER BY post_version DESC’ at line 1

    It looks like the Post ID is getting stripped out for some reason…

    Thoughts?

    Jeff

  9. Jeff Says:

    Hmm… Replacing “$HTTP_GET_VARS” with “$_GET” fixes that problem, but then I get “no records found.” I just checked the database, and there’s nothing in the “wp_versions” table :(

  10. Jeff Says:

    Hey, me again…

    Looks like the problems had to do with the big “INSERT” query in “versioning_19.2.php” … It tries to insert the value “Array” for the “post_category” field, and an empty string into the “menu_order” field. These both expect integers. I hardcoded these with zeros (because I HAD to get it working NOW). This seems to work, but obviously will not correctly save the category and menu order info - not that I really care for my purposes - namely disaster mitigation :)

Leave a Reply

You must be logged in to post a comment.





purchase accutane online buy accutane cialis prescription order cialis without prescription buy cheap soma online generic synthroid accutane pills cheapest generic viagra lowest price acomplia propecia without a prescription cheap cialis from usa tablet viagra certified viagra buy cialis without prescription levitra discount cheap viagra in usa lowest price clomid order cheap viagra acomplia sale cialis rx order lasix viagra bangkok cheapest cialis prices online viagra cialis vendors buy soma online clomid sale buy cheap lasix online viagra free sample cialis in us viagra canada buy cialis from us soma no prescription cialis pill buy soma buy viagra in us soma for sale where to order viagra viagra buy drug viagra buy cialis in uk synthroid cheap cheap generic cialis buy cheap synthroid online discount propecia acomplia pharmacy order lasix online buy cialis in us soma without a prescription cheap propecia tablets cheap viagra tablets find cheap cialis cialis sales clomid online stores clomid prices compare viagra prices online cheap cialis no rx lasix without prescription cialis pills cialis purchase online pharmacy viagra buy cheap accutane find viagra on internet cialis order buy viagra cheap cheapest levitra cost of viagra cheap lasix tablets order cialis on internet order viagra in canada zithromax no prescription lowest price zithromax cheapest viagra prices