I've just installed and started working with UIEForum, and the first thing I need to say is thank you for the great work.
Now on to the buggage. One thing I noticed is that if you have an EMPTY forum which has subforums, it will display an empty "Thread" table. You can confirm this by creating a forum with NO posts, then create a subforum and put some posts in it. It should display the "No Threads in this forum" note in the parent forum, but it doesn't.
I figured out that there are two sets of counters for each forum: normal and total. In the database (table {F_Forums}), there's ThreadCount and TotalThreadCount, then PostCount and TotalPostCount. However, the uieforum code does not distinguish between the two when updating post counts, even though it's clearly supposed to. When you look at the database, the numbers are exactly the same under all circumstances I've seen. As I understand it, "ThreadCount" refers to the number of threads in that forum and "TotalThreadCount" refers to the number of threads in the forum PLUS the number of threads in all sub-forums. However, due to a bug in the uieforum_update_counts function, the two are updated in step with one another, no matter what.
Starting Line 1592 you'll see:
if($f->ParentForum)
{
uieforum_update_counts($f->ParentForum, $type, $counttype, $increment);
}
In some cases $counttype is "thread" and in others it is "totalthread" (also "post" and "totalpost"), but as you can see, no matter which it is, it "bubbles up" to all parents, and so the parent's "ThreadCount" gets updated right alongside its "TotalThreadCount" even though the code obviously means to only update the "TotalThreadCount" of parents, since the code leading up to this point clearly distinguishes between the two. So to fix this, add the lines:
if($f->ParentForum)
{
// Prevent counts of threads and posts from bubbling up to parent forum.
// Increment totalthread and totalpost (which are SUPPOSED to include all subforums) only.
if ($counttype == "thread") $counttype = 'totalthread';
if ($counttype == "post") $counttype = 'totalpost';
uieforum_update_counts($f->ParentForum, $type, $counttype, $increment);
}
This fixes the problem. Now when you view a forum with no threads in it, it shows the "no threads" text as designed, even when there are subforums with threads. But the "TotalThreadCount" and "TotalPostCount" are still correctly incremented, so the counts of threads and posts for all nested subforums are still accurate!
I hope this helps. I don't know enough about CVS and diff and stuff to create a real patch file. I know how to apply them using Eclipse, but not how to generate them; I'm sorry! Someone will have to generate the actual patch themselves.
Comments
Comment #1
Vallenwood commentedDammit, I keep forgetting to say which file it's in. This is in functions.inc.php.
Comment #2
daniel.hunt commentedExcellent, nice work Vallenwood.
I've fixed the file with your changes.
Daniel
Comment #3
(not verified) commented