Skip to:
Content

BuddyPress.org

Opened 14 years ago

Closed 14 years ago

#2342 closed defect (bug) (fixed)

Blog Comment Link in Activity Stream Broken has ID# Twice

Reported by: hotforwords's profile hotforwords Owned by:
Milestone: 1.2.4 Priority: normal
Severity: Version:
Component: Core Keywords: has-patch
Cc:

Description

BuddyPress integrated with Wordpress Single User in the activity stream if someone makes a comment on the Wordpress Blog side the link to the comment in the Activity stream is correct EXCEPT that the comment number is doubled at the end, thus breaking the link.

I reference the problem in this thread: http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/blog-comment-link-in-activity-stream-broken-has-id-twice/


It appears that some code in function bp_blogs_record_comment() of bp-blogs.php is causing the issue. In BP v1.2.3, if you look at line 429 and 430, you can see the culprit.

`$comment_link = get_permalink( $comment->comment_post_ID ) . ‘#comment-’ . $comment_id;
$activity_action = sprintf( ( ‘%1$s commented on the blog post %2$s’, ‘buddypress’ ), bp_core_get_userlink( $user_id ), ‘comment_ID . ‘”>’ . $comment->post->post_title . ‘‘ );`

If you look at line 430 near the end, the comment ID is appended to the built string. But, that comment ID has already been included in the variable $comment_link which is built above on line 429. So, you get a doubling of the comment ID.

In the trunk version of BP, the latest working copy version, function bp_blogs_record_comment() is located in a different place and these two code lines appear at 371 and 372.

Change History (5)

#1 @hotforwords
14 years ago

I figured out the proper fix, because the first link, the name of the Blog Title is supposed to take you to the blog not the comment.. the later link called View takes you to the Comment.

We want to fix the BLOG POST TITLE LINK without breaking the VIEW link.

So I fixed it this way:

On Line 429
Take this code:

$activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );

and change it to:

$activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . get_permalink( $comment->comment_post_ID ) . '">' . $comment->post->post_title . '</a>' );
{{{

}}}

#2 @boonebgorges
14 years ago

  • Keywords has-patch added

I noticed this before when writing a plugin. My fix was similar to hotforwords's

#3 @johnjamesjacoby
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [2974]) Fixes #2342 props hotforwords

#4 @hotforwords
14 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The 2974 fix is incorrect. When PAGED COMMENTS are turned on in Wordpress, the link does not take you to the proper page with the proper comment.

I have the proper fix:

On line 429 take this code:

$comment_link = get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id;

And change it to:

$comment_link = htmlspecialchars( get_comment_link( $comment->comment_ID ) );

Then on line 430 take the code:

$activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '#comment-' . $comment->comment_ID . '">' . $comment->post->post_title . '</a>' );

And change it to:

$activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $comment_link . '">' . $comment->post->post_title . '</a>' );

Now, when paged comments are on, the link takes you directly to the comment on the correct page.

Thanks!

#5 @apeatling
14 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [3013]) Fixes #2342 props hotforwords

Note: See TracTickets for help on using tickets.