Skip to:
Content
Pages
Categories
Search
Top
Bottom

Bug: broken link in the Last Post column when Akismet installed


  • gtatar
    Participant

    @gtatar

    In the list of forums, there is a column called “Last Post”. For each forum, this column contains a link to the last topic or reply posted to that forum.

    If there was a spam post 2 hours ago (and Akismet puts it in spam), then the “Last Post” column will contain text “2 hours ago” and a link like https://www.example.com/?post_type=topic&p=1759 (where 1759 is ID of the spam post).

    Correct behavior would be to link to the latest published post. Anchor text should also reflect when the latest post was published. In my example, if a post got published 5 hours ago; and then a spam post came in 2 hours ago, the anchor text should say “5 hours ago”.

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

  • Robin W
    Moderator

    @robin-w

    yes it does (and does so on here as well!).

    I’m just a helper here, not a bbpress author.

    I don’t run akismet on my test site. Are you able to replicate the problem so that we can check a fix if I am able to work up some code?


    Robin W
    Moderator

    @robin-w

    just posting this link here for reference for me 🙂

    Akismet causing “recent topics” problem?


    gtatar
    Participant

    @gtatar

    Hi Robin. Thank you for looking at this. Yes, I can replicate the problem and test a fix. In fact, I have the described situation on my forum right now:

    https://www.totalsync.com/forum/

    And it is likely to stay this way for the next few days. If necessary I can also recrate it manually.


    Robin W
    Moderator

    @robin-w

    ok, give this a try – it may or may not do the trick !!

    add_action ('bbp_new_topic_post_extras', 'rew_spam_update_last_active', 10 ,1 ) ;
    
    function rew_spam_update_last_active ($topic_id) {
    	//this function tests if a new topic has been marked as spam by Akismet.  If so then the last active date will be wrong
    	//So we use topic walker to recalculate it
    	if (!empty (get_post_meta( $topic_id, '_bbp_akismet_user_result' ))) {
    	bbp_update_topic_walker ($topic_id) ;
    	}
    }

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets


    Robin W
    Moderator

    @robin-w

    if it works for a topic, then I’ll do the code for a reply, which is basically changing mthe word topic to reply 🙂


    gtatar
    Participant

    @gtatar

    Thank you, Robin. I added the snipped, and it partially worked. The anchor text “time ago” now reflects the time of the latest good post. However the URL is for the latest spam post.

    I started digging a bit through bbpress code. It looks like if the fix was inside bbp_topic_freshness_link() it would be much easier to test, as we would not need to wait for a new spam post to test the fix. And perhaps make decisions based on the wp_post status having the value “publish”. This way the solution would not be specific to Akismet. But I am really too new to WordPress coding and bbPress to be making this kind of changes myself.


    gtatar
    Participant

    @gtatar

    FYI, post ID 1768 is the post that just came in.


    Robin W
    Moderator

    @robin-w

    ‘It looks like if the fix was inside bbp_topic_freshness_link() it would be much easier to test, ;’

    agree but it just wouldn’t work there, that is not where or when the issue is occurring.

    Try

    add_action ('bbp_new_topic_post_extras', 'rew_spam_update_last_active', 10 ,1 ) ;
    
    function rew_spam_update_last_active ($topic_id) {
    	//this function tests if a new topic has been marked as spam by Akismet.  If so then the last active date will be wrong
    	//So we use topic walker to recalculate it
    	if (!empty (get_post_meta( $topic_id, '_bbp_akismet_user_result' ))) {
    	bbp_update_topic_walker ($topic_id,  '', 0, 0, true) ;
    	}
    }
    

    gtatar
    Participant

    @gtatar

    Still the same result with the new code.

    But I noticed that emptying the spam folder causes “Last Post” link to change to the correct value. So there is some code in bbpress that can fix the link (I am guessing by changing something in the database?).


    Robin W
    Moderator

    @robin-w

    So there is some code in bbpress that can fix the link (I am guessing by changing something in the database?).

    yes it is the function ‘bbp_update_topic_walker ‘ called in my code 🙂 🙂

    I’ll look further at why it isn’t recalculating based in that info


    Robin W
    Moderator

    @robin-w

    maybe it’s the if function, try

    add_action ('bbp_new_topic_post_extras', 'rew_spam_update_last_active', 10 ,1 ) ;
    
    function rew_spam_update_last_active ($topic_id) {
    	//this function tests if a new topic has been marked as spam by Akismet.  If so then the last active date will be wrong
    	//So we use topic walker to recalculate it
    	bbp_update_topic_walker ($topic_id,  '', 0, 0, true) ;
    	}

    It’s not the answer, but might help get to the solution problem


    Robin W
    Moderator

    @robin-w

    or might not – I’m trying to look at this in limited free time and trying not to get sucked into too deeper a code dive 🙂


    gtatar
    Participant

    @gtatar

    Robin, I applied your code change. Will report results once I have them.


    gtatar
    Participant

    @gtatar

    Robin, your code change worked for new topics. Did you say we would need an additional code change for replies?

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.
Skip to toolbar