Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/16/2012 02:07:37 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Revisions:

  • Since we do our own revision handling, turn off revisions for the initial call to wp_update_post() in topics and replies.
  • We check if the post type supports revisions, and toggle them off and back on to avoid duplicate revisions from specifically saving it later in the edit process.
  • Fixes #2029.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/replies/functions.php

    r4331 r4426  
    365365 * @uses bbp_has_errors() To get the {@link WP_Error} errors
    366366 * @uses wp_save_post_revision() To save a reply revision
    367  * @uses bbp_update_topic_revision_log() To update the reply revision log
     367 * @uses bbp_update_reply_revision_log() To update the reply revision log
    368368 * @uses wp_update_post() To update the reply
    369369 * @uses bbp_get_reply_topic_id() To get the reply topic id
     
    387387
    388388    // Define local variable(s)
     389    $revisions_removed = false;
    389390    $reply = $reply_id = $reply_author = $topic_id = $forum_id = $anonymous_data = 0;
    390391    $reply_title = $reply_content = $reply_edit_reason = $terms = '';
     
    548549    ) );
    549550
    550     // Insert reply
     551    // Toggle revisions to avoid duplicates
     552    if ( post_type_supports( bbp_get_topic_post_type(), 'revisions' ) ) {
     553        $revisions_removed = true;
     554        remove_post_type_support( bbp_get_topic_post_type(), 'revisions' );
     555    }
     556
     557    // Insert topic
    551558    $reply_id = wp_update_post( $reply_data );
     559
     560    // Toggle revisions back on
     561    if ( true === $revisions_removed ) {
     562        $revisions_removed = true;
     563        add_post_type_support( bbp_get_topic_post_type(), 'revisions' );
     564    }
    552565
    553566    /** Topic Tags ************************************************************/
     
    572585    // Update revision log
    573586    if ( !empty( $_POST['bbp_log_reply_edit'] ) && ( 1 == $_POST['bbp_log_reply_edit'] ) ) {
    574         $revision_id = wp_save_post_revision( $reply_id );
     587        $revision_id = wp_is_post_revision( $reply_id );
    575588        if ( !empty( $revision_id ) ) {
    576589            bbp_update_reply_revision_log( array(
Note: See TracChangeset for help on using the changeset viewer.