Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] Archive - SQL bug fetching attachments/posts with abandoned thread [C-StefanT]
MyBB 1.4.6

Error log contains:
        <friendly_type>MyBB SQL Error</friendly_type>
        <message>SQL Error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
Query: SELECT * FROM mybb_attachments WHERE pid IN ()</message>
while accessing "abandoned" threads in archive mode. With "abandoned" I mean threads which exists in mybb_threads table but do not have any posts in mybb_posts - probably because of MyBB or DB error (e.g. restarting DB server, timeout, race condition etc.).

Simple patch:
.diff   710_mybb_1.4.6_index_sql_attachments_pids_bug.diff (Size: 422 bytes / Downloads: 551)
- So... Maybe you shouldn't have hacked it.
- And why don't you try not breathing. Hurts, dunnit. (
Nicely found...! Patch seems to fix the problem...
Personally I'd favor not running the query at all in there is nothing to look up, but the fix does work fine.
So, really, a fix could be:

$pids = implode(",", $pids);

	// Build attachments cache
	$query = $db->simple_select("attachments", "*", "pid IN ({$pids})");
	while($attachment = $db->fetch_array($query))
		$acache[$attachment['pid']][$attachment['aid']] = $attachment;
Yes, that sounds better
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group

Forum Jump:

Users browsing this thread: 1 Guest(s)