Skip to:
Content

bbPress.org

Changeset 4426


Ignore:
Timestamp:
11/16/2012 02:07:37 AM (8 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.
Location:
trunk/includes
Files:
2 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(
  • trunk/includes/topics/functions.php

    r4362 r4426  
    434434
    435435    // Define local variable(s)
     436    $revisions_removed = false;
    436437    $topic = $topic_id = $topic_author = $forum_id = $anonymous_data = 0;
    437438    $topic_title = $topic_content = $topic_edit_reason = '';
     
    614615    ) );
    615616
     617    // Toggle revisions to avoid duplicates
     618    if ( post_type_supports( bbp_get_topic_post_type(), 'revisions' ) ) {
     619        $revisions_removed = true;
     620        remove_post_type_support( bbp_get_topic_post_type(), 'revisions' );
     621    }
     622
    616623    // Insert topic
    617624    $topic_id = wp_update_post( $topic_data );
     625
     626    // Toggle revisions back on
     627    if ( true === $revisions_removed ) {
     628        $revisions_removed = true;
     629        add_post_type_support( bbp_get_topic_post_type(), 'revisions' );
     630    }
    618631
    619632    /** Stickies **************************************************************/
     
    649662
    650663    // Update revision log
    651     if ( !empty( $_POST['bbp_log_topic_edit'] ) && ( 1 == $_POST['bbp_log_topic_edit'] ) && ( $revision_id = wp_save_post_revision( $topic_id ) ) ) {
    652         bbp_update_topic_revision_log( array(
    653             'topic_id'    => $topic_id,
    654             'revision_id' => $revision_id,
    655             'author_id'   => bbp_get_current_user_id(),
    656             'reason'      => $topic_edit_reason
    657         ) );
     664    if ( !empty( $_POST['bbp_log_topic_edit'] ) && ( 1 == $_POST['bbp_log_topic_edit'] ) )  {
     665        $revision_id = wp_save_post_revision( $topic_id );
     666        if ( ! empty( $revision_id ) ) {
     667            bbp_update_topic_revision_log( array(
     668                'topic_id'    => $topic_id,
     669                'revision_id' => $revision_id,
     670                'author_id'   => bbp_get_current_user_id(),
     671                'reason'      => $topic_edit_reason
     672            ) );
     673        }
    658674    }
    659675
Note: See TracChangeset for help on using the changeset viewer.