MyBB Community Forums

Full Version: [D] ModCP attachment moderation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When trying to moderate (i.e. ignore/delete/approve) unapproved attachments in the ModCP (modcp.php?action=modqueue), I get the following error:

Quote:SQL Error:
1054 - Unknown column 'p.tid' in 'on clause'
Query:
SELECT a.pid, a.aid FROM attachments a LEFT JOIN threads t ON (t.tid=p.tid) WHERE aid IN (3,4,5,6,8,11)

Solution:
Replace the query starting on line 1197 with this:
PHP Code:
$query $db->query("
            SELECT a.pid, a.aid
            FROM  "
.TABLE_PREFIX."attachments a
            LEFT JOIN "
.TABLE_PREFIX."posts p ON (a.pid=p.pid)
            LEFT JOIN "
.TABLE_PREFIX."threads t ON (t.tid=p.tid)
            WHERE aid IN ("
.implode(","array_map("intval"array_keys($mybb->input['attachments'])))."){$tflist}
        "
); 
Attachments and threads don't have any connections. It's attachments and posts that are connected...

Solution
Replace...

PHP Code:
        $query $db->query("
            SELECT a.pid, a.aid
            FROM  "
.TABLE_PREFIX."attachments a
            LEFT JOIN "
.TABLE_PREFIX."threads t ON (t.tid=p.tid)
            WHERE aid IN ("
.implode(","array_map("intval"array_keys($mybb->input['attachments'])))."){$flist}
        "
); 

...with...

PHP Code:
$query $db->query("
            SELECT a.pid, a.aid
            FROM  "
.TABLE_PREFIX."attachments a
            LEFT JOIN "
.TABLE_PREFIX."posts p ON (a.pid=p.pid)
            WHERE aid IN ("
.implode(","array_map("intval"array_keys($mybb->input['attachments'])))."){$flist}
        "
); 
Reference URL's