WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post revisions (16 posts)

  1. Ingoal
    Member
    Posted 5 years ago #

    Hi there, I just upgraded all my blogs from 2.5.1 to 2.6. Right after the upgrade I noticed something strange. I've got a custom plugin running that generates a shorturl (using zz.gd) and posts a tweet containing a short line + posttitle + shorturl to twitter (using the API). All good there.

    BUT, there's always a but now isn't there, each new post results in more than one tweet. Why? Because of the post-revisions. So, can someone tell me how I can easily check the status of a post at POST-time, so that only the "published" ones are used by the script and the revisions ('inherited') are ignore?

    Any help would be appreciated.

  2. Ingoal
    Member
    Posted 5 years ago #

    Anyone?

  3. Ingoal
    Member
    Posted 5 years ago #

    Come on ppl...what's up with this support forum...everytime I post something on here there's a big blank...are my problems really that strange? Sigh...

  4. microkid
    Member
    Posted 5 years ago #

    I am having the same problem with a plugin of mine, must be others out there too. Fixing it right now.

    The problem is that your plugin probably saves the posts ID somewhere. However, after a revision the ID is changed, that is, a new post row is created and the old one (with the old ID) is set to post_type = 'revision'.

  5. hotkee
    Member
    Posted 5 years ago #

    Why not search and find out on the forum?

    http://wordpress.org/support/topic/189050?replies=4

    You can turn off revisions as suggested through the above article.

  6. Ingoal
    Member
    Posted 5 years ago #

    microkid: yeah, that sounds about right...need to check post-id handling again...

    hotkee: Because turning it off is bs...plain and simple, I can't tell ppl "turn off revisions, because else my plugin won't work"...apart from the fact that it can have side-effects to disable it (see http://wordpress.org/support/topic/175886?replies=20) ;-)

  7. microkid
    Member
    Posted 5 years ago #

    No that's definitely not an option. It has to be plug and play.

    I'm looking into it right now, trying to find a hook that will let us update our plugin data when the post is saved. I'll let you know here when I find the solutions, because it's out there ;)

  8. microkid
    Member
    Posted 5 years ago #

    I was wrong, the ID is not changed, but when saving the post the save_post hook is called twice: once when saving the post before editing as a revision, once for saving the current version. Seems like that's our problem right there.

    I have found a solution by using this in whatever function you call with the save_post hook:

    function plugin_function_save_postdata($post_id)
    {
     if(wp_is_post_revision($post_id) || wp_is_post_autosave($post_id))
     {
       return $post_id;
     }
     else
     {
      // your process that uses $post_id
     }
    }

    This way, the process is not run for the revision.

  9. Ingoal
    Member
    Posted 5 years ago #

    Microkid: That should do it! Thanks a lot...I'll keep you posted on my progress in fixing my plugin...just watch twitter ;-)

  10. Keilya
    Member
    Posted 5 years ago #

    Hey microkid, thanks for directing me here but I'm a little lost as to how I can implement your fix? >_<

    Like which file to edit...?

  11. microkid
    Member
    Posted 5 years ago #

    I thought you were having truoble with a plugin, since you were talking about problems with shifting ID's.

    Me and Ingoal both have plugins that take the ID of a post when it's saved through the save_post hook. With the revision system, this hook is called not only for the actual post, but also for the revision. So we had double entries show up. The fix mentioned above is to be placed in the function of your plugin that is called by save_post.

    So is it a plugin that's causing you trouble?

  12. Keilya
    Member
    Posted 5 years ago #

    Oh nope lol. Nothing to do with plugins. I just want my Post IDs to stop jumping everytime I edit a post. It seems that even with some of the "anti-post-revisions" plugins and methods installed, the IDs still jump anyway.

  13. microkid
    Member
    Posted 5 years ago #

    Ah :) Well, don't be bothered by ID's - they're just references. You should use pretty permalinks anyway :)

  14. Keilya
    Member
    Posted 5 years ago #

    Haha...I happened to be the 1% who's not a fan of pretty permalinks. ^^'' Most of my post titles are in Japanese anyway...that's why. >_< Anyhow! I found a plugin that solved my ID problem! Just plugging it here for anyone who needs it. http://exper.3drecursions.com/2008/07/25/disable-revisions-and-autosave-plugin/

  15. fzilbermann
    Member
    Posted 5 years ago #

    Just dropping by to say thanks, a big thank. I was having the same issue after upgrading to 2.6 with a plugin of mine and was wondering what was going wrong. Just fixed it with you advices and it's working great. N°1.

  16. martiegras
    Member
    Posted 5 years ago #

    I restarted blogging once again and migrated everything today(wp 2.7.1) and I wanted to say that I agree with fantasycrusader. I also like my posts ID to go in chronological order. :)

    Many thanks

Topic Closed

This topic has been closed to new replies.

About this Topic