Skip to:
Content
Pages
Categories
Search
Top
Bottom

Topic Count

  • @bobjgarrett

    Participant

    Having imported thousands of topics from another system the topic count was incorrect for one of my forums.
    I tried the Repair Forums tool to correct this but it made no difference.
    I then edited the postmeta table for the relevant forum setting _bbp_topic_count and _bbp_total_topic_count to the correct topic number. This worked in that the forum then showed the correct number.
    However, when I then deleted a post (which had been a test topic) the number went back down to only counting those that were actually added rather than those imported.
    So the numbering system is clearly more complex than I thought.
    Can anyone advise how to get the right number to be there and be updated correctly?

Viewing 11 replies - 1 through 11 (of 11 total)
  • @robin-w

    Moderator

    without getting into looking at the code, you might want to look at the meta for a topic which is imported vs. one that is added. I think there is a ‘parent’ or ‘forum_id’ set in topic meta to say which forum it belongs to, which might need setting for the imported ones to get the repair tools and updates working correctly.

    or even the actual post parent of the imported topic might need setting.

    If it is not that, come back and I’ll do some digging further.

    @bobjgarrett

    Participant

    Thanks for your reply.
    I have looked at this in a bit more detail but not got anywhere!
    As you suggested I compared two topics for a topic imported vs one entered and the differences don’t seem relevant (e.g. no ip address for the imported ones etc.). I also looked at the records from the postmeta table for the two topics and again don’t think there are relevant differences though again no ip address for the imported, 0 for _bbp_reply_count for the imported.
    So no luck there.
    I tried looking at the code of bbpress.php but could not work out how it picked up the count or incremented it.
    Interestingly I also tried using the shortcode [bbp-stats] in a test page and that reported the correct number of topics despite the individual forum count being incorrect! How can that be?

    @robin-w

    Moderator

    Interestingly I also tried using the shortcode [bbp-stats] in a test page and that reported the correct number of topics despite the individual forum count being incorrect! How can that be?

    I should start by saying that I am not a bbpress author, just someone trying to help 🙂

    the [bbp-stats] shortcode does the wordpress function
    wp_count_posts( bbp_get_topic_post_type())

    so actually counts the number of topics in the database.

    the forums page calls a function bbp_get_forum_topic_count in \bbpress\includes\forums\template.php

    This looks up the number held in the forum’s post meta under _bbp_topic_count (which you had already worked out)

    so how did you delete the post which caused the numnber to fail back?

    @bobjgarrett

    Participant

    Thanks for your help on this. Like me you obviously relish a challenge.
    To answer your question, I believe the topic count number has been reset wrongly when new topics I added as that is all other members of the forum could do and I have seen the number change and this is what led me to try to sort this out. I do not want to add a topic myself as the site is live and >400 members would then be alerted. However, there were a few topics which were imported added when I was setting it up which I did not want. I had set these to “hidden”. I just deleted one of these and the topic count immediately changed to the wrong number. So if you have a test site you could just try deleting a topic.
    So it must be whatever function which updates the topic count which is causing the issue but I have not found this.

    @robin-w

    Moderator

    so are they still set as ‘hidden’ ?

    @bobjgarrett

    Participant

    The forum was showing as 675 topics 5 hidden. I deleted one of the hidden ones and now have 5 topics 4 hidden.

    @robin-w

    Moderator

    I can’t see anything in the code that would do anything other than decrease the count by 1 on trashing a hidden or published topic.

    If it was set to hidden, then it changes the following meta_bbp_total_topic_count_hidden

    @bobjgarrett

    Participant

    Strange then that it also changed the total topic count. I will have another look at the code tomorrow.
    Thanks.

    @robin-w

    Moderator

    these functions are held in bbpress\includes\forums\template.php and \bbpress\includes\forums\functions.php

    the one changing the count is in functions.php

    bbp_bump_forum_topic_count

    @bobjgarrett

    Participant

    After much searching in that file and then further comparisons of the posts (and then the linked postmeta records) created vs those imported I spotted an error in the postmeta records for those imported.
    I had had to write my own code to import a forum from WP Symposium and I had swapped two record numbers between two meta_keys. An update in the database table seems to have fixed this.
    Thanks for your advice while I was finding the problem I had created!

    @robin-w

    Moderator

    hey that’s great to hear – glad you are fixed !!

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