MyBB Community Forums

Full Version: [F] MyBB 1.4 Threadview Attachments
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Browsers: Opera 9.27 and 9.5, IE7, Firefox 3

The paper clip on the threadview displays the wrong number of attachments and starting a thread with an attachment and then removing it over the User-CP, the paper clip shows, that there is an attachment while there is no one.
It seem to be because of this:

$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'");
			$attachmentcount = $db->fetch_field($query, "attachmentcount");

			$thread_update['attachmentcount'] = "+{$attachmentcount}";

			// Update forum count
			update_thread_counters($post['tid'], $thread_update);

It counts all of the attachments in the posts and updates the attachment count.

This however can be a problem if we're updating the post, we'll be adding attachments that were already added to the count, therefore causing the invalid count.
One solution I can think of is:

1) Adding a tid column for attachments
2) Recounting all of the attachments in the thread, but that would sort of defeat some of the purpose of the counter system.
(2008-06-11, 09:47 PM)Tikitiki Wrote: [ -> ]
$query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'");
			$attachmentcount = $db->fetch_field($query, "attachmentcount");

			$thread_update['attachmentcount'] = "+{$attachmentcount}";

			// Update forum count
			update_thread_counters($post['tid'], $thread_update);

Within which php file is this code processed forumdisplay.php, newreply.php or editpost.php ?
None, it's 1.4 code which is not released to the public.
(2008-06-11, 11:56 PM)Tikitiki Wrote: [ -> ]None, it's 1.4 code which is not released to the public.

Yes, i know, but MyBB 1.4 have although a newreply.php...

I just wanted to know, at which time is the code processed. If the browser is open Mybb 1.4-forumdisplay or when a user is writing a post or editing a post.

If the code above is processed when a user is writing or editing a post, then it could be possible the update the attachmentcount by the number of attachments, which is show on the editor.

If the code above is processed in Mybb1.4-forumdisplay, then I do not understand this part:

$thread_update['attachmentcount'] = "+{$attachmentcount}";

i think, that there should not be a "+".
That's not at all how it works. I'm sorry I posted that snippet of code >.>


Anyway, I've managed to come up with a fix.
(2008-06-12, 12:37 AM)Tikitiki Wrote: [ -> ]That's not at all how it works.

I thought as much! But my mind was caught in "Maybe I could help".

(2008-06-12, 12:37 AM)Tikitiki Wrote: [ -> ]Anyway, I've managed to come up with a fix.

Smile