MyBB Community Forums
[F] Merge posts - attachment(s) problem [R] [C-Michael83] - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Community Archive (https://community.mybb.com/forum-106.html)
+--- Forum: Archived Forums (https://community.mybb.com/forum-143.html)
+---- Forum: Archived Development and Support (https://community.mybb.com/forum-155.html)
+----- Forum: Archived Bug Reports (https://community.mybb.com/forum-74.html)
+------ Forum: MyBB 1.4.2 (https://community.mybb.com/forum-100.html)
+------ Thread: [F] Merge posts - attachment(s) problem [R] [C-Michael83] (/thread-39829.html)



[F] Merge posts - attachment(s) problem [R] [C-Michael83] - Michael S. - 2008-10-30

If you merge two posts and the first of them contains an attachment is is not shown anymore after the merge. The problem is that the attachmentcount is set to 0 in the threads table.

It's working correctly if the second post contains an attachment.

Steps to reproduce:
1. Create a new thread and attach a file to your post.
2. Create a reply.
3. Merge the two posts.


RE: Merge posts - attachment(s) problem [R] - Ryan Gordon - 2008-10-30

Hmm, shouldn't the attachmentcount be incremented to 1 when you attach the attachment to your first post then?


RE: Merge posts - attachment(s) problem [R] - Michael S. - 2008-10-30

It's 1 before the merge. The reason for the change can be found in the function merge_posts():
$query2 = $db->simple_select("attachments", "COUNT(aid) as count", "pid IN({$pidin}) AND pid != '{$masterpid}' AND visible='1'");
$attachment_count = $db->fetch_field($query2, "count");

$db->update_query("threads", array("attachmentcount" => $attachment_count), "tid = '{$mastertid}'");
$masterpid is the ID of the first post and because of that the query returns 0.


RE: Merge posts - attachment(s) problem [R] - Ryan Gordon - 2008-10-30

I'll have to look at the logs, but I'm pretty sure that was put in place to fix another bug for some reason


RE: Merge posts - attachment(s) problem [R] - Ryan Gordon - 2008-10-30

Does this work? In inc/class_moderation.php find:

$query2 = $db->simple_select("attachments", "COUNT(aid) as count", "pid IN({$pidin}) AND pid != '{$masterpid}' AND visible='1'");
$attachment_count = $db->fetch_field($query2, "count");

and replace with

$query2 = $db->simple_select("attachments", "COUNT(aid) as count", "pid IN({$pidin}) AND visible='1'");
$attachment_count = $db->fetch_field($query2, "count");

I don't see why we wouldn't count the first post in the amount of attachments


RE: Merge posts - attachment(s) problem [R] - Michael S. - 2008-10-30

I tested several cases and I could not find any problem. The fix is working fine.


[F] Merge posts - attachment(s) problem [R] - Ryan Gordon - 2008-10-30

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