#5341 closed defect (bug) (wontfix)
Avoid bloat in the activity table when recording blog post activity items
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Core | Keywords: | |
| Cc: |
Description
Currently the content of a new blog post is recorded to the database twice. Once in the BP activity table by function bp_blogs_record_post and once in the wp_posts table.
I'm wondering if this is unnecessary?
In bp_blogs_record_post, the bp_blogs_record_activity function records the $post_id as the secondary_item_id so if the content is needed at a later date then the content can be fetched from the wp_posts table via something like this:
$post = get_post( $post_id ); $excerpt = $post->post_excerpt; $content = $post->post_content;
This makes it unnecessary for bp_blogs_record_activity to record blog post content.
The same approach to avoiding saving duplicate data could be taken for blog comments. As a result, the size of the activity table wouldn't grow as quickly.
Thoughts?
The biggest issue here is that, on a multisite setup, the posts come from all over the network. Thus, you'd need to
switch_to_blog()for every post. This would create a huge amount of overhead on every pageload. Even on a non-multisite setup, loading 20 blog posts is much more resource-intensive than doing the single SQL query that the activity stream currently requires.You might think of the excerpt stored in the activity table as a sort of cache: a readily accessible copy of the original data, optimized for quick access.
Thanks for the thought!