bp_get_forum_topic_count causing massive memory requirements and timeouts
|Reported by:||3sixty||Owned by:|
I previously reported that the BuddyPress /forums page (“Group Forums Directory”) was crashing due to memory limit errors on a BP Forum that had 20,000+ topics. I kept bumping it up until I finally got the page to render at a memory limit of 200M. The problem is the function bp_get_forum_topic_count is causing massive memory requirements and timeouts. This function that displays the total number of topics in the tab: “All Topics (23,466)” Even with the memory limit high enough, bp_get_forum_topic_count takes a good 4 seconds to generate that number (on a VPS that otherwise pulls up pages in a fraction of a second).
I’m wondering why this function even exists, and if it needs to exist, can it be fixed?? r-a-y suspects (and I agree) that this is probably an issue with the BB_Query instance.
bp_forum_pagination_count() already performs a similar function directly below the All Topics tab (“Viewing topic 1 to 20 (23,466 total topics)”) and all it does is call $forum_template->total_topic_count - very simple
Given that total_topic_count is already stored in the $forum_template, is bp_get_forum_topic_count a dog that serves no purpose and causes massive memory issues to boot?