<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [2826] branches/1.2:
Fixing errors in single WP setups with blog post recording by removing all no longer used blog and comment recording functions to the back compat plugin
.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>2826</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-03-10 12:03:43 +0000 (Wed, 10 Mar 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fixing errors in single WP setups with blog post recording by removing all no longer used blog and comment recording functions to the back compat plugin.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches12bpblogsbpblogsclassesphp">branches/1.2/bp-blogs/bp-blogs-classes.php</a></li>
<li><a href="#branches12bpblogsphp">branches/1.2/bp-blogs.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches12bpblogsbpblogsclassesphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-blogs/bp-blogs-classes.php (2825 => 2826)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-blogs/bp-blogs-classes.php        2010-03-10 11:12:52 UTC (rev 2825)
+++ branches/1.2/bp-blogs/bp-blogs-classes.php        2010-03-10 12:03:43 UTC (rev 2826)
</span><span class="lines">@@ -278,17 +278,9 @@
</span><span class="cx">                 if ( empty( $blog_ids ) )
</span><span class="cx">                         return $paged_blogs;
</span><span class="cx">
</span><del>-                /* Fetch lastest post for each blog. */
-                $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.blog_id IN ( {$blog_ids} ) GROUP BY p.blog_id ORDER BY p.date_created DESC" ) );
</del><ins>+                for ( $i = 0; $i < count( $paged_blogs ); $i++ )
+                        $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $paged_blogs[$i]->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' AND id != 1 ORDER BY id DESC LIMIT 1" );
</ins><span class="cx">
</span><del>-                for ( $i = 0; $i < count( $paged_blogs ); $i++ ) {
-                        foreach ( (array)$post_ids as $post ) {
-                                if ( $post->blog_id == $paged_blogs[$i]->blog_id ) {
-                                        $paged_blogs[$i]->latest_post = $wpdb->get_row( "SELECT post_title, guid FROM {$wpdb->base_prefix}" . $post->blog_id . "_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY id DESC LIMIT 1" );
-                                }
-                        }
-                }
-
</del><span class="cx">                 /* Fetch the blog description for each blog (as it may be empty we can't fetch it in the main query). */
</span><span class="cx">                 $blog_descs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, meta_value as description FROM {$bp->blogs->table_name_blogmeta} WHERE meta_key = 'description' AND blog_id IN ( {$blog_ids} )" ) );
</span><span class="cx">
</span><span class="lines">@@ -315,398 +307,4 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-/* DEPRECATED - Post DB recording is scheduled for removal. Please use the activity stream to fetch a user's posts. */
-Class BP_Blogs_Post {
-        var $id;
-        var $user_id;
-        var $blog_id;
-        var $post_id;
-        var $date_created;
-
-        function bp_blogs_post( $id = null, $blog_id = null, $post_id = null ) {
-                global $bp, $wpdb;
-
-                if ( $id || ( !$id && $blog_id && $post_id ) ) {
-                        $this->id = $id;
-                        $this->blog_id = $blog_id;
-                        $this->post_id = $post_id;
-                        $this->populate();
-                }
-        }
-
-        function populate() {
-                global $wpdb, $bp;
-
-                if ( $this->id )
-                        $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE id = %d", $this->id ) );
-                else
-                        $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $this->blog_id, $this->post_id ) );
-
-                $this->id = $post->id;
-                $this->user_id = $post->user_id;
-                $this->blog_id = $post->blog_id;
-                $this->post_id = $post->post_id;
-                $this->date_created = $post->date_created;
-        }
-
-        function save() {
-                global $wpdb, $bp;
-
-                $this->post_id = apply_filters( 'bp_blogs_post_id_before_save', $this->post_id, $this->id );
-                $this->blog_id = apply_filters( 'bp_blogs_post_blog_id_before_save', $this->blog_id, $this->id );
-                $this->user_id = apply_filters( 'bp_blogs_post_user_id_before_save', $this->user_id, $this->id );
-                $this->date_created = apply_filters( 'bp_blogs_post_date_created_before_save', $this->date_created, $this->id );
-
-                do_action( 'bp_blogs_post_before_save', $this );
-
-                if ( $this->id ) {
-                        // Update
-                        $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_posts} SET post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
-                } else {
-                        // Save
-                        $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_posts} ( post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, FROM_UNIXTIME(%d) )", $this->post_id, $this->blog_id, $this->user_id, $this->date_created );
-                }
-
-                if ( !$wpdb->query($sql) )
-                        return false;
-
-                do_action( 'bp_blogs_post_after_save', $this );
-
-                if ( $this->id )
-                        return $this->id;
-                else
-                        return $wpdb->insert_id;
-        }
-
-        /* Static Functions */
-
-        function delete( $post_id, $blog_id ) {
-                global $wpdb, $bp, $current_user;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d AND post_id = %d", $blog_id, $post_id ) );
-        }
-
-        function delete_oldest( $user_id = null ) {
-                global $wpdb, $bp;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $current_user->ID;
-
-                return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
-        }
-
-        function delete_posts_for_user( $user_id = null ) {
-                global $wpdb, $bp;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $bp->loggedin_user->id;
-
-                return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
-        }
-
-        function delete_posts_for_blog( $blog_id ) {
-                global $wpdb, $bp;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
-        }
-
-        function get_latest_posts( $blog_id = null, $limit = 5 ) {
-                global $wpdb, $bp;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( $blog_id )
-                        $blog_sql = $wpdb->prepare( " AND p.blog_id = %d", $blog_id );
-
-                $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 $blog_sql ORDER BY p.date_created DESC LIMIT $limit" ) );
-
-                for ( $i = 0; $i < count($post_ids); $i++ ) {
-                        $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
-                }
-
-                return $posts;
-        }
-
-        function get_posts_for_user( $user_id = null ) {
-                global $bp, $wpdb;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $bp->displayed_user->id;
-
-                // Show a logged in user their posts on private blogs, but not anyone else.
-                if ( !bp_is_my_profile() ) {
-                        $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
-                        $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
-                } else {
-                        $post_ids = $wpdb->get_results( $wpdb->prepare( "SELECT p.post_id, p.blog_id FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d ORDER BY p.date_created DESC", $user_id) );
-
-                        $total_post_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(p.post_id) FROM {$bp->blogs->table_name_blog_posts} p LEFT JOIN {$wpdb->base_prefix}blogs b ON p.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND p.user_id = %d", $user_id) );
-                }
-
-                for ( $i = 0; $i < count($post_ids); $i++ ) {
-                        $posts[$i] = BP_Blogs_Post::fetch_post_content($post_ids[$i]);
-                }
-
-                return array( 'posts' => $posts, 'count' => $total_post_count );
-        }
-
-        function fetch_post_content( $post_object ) {
-                // TODO: switch_to_blog() calls are expensive and this needs to be changed.
-                switch_to_blog( $post_object->blog_id );
-                $post = get_post($post_object->post_id);
-                $post->blog_id = $post_object->blog_id;
-                restore_current_blog();
-
-                return $post;
-        }
-
-        function get_total_recorded_for_user( $user_id = null ) {
-                global $bp, $wpdb;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $current_user->ID;
-
-                return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE user_id = %d", $user_id ) );
-        }
-
-        function is_recorded( $post_id, $blog_id, $user_id = null ) {
-                global $bp, $wpdb, $current_user;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $current_user->ID;
-
-                return $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$bp->blogs->table_name_blog_posts} WHERE post_id = %d AND blog_id = %d AND user_id = %d", $post_id, $blog_id, $user_id ) );
-        }
-
-        function total_post_count( $blog_id ) {
-                global $bp, $wpdb;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$blog_id )
-                        return false;
-
-                return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$bp->blogs->table_name_blog_posts} WHERE blog_id = %d", $blog_id ) );
-        }
-
-        function get_all() {
-                global $bp, $wpdb;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                return $wpdb->get_col( $wpdb->prepare( "SELECT post_id, blog_id FROM " . $bp->blogs->table_name_blog_posts ) );
-        }
-
-}
-
-/* DEPRECATED - Comment DB recording is scheduled for removal. Please use the activity stream to fetch a user's comments. */
-Class BP_Blogs_Comment {
-        var $id;
-        var $user_id;
-        var $blog_id;
-        var $comment_id;
-        var $comment_post_id;
-        var $date_created;
-
-        function bp_blogs_comment( $id = false, $blog_id = false, $comment_id = false ) {
-                global $bp, $wpdb;
-
-                if ( !$user_id )
-                        $user_id = $bp->displayed_user->id;
-
-                if ( $id || ( !$id && $blog_id && $comment_id ) ) {
-                        $this->id = $id;
-                        $this->blog_id = $blog_id;
-                        $this->comment_id = $comment_id;
-                        $this->populate();
-                }
-        }
-
-        function populate() {
-                global $wpdb, $bp;
-
-                if ( $this->id )
-                        $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE id = %d", $this->id ) );
-                else
-                        $comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d AND comment_id = %d", (int)$this->blog_id, (int)$this->comment_id ) );
-
-                $this->comment_id = $comment->comment_id;
-                $this->user_id = $comment->user_id;
-                $this->blog_id = $comment->blog_id;
-                $this->comment_post_id = $comment->comment_post_id;
-                $this->date_created = $comment->date_created;
-        }
-
-        function save() {
-                global $wpdb, $bp;
-
-                $this->comment_id = apply_filters( 'bp_blogs_comment_id_before_save', $this->comment_id, $this->id );
-                $this->comment_post_id = apply_filters( 'bp_blogs_comment_post_id_before_save', $this->comment_post_id, $this->id );
-                $this->blog_id = apply_filters( 'bp_blogs_comment_blog_id_before_save', $this->blog_id, $this->id );
-                $this->user_id = apply_filters( 'bp_blogs_comment_user_id_before_save', $this->user_id, $this->id );
-                $this->date_created = apply_filters( 'bp_blogs_comment_date_created_before_save', $this->date_created, $this->id );
-
-                do_action( 'bp_blogs_comment_before_save', $this );
-
-                if ( $this->id ) {
-                        // Update
-                        $sql = $wpdb->prepare( "UPDATE {$bp->blogs->table_name_blog_comments} SET comment_id = %d, comment_post_id = %d, blog_id = %d, user_id = %d, date_created = FROM_UNIXTIME(%d) WHERE id = %d", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created, $this->id );
-                } else {
-                        // Save
-                        $sql = $wpdb->prepare( "INSERT INTO {$bp->blogs->table_name_blog_comments} ( comment_id, comment_post_id, blog_id, user_id, date_created ) VALUES ( %d, %d, %d, %d, FROM_UNIXTIME(%d) )", $this->comment_id, $this->comment_post_id, $this->blog_id, $this->user_id, $this->date_created );
-                }
-
-                if ( !$wpdb->query($sql) )
-                        return false;
-
-                do_action( 'bp_blogs_comment_after_save', $this );
-
-                if ( $this->id )
-                        return $this->id;
-                else
-                        return $wpdb->insert_id;
-        }
-
-        /* Static Functions */
-
-        function delete( $comment_id, $blog_id ) {
-                global $wpdb, $bp, $current_user;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d", $comment_id, $blog_id ) );
-        }
-
-        function delete_oldest( $user_id = null ) {
-                global $wpdb, $bp, $current_user;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $current_user->ID;
-
-                return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d ORDER BY date_created ASC LIMIT 1", $user_id ) );
-        }
-
-        function delete_comments_for_user( $user_id = null ) {
-                global $wpdb, $bp;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $bp->loggedin_user->id;
-
-                return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
-        }
-
-        function delete_comments_for_blog( $blog_id ) {
-                global $wpdb, $bp;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->blogs->table_name_blog_comments} WHERE blog_id = %d", $blog_id ) );
-        }
-
-        function get_comments_for_user( $user_id = null ) {
-                global $bp, $wpdb;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $bp->displayed_user->id;
-
-                // Show the logged in user their comments on hidden blogs, but not to anyone else.
-                if ( !bp_is_my_profile() ) {
-                        $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
-                        $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.public = 1 AND b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
-                } else {
-                        $comment_ids = $wpdb->get_results( $wpdb->prepare( "SELECT c.comment_id, c.blog_id FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d ORDER BY c.date_created ASC", $user_id) );
-
-                        $total_comment_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(c.comment_id) FROM {$bp->blogs->table_name_blog_comments} c LEFT JOIN {$wpdb->base_prefix}blogs b ON c.blog_id = b.blog_id WHERE b.deleted = 0 AND b.archived = '0' AND b.spam = 0 AND b.mature = 0 AND c.user_id = %d", $user_id) );
-                }
-
-                for ( $i = 0; $i < count($comment_ids); $i++ )
-                        $comments[$i] = BP_Blogs_Comment::fetch_comment_content($comment_ids[$i]);
-
-                return array( 'comments' => $comments, 'count' => $total_comment_count );
-        }
-
-        function fetch_comment_content( $comment_object ) {
-                switch_to_blog($comment_object->blog_id);
-                $comment = get_comment($comment_object->comment_id);
-                $comment->blog_id = $comment_object->blog_id;
-                $comment->post = &get_post( $comment->comment_post_ID );
-                restore_current_blog();
-
-                return $comment;
-        }
-
-        function get_total_recorded_for_user( $user_id = null ) {
-                global $bp, $wpdb, $current_user;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $current_user->ID;
-
-                return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) FROM {$bp->blogs->table_name_blog_comments} WHERE user_id = %d", $user_id ) );
-        }
-
-        function total_comment_count( $blog_id, $post_id ) {
-                global $bp, $wpdb;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( $post_id )
-                        $post_sql = $wpdb->prepare( " AND comment_post_id = %d", $post_id );
-
-                return $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_id) WHERE blog_id = %d{$post_sql}", $blog_id ) );
-        }
-
-
-        function is_recorded( $comment_id, $comment_post_id, $blog_id, $user_id = null ) {
-                global $bp, $wpdb, $current_user;
-
-                if ( !$bp->blogs )
-                        bp_blogs_setup_globals();
-
-                if ( !$user_id )
-                        $user_id = $current_user->ID;
-
-                return $wpdb->get_var( $wpdb->prepare( "SELECT comment_id FROM {$bp->blogs->table_name_blog_comments} WHERE comment_id = %d AND blog_id = %d AND comment_post_id = %d AND user_id = %d", $comment_id, $blog_id, $comment_post_id, $user_id ) );
-        }
-
-}
-
</del><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="branches12bpblogsphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-blogs.php (2825 => 2826)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-blogs.php        2010-03-10 11:12:52 UTC (rev 2825)
+++ branches/1.2/bp-blogs.php        2010-03-10 12:03:43 UTC (rev 2826)
</span><span class="lines">@@ -27,30 +27,6 @@
</span><span class="cx">                                 KEY blog_id (blog_id)
</span><span class="cx">                          ) {$charset_collate};";
</span><span class="cx">
</span><del>-        $sql[] = "CREATE TABLE {$bp->blogs->table_name_blog_posts} (
-                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
-                                user_id bigint(20) NOT NULL,
-                                blog_id bigint(20) NOT NULL,
-                                post_id bigint(20) NOT NULL,
-                                date_created datetime NOT NULL,
-                                KEY user_id (user_id),
-                                KEY blog_id (blog_id),
-                                KEY post_id (post_id)
-                         ) {$charset_collate};";
-
-        $sql[] = "CREATE TABLE {$bp->blogs->table_name_blog_comments} (
-                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
-                                user_id bigint(20) NOT NULL,
-                                blog_id bigint(20) NOT NULL,
-                                comment_id bigint(20) NOT NULL,
-                                comment_post_id bigint(20) NOT NULL,
-                                date_created datetime NOT NULL,
-                                KEY user_id (user_id),
-                                KEY blog_id (blog_id),
-                                KEY comment_id (comment_id),
-                                KEY comment_post_id (comment_post_id)
-                         ) {$charset_collate};";
-
</del><span class="cx">         $sql[] = "CREATE TABLE {$bp->blogs->table_name_blogmeta} (
</span><span class="cx">                                 id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
</span><span class="cx">                                 blog_id bigint(20) NOT NULL,
</span><span class="lines">@@ -93,8 +69,6 @@
</span><span class="cx">         $bp->blogs->id = 'blogs';
</span><span class="cx">
</span><span class="cx">         $bp->blogs->table_name = $wpdb->base_prefix . 'bp_user_blogs';
</span><del>-        $bp->blogs->table_name_blog_posts = $wpdb->base_prefix . 'bp_user_blogs_posts';
-        $bp->blogs->table_name_blog_comments = $wpdb->base_prefix . 'bp_user_blogs_comments';
</del><span class="cx">         $bp->blogs->table_name_blogmeta = $wpdb->base_prefix . 'bp_user_blogs_blogmeta';
</span><span class="cx">         $bp->blogs->format_notification_function = 'bp_blogs_format_notifications';
</span><span class="cx">         $bp->blogs->slug = BP_BLOGS_SLUG;
</span><span class="lines">@@ -182,16 +156,6 @@
</span><span class="cx">         bp_core_load_template( apply_filters( 'bp_blogs_template_my_blogs', 'members/single/home' ) );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function bp_blogs_screen_recent_posts() {
-        do_action( 'bp_blogs_screen_recent_posts' );
-        bp_core_load_template( apply_filters( 'bp_blogs_template_recent_posts', 'members/single/home' ) );
-}
-
-function bp_blogs_screen_recent_comments() {
-        do_action( 'bp_blogs_screen_recent_comments' );
-        bp_core_load_template( apply_filters( 'bp_blogs_template_recent_comments', 'members/single/home' ) );
-}
-
</del><span class="cx"> function bp_blogs_screen_create_a_blog() {
</span><span class="cx">         global $bp;
</span><span class="cx">
</span><span class="lines">@@ -330,7 +294,6 @@
</span><span class="cx">         return apply_filters( 'bp_blogs_get_blogs', BP_Blogs_Blog::get( $type, $per_page, $page, $user_id, $search_terms ), &$params );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-
</del><span class="cx"> function bp_blogs_record_existing_blogs() {
</span><span class="cx">         global $bp, $wpdb;
</span><span class="cx">
</span><span class="lines">@@ -402,7 +365,7 @@
</span><span class="cx">         if ( !$user_id )
</span><span class="cx">                 $user_id = (int)$post->post_author;
</span><span class="cx">
</span><del>-        /* This is to stop infinate loops with Donncha's sitewide tags plugin */
</del><ins>+        /* This is to stop infinite loops with Donncha's sitewide tags plugin */
</ins><span class="cx">         if ( (int)$bp->site_options['tags_blog_id'] == (int)$blog_id )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><span class="lines">@@ -410,59 +373,11 @@
</span><span class="cx">         if ( $post->post_type != 'post' )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( !$is_recorded = BP_Blogs_Post::is_recorded( $post_id, $blog_id, $user_id ) ) {
-                if ( 'publish' == $post->post_status && '' == $post->post_password ) {
</del><ins>+        if ( 'publish' == $post->post_status && '' == $post->post_password ) {
+                bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
</ins><span class="cx">
</span><del>-                        /* If we're on a multiblog install, record this post */
-                        if ( bp_core_is_multisite() ) {
-                                $recorded_post = new BP_Blogs_Post;
-                                $recorded_post->user_id = $user_id;
-                                $recorded_post->blog_id = $blog_id;
-                                $recorded_post->post_id = $post_id;
-                                $recorded_post->date_created = strtotime( $post->post_date );
-
-                                $recorded_post_id = $recorded_post->save();
-
-                                bp_blogs_update_blogmeta( $recorded_post->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
-                        }
-
-                        if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
-                                /* Record this in activity streams */
-                                $post_permalink = get_permalink( $post_id );
-
-                                $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
-                                $activity_content = $post->post_content;
-
-                                bp_blogs_record_activity( array(
-                                        'user_id' => (int)$post->post_author,
-                                        'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ),
-                                        'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ),
-                                        'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ),
-                                        'type' => 'new_blog_post',
-                                        'item_id' => $blog_id,
-                                        'secondary_item_id' => $post_id,
-                                        'recorded_time' => $post->post_date_gmt
-                                ));
-                        }
-                }
-        } else {
-                $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
-
-                /* Delete the recorded post if the status is not published or it is password protected */
-                if ( 'publish' != $post->post_status || '' != $post->post_password ) {
-                        return bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
-
-                /* If the post author has changed, delete the post and re-add it. */
-                } else if ( (int)$existing_post->user_id != (int)$post->post_author ) {
-                        // Delete the existing recorded post
-                        bp_blogs_remove_post( $post_id, $blog_id, $existing_post );
-
-                        // Re-record the post with the new author.
-                        bp_blogs_record_post( $post_id );
-                }
-
</del><span class="cx">                 if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
</span><del>-                        /* Now re-record the post in the activity streams */
</del><ins>+                        /* Record this in activity streams */
</ins><span class="cx">                         $post_permalink = get_permalink( $post_id );
</span><span class="cx">
</span><span class="cx">                         $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
</span><span class="lines">@@ -477,20 +392,18 @@
</span><span class="cx">                                 'item_id' => $blog_id,
</span><span class="cx">                                 'secondary_item_id' => $post_id,
</span><span class="cx">                                 'recorded_time' => $post->post_date_gmt
</span><del>-                        ) );
</del><ins>+                        ));
</ins><span class="cx">                 }
</span><del>-        }
</del><ins>+        } else
+                bp_blogs_remove_post( $post_id, $blog_id );
</ins><span class="cx">
</span><del>-        do_action( 'bp_blogs_new_blog_post', $existing_post, $is_private, $is_recorded );
</del><ins>+        do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id );
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'save_post', 'bp_blogs_record_post', 10, 2 );
</span><span class="cx">
</span><del>-function bp_blogs_record_comment( $comment_id, $is_approved ) {
</del><ins>+function bp_blogs_record_comment( $comment_id, $is_approved = true ) {
</ins><span class="cx">         global $wpdb, $bp;
</span><span class="cx">
</span><del>-        if ( !$is_approved )
-                return false;
-
</del><span class="cx">         $comment = get_comment($comment_id);
</span><span class="cx">         $comment->post = get_post( $comment->comment_post_ID );
</span><span class="cx">
</span><span class="lines">@@ -505,20 +418,6 @@
</span><span class="cx">         if ( !empty( $post->post_password ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        /* If we're on a multiblog install, record this post */
-        if ( bp_core_is_multisite() ) {
-                $recorded_comment = new BP_Blogs_Comment;
-                $recorded_comment->user_id = $user_id;
-                $recorded_comment->blog_id = $wpdb->blogid;
-                $recorded_comment->comment_id = $comment_id;
-                $recorded_comment->comment_post_id = $comment->comment_post_ID;
-                $recorded_comment->date_created = strtotime( $comment->comment_date_gmt );
-
-                $recorded_commment_id = $recorded_comment->save();
-
-                bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) );
-        }
-
</del><span class="cx">         if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
</span><span class="cx">                 /* Record in activity streams */
</span><span class="cx">                 $comment_link = get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id;
</span><span class="lines">@@ -541,6 +440,7 @@
</span><span class="cx">         return $recorded_comment;
</span><span class="cx"> }
</span><span class="cx"> add_action( 'comment_post', 'bp_blogs_record_comment', 10, 2 );
</span><ins>+add_action( 'edit_comment', 'bp_blogs_record_comment', 10 );
</ins><span class="cx">
</span><span class="cx"> function bp_blogs_manage_comment( $comment_id, $comment_status ) {
</span><span class="cx">         if ( 'spam' == $comment_status || 'hold' == $comment_status || 'delete' == $comment_status || 'trash' == $comment_status )
</span><span class="lines">@@ -600,7 +500,7 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'remove_user_from_blog', 'bp_blogs_remove_blog_for_user', 10, 2 );
</span><span class="cx">
</span><del>-function bp_blogs_remove_post( $post_id, $blog_id = false, $existing_post = false ) {
</del><ins>+function bp_blogs_remove_post( $post_id, $blog_id = false ) {
</ins><span class="cx">         global $current_blog, $bp;
</span><span class="cx">
</span><span class="cx">         $post_id = (int)$post_id;
</span><span class="lines">@@ -608,12 +508,6 @@
</span><span class="cx">         if ( !$blog_id )
</span><span class="cx">                 $blog_id = (int)$current_blog->blog_id;
</span><span class="cx">
</span><del>-        if ( !$existing_post )
-                $existing_post = new BP_Blogs_Post( null, $blog_id, $post_id );
-
-        // Delete post from the bp_blogs table
-        BP_Blogs_Post::delete( $post_id, $blog_id );
-
</del><span class="cx">         // Delete activity stream item
</span><span class="cx">         bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'component' => $bp->blogs->slug, 'type' => 'new_blog_post' ) );
</span><span class="cx">
</span><span class="lines">@@ -624,9 +518,6 @@
</span><span class="cx"> function bp_blogs_remove_comment( $comment_id ) {
</span><span class="cx">         global $wpdb, $bp;
</span><span class="cx">
</span><del>-        $recorded_comment = new BP_Blogs_Comment( false, $wpdb->blogid, $comment_id );
-        BP_Blogs_Comment::delete( $comment_id, $wpdb->blogid );
-
</del><span class="cx">         // Delete activity stream item
</span><span class="cx">         bp_blogs_delete_activity( array( 'item_id' => $wpdb->blogid , 'secondary_item_id' => $comment_id, 'type' => 'new_blog_comment' ) );
</span><span class="cx">
</span><span class="lines">@@ -662,8 +553,6 @@
</span><span class="cx">
</span><span class="cx">         /* If this is regular blog, delete all data for that blog. */
</span><span class="cx">         BP_Blogs_Blog::delete_blog_for_all( $blog_id );
</span><del>-        BP_Blogs_Post::delete_posts_for_blog( $blog_id );
-        BP_Blogs_Comment::delete_comments_for_blog( $blog_id );
</del><span class="cx">
</span><span class="cx">         // Delete activity stream item
</span><span class="cx">         bp_blogs_delete_activity( array( 'item_id' => $blog_id, 'component' => $bp->blogs->slug, 'type' => false ) );
</span><span class="lines">@@ -676,25 +565,6 @@
</span><span class="cx">         return BP_Blogs_Blog::get_blogs_for_user( $user_id, $show_hidden );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-/* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_post' filter. */
-function bp_blogs_get_posts_for_user( $user_id ) {
-        return BP_Blogs_Post::get_posts_for_user( $user_id );
-}
-
-/* DEPRECATED - scheduled for removal. Please use the activity stream with a 'new_blog_comment' filter. */
-function bp_blogs_get_comments_for_user( $user_id ) {
-        return BP_Blogs_Comment::get_comments_for_user( $user_id );
-}
-
-function bp_blogs_get_latest_posts( $blog_id = null, $limit = 5 ) {
-        global $bp;
-
-        if ( !is_numeric( $limit ) )
-                $limit = 5;
-
-        return BP_Blogs_Post::get_latest_posts( $blog_id, $limit );
-}
-
</del><span class="cx"> function bp_blogs_get_all_blogs( $limit = null, $page = null ) {
</span><span class="cx">         return BP_Blogs_Blog::get_all( $limit, $page );
</span><span class="cx"> }
</span><span class="lines">@@ -703,18 +573,6 @@
</span><span class="cx">         return BP_Blogs_Blog::get( 'random', $limit, $page );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function bp_blogs_get_all_posts( $limit = null, $page = null ) {
-        return BP_Blogs_Post::get_all( $limit, $page );
-}
-
-function bp_blogs_total_post_count( $blog_id ) {
-        return BP_Blogs_Post::total_post_count( $blog_id );
-}
-
-function bp_blogs_total_comment_count( $blog_id, $post_id = false ) {
-        return BP_Blogs_Post::total_comment_count( $blog_id, $post_id );
-}
-
</del><span class="cx"> function bp_blogs_is_blog_hidden( $blog_id ) {
</span><span class="cx">         return BP_Blogs_Blog::is_hidden( $blog_id );
</span><span class="cx"> }
</span><span class="lines">@@ -833,8 +691,6 @@
</span><span class="cx"> function bp_blogs_remove_data( $user_id ) {
</span><span class="cx">         /* If this is regular blog, delete all data for that blog. */
</span><span class="cx">         BP_Blogs_Blog::delete_blogs_for_user( $user_id );
</span><del>-        BP_Blogs_Post::delete_posts_for_user( $user_id );
-        BP_Blogs_Comment::delete_comments_for_user( $user_id );
</del><span class="cx">
</span><span class="cx">         do_action( 'bp_blogs_remove_data', $user_id );
</span><span class="cx"> }
</span><span class="lines">@@ -866,36 +722,9 @@
</span><span class="cx">         wp_cache_delete( 'bp_total_blogs', 'bp' );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function bp_blogs_clear_post_object_cache( $blog_id, $post_id, $user_id ) {
-        wp_cache_delete( 'bp_user_posts_' . $user_id, 'bp' );
-}
-
-function bp_blogs_format_clear_post_cache( $recorded_post_obj ) {
-        bp_blogs_clear_post_object_cache( false, false, $recorded_post_obj->user_id );
-
-        /* Clear the sitewide activity cache */
-        wp_cache_delete( 'sitewide_activity', 'bp' );
-}
-
-function bp_blogs_clear_comment_object_cache( $blog_id, $comment_id, $user_id ) {
-        wp_cache_delete( 'bp_user_comments_' . $user_id, 'bp' );
-}
-
-function bp_blogs_format_clear_comment_cache( $recorded_comment_obj ) {
-        bp_blogs_clear_comment_object_cache( false, false, $recorded_comment_obj->user_id );
-
-        /* Clear the sitewide activity cache */
-        wp_cache_delete( 'sitewide_activity', 'bp' );
-}
-
</del><span class="cx"> // List actions to clear object caches on
</span><span class="cx"> add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 );
</span><del>-add_action( 'bp_blogs_remove_post', 'bp_blogs_clear_post_object_cache', 10, 3 );
-add_action( 'bp_blogs_remove_comment', 'bp_blogs_clear_comment_object_cache', 10, 3 );
-
</del><span class="cx"> add_action( 'bp_blogs_new_blog', 'bp_blogs_format_clear_blog_cache', 10, 2 );
</span><del>-add_action( 'bp_blogs_new_blog_post', 'bp_blogs_format_clear_post_cache', 10, 2 );
-add_action( 'bp_blogs_new_blog_comment', 'bp_blogs_format_clear_comment_cache', 10, 2 );
</del><span class="cx">
</span><span class="cx"> // List actions to clear super cached pages on, if super cache is installed
</span><span class="cx"> add_action( 'bp_blogs_remove_data_for_blog', 'bp_core_clear_cache' );
</span></span></pre>
</div>
</div>
</body>
</html>