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

Error log contains:
<error>
        <dateline>1244532827</dateline>
        <script></script>
        <line>0</line>
        <type>20</type>
        <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>
</error>
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)
www.kozik.net.pl
- So... Maybe you shouldn't have hacked it.
- And why don't you try not breathing. Hurts, dunnit. (userfriendly.org)
#2
Nicely found...! Patch seems to fix the problem...
#3
Personally I'd favor not running the query at all in there is nothing to look up, but the fix does work fine.
#4
So, really, a fix could be:

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

if($pids)
{
	// Build attachments cache
	$query = $db->simple_select("attachments", "*", "pid IN ({$pids})");
	while($attachment = $db->fetch_array($query))
	{
		$acache[$attachment['pid']][$attachment['aid']] = $attachment;
	}
}
#5
Yes, that sounds better
#6
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)