[Rejected] [Fix included] Bug in functions_forumlist.php
#1
Look at this code section:
        //if(!$forum_read)
        //{
            //$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.)
Reply
#2
Can you please provide steps to reproduce the issue?
[Image: banner.png]
Reply
#3
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.
[MyBB 1.8 Czech translation] [MyBB 1.8 plugins]: Prune old PMs + optimize DB plugin --- Thank you/like system
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)