MyBB Community Forums

Full Version: [F] Approve thread with attachment(s)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If a forum is configured that new threads need moderation and you approve a new thread that contains an attachment the attachment is missing in the post. There's no problem with moderating new posts with attachments.

Steps to reproduce:
1. Coose in the settings of a forum to moderate new threads.
2. Post a new thread with an attachment in this forum as a normal user.
3. Approve this thread as a moderator or admin. The attachment is not shown in the post.
If you have time can you do a bit more debugging:

When you post the thread (and it automatically is unapproved), is the attachment unapproved too?

When you approve the thread, are you saying the attachment completely disappears (i.e. deleted) or just unapproved? Is the attachment still in the file system and the database?

Thanks.
(2008-08-21, 07:56 PM)DennisTT Wrote: [ -> ]When you post the thread (and it automatically is unapproved), is the attachment unapproved too?
I think you mean the visible column in the database? thread = 0, attachment = 1. But in the thread table in the column attachmentcount it says 0 although I added a file.
(2008-08-21, 07:56 PM)DennisTT Wrote: [ -> ]When you approve the thread, are you saying the attachment completely disappears (i.e. deleted) or just unapproved? Is the attachment still in the file system and the database?
The attachment is still in the database and in the filesystem. It's just not shown in the post. After approving the thread attachmentcount is still set to 0 in the database.
I just changed 0 to 1 in the column attachmentcount and now the attachment is shown. The problem is that the field attachmentcount is only updated if a thread is visible. See inc/datahandlers/post.php:
if($visible == 1)
{
	$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'");
	$attachmentcount = $db->fetch_field($query, "attachmentcount");
	if($attachmentcount > 0)
	{
		update_thread_counters($this->tid, array("attachmentcount" => "+{$attachmentcount}"));
	}

	update_thread_data($this->tid);
	update_forum_counters($thread['fid'], array("threads" => "+1", "posts" => "+1"));
}
During the approval there is no update of the attachmentcount and because of that it is 0.
Hm, we need to not rely on a count of 0 attachments being an actual representation of the number of attachments we have in that thread. That number is the number of approved attachments then.
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.