MyBB Community Forums

Full Version: Threads table empty data and update_first_post()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been experiencing intermittent threads which do not have a username in forumdisplay but when you view the thread it has the data.  I looked into this and it appears to have started in MyBB 1.8x only since none of the problems threads were previous to my upgrade.

mybb_threads table has a firspost entry but the UID, USERNAME, and DATELINE are either empty or set 0.  

I found about 111 threads in the past 5 months with uid=0 and dateline=0.  Today I was trying to fix them all with a while query to populate the data from post table using the firstpost pid.  While doing so I found out that the function update_first_post() exists in inc/functions. So basically I just had to do the query for "uid=0 AND dateline=0" and then run update_first_post($results['tid']) to populate the data. Worked perfectly.

So I looked into what triggers the update_first_post() action and inside showthread.php is this:

if($mybb->input['action'] == "thread")
{
 if($thread['firstpost'] == 0)
 {
 update_first_post($tid);
 }


If this can be changed to


if($mybb->input['action'] == "thread")
{
 if($thread['firstpost'] == 0 || $thread['dateline'] == 0)
 {
 update_first_post($tid);
 }


It would pretty much fix this bug.  I can't be sure if the thread entries are a bug strictly for my site due to lag, plugins, or attacks but I do know this code change could fix it and also help anyone who may have this issue.

Can I suggest everyone who has a reasonable size forum please run this query to check if you have any of these bad threads?

SELECT * FROM `mybb_threads` WHERE `uid` = 0 AND `dateline` = 0 ORDER BY `tid` ASC


So this is part bug report and part suggestion to fix potential problems.

Thanks.
Interesting, I have a live large board but I havent seen this issue since v1.8. Anyway would be nice to have a reply from MyBB devs and leave this thread for discussion.
I'd definitely be interested to see what caused the original issue with the data not being populated, but I'm not opposed to a minor change like this if it turns out to be an issue that a couple of people are facing.
(2018-04-16, 05:58 PM)Eldenroot Wrote: [ -> ]Interesting, I have a live large board but I havent seen this issue since v1.8. Anyway would be nice to have a reply from MyBB devs and leave this thread for discussion.


Can you run this query in your MySQL?


SELECT * FROM mybb_threads WHERE dateline = 0 ORDER BY tid ASC

That will show if you have any of these bad threads.

Quote: but I'm not opposed to a minor change like this if it turns out to be an issue that a couple of people are facing.

Yeah, that's what I'm trying to gauge too. Because it honestly could totally be just my site due to lag in MySQL or php-fpm. I have a massive cron job each night that causes double posting and other issues. But with innodb it should just wait and still insert into threads table. Funny part is that the posts table is populated just fine which of course is a much larger table.
I understand adding dateline to the check since firstpost is already there, but IMO none of them should be in there in the first place.

I would suggest to instead add a new moderation tool option to update the first post. Since I have seen this issue happen to me when third party plugins that hook into post creation fail it could be of more help for administrators. We have already done this in the past: adding a new moderation tool option to recount posts.
(2018-04-16, 08:29 PM)Omar G. Wrote: [ -> ]I understand adding dateline to the check since firstpost is already there, but IMO none of them should be in there in the first place.

I would suggest to instead add a new moderation tool option to update the first post. Since I have seen this issue happen to me when third party plugins that hook into post creation fail it could be of more help for administrators. We have already done this in the past: adding a new moderation tool option to recount posts.


Then if you've seen this in the past with a potential plugin conflict then my change to also check for an empty dateline could automatically fix it with simple alteration and almost no overhead.

Currently I just altered my php code to reflect the change I need and will keep a close eye on it.

Absolutely this could be strange behavior from a 1.6x legacy plugin conflicting with 1.8x code. I have more than a few hooks into $post actions. I think this is more about a combination of lag and plugins.

Thanks for the discussion though.
I have access to 2 large boards, 1 is my own with just under 200k posts and the other is a friend's with about 600k posts.

my forum started on mybb 1.8.X:
Showing rows 0 - 0 (1 total, Query took 0.0013 seconds.) [tid: 3251... - 3251...]

my friend's forum, which was converted from vbulletin:
Showing rows 0 - 24 (216 total, Query took 0.0019 seconds.) [tid: 2... - 26...]
Looks to me like the trivial change sugegsted by @labrocca would make sense then since we now know of at least 3 decent sized boards with this issue (Justin has indicated that his board is affected too).
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/3148

Thanks for contributing to MyBB!

Regards,
The MyBB Group
Thank you for fixing in core. Smile