Skip to:
Content

bbPress.org

Changeset 5775


Ignore:
Timestamp:
05/21/2015 09:57:32 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Inserts: When inserting a forum/topic/reply, immediately update the new object so hierarchy is refreshed.

This commit addresses the last active post ID being incorrect after inserting topics and replies to a forum, and fixes a failing test (in BBP_Tests_Core_Update::test_bbp_create_initial_content).

See #2805.

Location:
trunk/src/includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/update.php

    r5770 r5775  
    207207            'post_content' => $r['topic_content']
    208208        ),
    209         array( 'forum_id'  => $forum_id )
     209        array(
     210            'forum_id'     => $forum_id
     211        )
    210212    );
    211213
  • trunk/src/includes/forums/functions.php

    r5770 r5775  
    4343
    4444    // Insert forum
    45     $forum_id   = wp_insert_post( $forum_data );
     45    $forum_id = wp_insert_post( $forum_data );
    4646
    4747    // Bail if no forum was added
     
    6868        update_post_meta( $forum_id, '_bbp_' . $meta_key, $meta_value );
    6969    }
     70
     71    // Update the forum and hierarchy
     72    bbp_update_forum( array(
     73        'forum_id' => $forum_id,
     74    ) );
    7075
    7176    // Return new forum ID
  • trunk/src/includes/replies/functions.php

    r5770 r5775  
    4343
    4444    // Insert reply
    45     $reply_id   = wp_insert_post( $reply_data );
     45    $reply_id = wp_insert_post( $reply_data );
    4646
    4747    // Bail if no reply was added
     
    5555        'forum_id'  => 0,
    5656        'topic_id'  => 0,
     57        'reply_to'  => 0
    5758    ), 'insert_reply_meta' );
    5859
     
    6263    }
    6364
    64     // Update the topic
    65     $topic_id = bbp_get_reply_topic_id( $reply_id );
    66     if ( !empty( $topic_id ) ) {
    67         bbp_update_topic( $topic_id );
    68     }
     65    // Update the reply and hierarchy
     66    bbp_update_reply( $reply_id, $reply_meta['topic_id'], $reply_meta['forum_id'], array(), $reply_data['post_author'], false, $reply_meta['reply_to'] );
    6967
    7068    // Return new reply ID
  • trunk/src/includes/topics/functions.php

    r5770 r5775  
    4343
    4444    // Insert topic
    45     $topic_id   = wp_insert_post( $topic_data );
     45    $topic_id = wp_insert_post( $topic_data );
    4646
    4747    // Bail if no topic was added
     
    6868    }
    6969
    70     // Update the forum
    71     $forum_id = bbp_get_topic_forum_id( $topic_id );
    72     if ( ! empty( $forum_id ) ) {
    73         bbp_update_forum( array( 'forum_id' => $forum_id ) );
    74     }
     70    // Update the topic and hierarchy
     71    bbp_update_topic( $topic_id, $topic_meta['forum_id'], array(), $topic_data['author_id'], false );
    7572
    7673    // Return new topic ID
Note: See TracChangeset for help on using the changeset viewer.