Skip to:
Content
Pages
Categories
Search
Top
Bottom

Blog Comment Link in Activity Stream Broken has ID# Twice


  • hotforwords
    Participant

    @hotforwords

    Hi,
    I have BuddyPress integrated with WordPress Single User and everything is great, except that in the activity stream if someone makes a comment on the 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. You can see an example here: http://www.hotforwords.com/members/alx/ Just click the Blog Name after where it says “commented on the blog post”.

    Does anyone know where and in which PHP document that link is created? I can’t find it for the life of me!

    Thanks so much!

    Marina

Viewing 15 replies - 1 through 15 (of 15 total)

  • @mercime
    Keymaster

    @mercime

    Don’t see any comment number or doubling thereof in the line
    “aLx commented on the blog post Platonic i was talking about the old threads. they’re gone. that was my point. · View”


    Jeff Sayre
    Participant

    @jeffsayre

    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 430 and 431, 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 431 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 430. 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.

    Please log into Trac and report this as a bug ( create a new ticket ) as it will simply get lost in the support forums. You log into Trac using the same credentials as you use to log into this site.

    You can post a link to this thread to provide more details.


    Jeff Sayre
    Participant

    @jeffsayre

    @mercime-

    The doubling appears in the browser’s status bar.


    Jeff Sayre
    Participant

    @jeffsayre

    Glad that worked!

    When you’ve created the ticker, would you please post a link to it within this thread. It will help close the circle, so to speak.


    hotforwords
    Participant

    @hotforwords

    That fix I did actually didn’t work.. I need to look some more.. I realized that the Blog link is supposed go to the actual blog post.. the View link is supposed to go to the actual comment.. so I need to remove the whole Comment ID from the Blog link. Let me look some more!

    Oh.. here is the link to the Ticket: https://trac.buddypress.org/ticket/2342


    Jeff Sayre
    Participant

    @jeffsayre

    Okay, I did not include the entire code line in my post above. Line 431 (430 for you) should read as follows:

    `$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 . ‘‘ );`

    What you need to do is this:

    `$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->post->post_title . ‘‘ );`

    Keep (or replace) the first line as is. Make the small change to the second line. You are removing this from the end of the string:

    ` ‘#comment-‘ . $comment->comment_ID .`

    Code:
    testing

    Jeff Sayre
    Participant

    @jeffsayre

    Okay, crap. I did post the proper code line but the new forums are not allowing me to post code so it is turning it into a link. Give me a few minutes…


    Jeff Sayre
    Participant

    @jeffsayre

    Well, I can’t solve the issue of not being able to post codeblocks. So, here’s another way to display what I’m saying. On line 431, the end of the code starting just after the link tag is this:

    $comment_link . ‘#comment-‘ . $comment->comment_ID . ‘”>’ . $comment->post->post_title . ‘‘ );

    Remove this from that line:

    ‘#comment-‘ . $comment->comment_ID .

    Make sure to remove that last dot.

    Sorry about all the hassle. We’re trying to work out some kinks with the new forum.


    hotforwords
    Participant

    @hotforwords

    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.

    The stream looks like this:

    HotForWords commented on the blog post W, why double U? 18 seconds ago · View · Delete

    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:
    . $comment_link . '#comment-' . $comment->comment_ID .

    and change it to:

    . get_permalink( $comment->comment_post_ID ) .


    Jeff Sayre
    Participant

    @jeffsayre

    If you look at the “View” link output, it is fine–no double comment reference. It is only the Blog title link that has the doubling error.

    The error is caused by the Comment ID being passed twice into the sprintf() function. One time from the line above via the $comment_link variable, and the second time directly within the function via ‘#comment-‘ . $comment->comment_ID. Therefore, removing the second reference is the better option.

    The way that you are currently doing it may work, but once you upgrade BuddyPress, your changes will be lost. That is why it is important to file bug tickets and get the bugs correct in the core files!


    hotforwords
    Participant

    @hotforwords

    I fixed my code above to an easier fix.

    The Blog link is not supposed to go the the comment.. but rather the Blog post. I believe. Otherwise, why do you have the View link as well. So instead of fixing the Blog link to also go to the comment, which is what you just did.. I made the Blog link go to the actual Blog NOT the comment.

    I think that that is the way it is supposed to work, if I am not mistaken.

    Let me see if I can revise the ticket.


    hotforwords
    Participant

    @hotforwords

    I revised the ticket with my suggested fix :-)

    Thanks Jeff so much!


    Jeff Sayre
    Participant

    @jeffsayre

    NOTE: Please ignore this post. The same behavior in outputitng codeblocks is still being observed. Refer to the Trac ticket if you’re having the OP’s issue

    Alright, we DJPaul’s help, I’ve just learned that what I used to use without issue in the old forums is no longer an option. So, I’ll redo my first post using the &#8216code&#8217 notation.

    Here’s the original codeblock:


    $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 . '' );

    And here’s the corrected codeblock:


    $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->post->post_title . '' );


    Jeff Sayre
    Participant

    @jeffsayre

    You’re welome!


    Jeff Sayre
    Participant

    @jeffsayre

    [blockquote]The Blog link is not supposed to go the the comment.. but rather the Blog post. I believe. Otherwise, why do you have the View link as well. So instead of fixing the Blog link to also go to the comment, which is what you just did.. I made the Blog link go to the actual Blog NOT the comment.[/blockquote]

    Actually, what I changed was the code that outputs the comment link–at least as it is supposed in BP’s codebase. The blog link ( the link to the post’s permalink ) is outputted on line 46 of the theme file /activity/entry.php.

    But, I believe your interpretation may be better. First, here’s a link to the overall blog, next view the actual comment.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Blog Comment Link in Activity Stream Broken has ID# Twice’ is closed to new replies.
Skip to toolbar