MyBB Community Forums
[Rejected] [Fix included] Bug in functions_forumlist.php - Printable Version

+- MyBB Community Forums (
+-- Forum: Development (
+--- Forum: MyBB 1.8 Development (
+---- Forum: 1.8 Bugs and Issues (
+----- Forum: Rejected (
+----- Thread: [Rejected] [Fix included] Bug in functions_forumlist.php (/thread-203035.html)

[Fix included] Bug in functions_forumlist.php - Schrotti - 2016-09-27

Look at this code section:
            //$forum_read = $mybb->user['lastvisit'];

         // If the lastpost is greater than the last visit and is greater than the forum read date, we have a new post
        if($lastpost['lastpost'] > $forum_read && $lastpost['lastpost'] != 0)

The commented-out code clearly indicates that the MyBB devs were aware that here is something grossly afoul.
Just look at the corrected if statement line to understand what was the error.
        if($lastpost['lastpost'] > $forum_read && $lastpost['lastpost'] && $forum['posts'])

It is important to be aware that the forum cache is sometimes wrong.
In these cases $lastpost['lastpost'] just is an empty string. Obviously then comparing with a number "zero" will not yield the expected result.   Toungue
The correct way to do this is just to do a boolean check (see more information about this topic in the first user-contributed note in this php documentation page)

The comparison ("does this forum contain posts at all?") I added works around this cache bug which occurs under special circumstances on forums that do not yet have posts.
(A better solution would ofc be to fix the cache problem. But this is quite complex. It would be pointless to invest time in this as MyBB 1.8 series has already almost reached the state of abandonware.)

RE: [Fix included] Bug in functions_forumlist.php - StefanT - 2016-09-28

Can you please provide steps to reproduce the issue?

RE: [Fix included] Bug in functions_forumlist.php - Eldenroot - 2018-06-03

Maybe this one could cause the issue which was reported many times but without a proper steps how to reproduce. Would be nice to keep and eye on this and make a complex proper fix for 1.9.