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/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.