# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: \includes\topics
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: functions.php
--- functions.php Base (BASE)
+++ functions.php Locally Modified (Based On LOCAL)
@@ -954,6 +954,9 @@
 	$old_forum_id = bbp_get_forum_id( $old_forum_id );
 	$new_forum_id = bbp_get_forum_id( $new_forum_id );
 
+	// Update topic forum's ID
+	bbp_update_topic_forum_id( $topic_id, $new_forum_id );
+
 	/** Stickies **************************************************************/
 
 	// Get forum stickies
@@ -964,9 +967,9 @@
 
 		// Define local variables
 		$updated_stickies = array();
-
+                
 		// Loop through stickies of forum
-		foreach ( $old_stickies as $sticky_topic_id ) {
+		foreach ( (array) $old_stickies as $sticky_topic_id ) {
 
 			// Add non-matches to the updated array
 			if ( $topic_id != $sticky_topic_id ) {
@@ -974,17 +977,20 @@
 			}
 		}
 
-		// No more stickies so delete the beta
-		if ( empty( $updated_stickies ) ) {
-			delete_post_meta ( $old_forum_id, '_bbp_sticky_topics' );
+                if ( $updated_stickies != $old_stickies ) {
+                 
+                        // No more stickies so delete the beta
+                        if ( empty( $updated_stickies ) ) {
+                                delete_post_meta ( $old_forum_id, '_bbp_sticky_topics' );
 
-		// Still stickies so update the meta
-		} else {
-			update_post_meta( $old_forum_id, '_bbp_sticky_topics', $updated_stickies );
-		}
-
-		// Topic was sticky, so restick in new forum
-		bbp_stick_topic( $topic_id );
+                        // Still stickies so update the meta
+                        } else {
+                                update_post_meta( $old_forum_id, '_bbp_sticky_topics', $updated_stickies );
+                        }
+                        
+                        // Topic was sticky, so restick in new forum
+                        bbp_stick_topic( $topic_id );
+                }
 	}
 
 	/** Topic Replies *********************************************************/
@@ -996,17 +1002,14 @@
 	foreach ( $replies as $reply_id )
 		bbp_update_reply_forum_id( $reply_id, $new_forum_id );
 
-	// Forum topic meta
-	bbp_update_topic_forum_id( $topic_id, $new_forum_id );
-
 	/** Old forum_id **********************************************************/
 
 	// Get topic ancestors
-	$ancestors = array_values( array_unique( array_merge( array( $old_forum_id ), (array) get_post_ancestors( $old_forum_id ) ) ) );
+	$old_forum_ancestors = array_values( array_unique( array_merge( array( $old_forum_id ), (array) get_post_ancestors( $old_forum_id ) ) ) );
 
 	// Loop through ancestors
-	if ( !empty( $ancestors ) ) {
-		foreach ( $ancestors as $ancestor ) {
+	if ( !empty( $old_forum_ancestors ) ) {
+		foreach ( $old_forum_ancestors as $ancestor ) {
 
 			// If ancestor is a forum, update counts
 			if ( bbp_is_forum( $ancestor ) ) {
@@ -1022,14 +1025,17 @@
 	/** New forum_id **********************************************************/
 
 	// Make sure we're not walking twice
-	if ( !in_array( $new_forum_id, $ancestors ) ) {
+	if ( !in_array( $new_forum_id, $old_forum_ancestors ) ) {
 
 		// Get topic ancestors
-		$ancestors = array_values( array_unique( array_merge( array( $new_forum_id ), (array) get_post_ancestors( $new_forum_id ) ) ) );
+		$new_forum_ancestors = array_values( array_unique( array_merge( array( $new_forum_id ), (array) get_post_ancestors( $new_forum_id ) ) ) );
+                
+                // Make sure we're not walking twice
+                $new_forum_ancestors = array_diff( $new_forum_ancestors, $old_forum_ancestors );
 
 		// Loop through ancestors
-		if ( !empty( $ancestors ) ) {
-			foreach ( $ancestors as $ancestor ) {
+		if ( !empty( $new_forum_ancestors ) ) {
+			foreach ( $new_forum_ancestors as $ancestor ) {
 
 				// If ancestor is a forum, update counts
 				if ( bbp_is_forum( $ancestor ) ) {
