Home › Forums › BulletProof Security Pro › BuddyPress Activity Stream – Duplicate Content, Content Not Updated
Tagged: Activity Stream, BuddyPress
- This topic has 1 reply, 2 voices, and was last updated 8 years, 10 months ago by
Andrew Carter.
-
AuthorPosts
-
AITpro Admin
KeymasterWarning: This code mod no longer works in newer versions of BuddyPress
NOTE: This code should be considered experimental. Everything is working as intended and correctly on this forum site, but this code should still be considered experimental.I am not sure if these 2 issues are only occurring on this particular BuddyPress/bbPress Forum site. I looked around and I see similar questions about this issue, but did not find the exact questions or solutions to these 2 issues. Or maybe this is just the new BuddyPress/bbPress intended functionality.The first issue was that in older versions of BuddyPress a single event would be created in the Sitewide Activity Stream even if the Topic Reply was edited again. In BuddyPress 2.1.1 I was seeing a new Activity Stream event each time a Topic Reply was edited/updated. This may be new intended functionality.The second issue was an older issue that I finally had time to dig into. The content of Activity Stream events were not being updated even though there is an existing UPDATE Query in BuddyPress. This may just be a specific issue with this specific forum site since a fair amount of customizations/modifications have been created.I created a custom coding solution for anyone else who wants to modify/change these things. Unfortunately, these are hard coded solutions directly in the Core BuddyPress code instead of using a hook.BuddyPress Older versions location of the code/file: /buddypress/bp-activity/bp-activity-classes.php
Code Line: 213
Query Performance Hit: None/insignificant for the item_id QueryBuddyPress 2.3.2.1 to 2.5.2: location of the code/file is different.
BuddyPress File: /buddypress/bp-activity/classes/class-bp-activity-activity.php
Code Line: 246
Query Performance Hit: None/insignificant for the item_id QueryOriginal BuddyPress Code// If we have an existing ID, update the activity item, otherwise insert it. if ( $this->id ) $q = $wpdb->prepare( "UPDATE {$bp->activity->table_name} SET user_id = %d, component = %s, type = %s, action = %s, content = %s, primary_link = %s, date_recorded = %s, item_id = %d, secondary_item_id = %d, hide_sitewide = %d, is_spam = %d WHERE id = %d", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam, $this->id ); else $q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam );
All new code modifications/replacements:
// AITpro Customization $get_item_id = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->activity->table_name} WHERE item_id = %d", $this->item_id ) ); // AITpro Customization // Note: The only drawback is that the last_activity timestamp is not updated in the activity stream, but I actually prefer that switch ( $wpdb->num_rows != 0 ) { // update row for everything that is NOT $this->type: new_member, last_activity, updated_profile and new_avatar using item_id WHERE clause case $this->type != 'new_member' && $this->type != 'last_activity' && $this->type != 'updated_profile' && $this->type != 'new_avatar': $q = $wpdb->update( $bp->activity->table_name, array( 'user_id' => $this->user_id, 'component' => $this->component, 'type' => $this->type, 'action' => $this->action, 'content' => $this->content, 'primary_link' => $this->primary_link, 'date_recorded' => $this->date_recorded, 'item_id' => $this->item_id, 'secondary_item_id' => $this->secondary_item_id, 'hide_sitewide' => $this->hide_sitewide, 'is_spam' => $this->is_spam ), array( 'item_id' => $this->item_id ) ); break; // for everything else insert a new row default: $q = $wpdb->prepare( "INSERT INTO {$bp->activity->table_name} ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( %d, %s, %s, %s, %s, %s, %s, %d, %d, %d, %d )", $this->user_id, $this->component, $this->type, $this->action, $this->content, $this->primary_link, $this->date_recorded, $this->item_id, $this->secondary_item_id, $this->hide_sitewide, $this->is_spam ); }
Andrew Carter
Participant[Spam comment has been allowed as the online Plagiarism Checking Tool appears to be useful]
Very nice and Detail information about Check Duplicate Content: http://theplagiarismchecker.com/. I was looking for such sites which can check detail information about copied content ! but i know some others they just provide you free check just once or twice!
-
AuthorPosts
- You must be logged in to reply to this topic.