MyBB Community Forums
[F] Orphaned attachment deletion [C-Imad Jomaa] - 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.4 (https://community.mybb.com/forum-110.html)
+------ Thread: [F] Orphaned attachment deletion [C-Imad Jomaa] (/thread-47269.html)



[F] Orphaned attachment deletion [C-Imad Jomaa] - Michael S. - 03-27-2009

The orphaned attachments search finds attachments that were uploaded over 24 hours ago but not attached to a post. In this case there's a file in the uploads folder and an entry in the database. If you delete such an attachment the file remains on the server (It is found in a second search though because of the missing database entry).

The reason can be found in the file inc/functions_upload.php in the functions remove_attachment() and remove_attachments():
@unlink($mybb->settings['uploadspath']."/".$attachment['attachname']);
if($attachment['thumbnail'])
{
    @unlink($mybb->settings['uploadspath']."/".$attachment['thumbnail']);
}
$mybb->settings['uploadspath'] by default is set to ./uploads. If you call the function from the ACP it tries to delete the file in ROOT/admin/uploads/.

A solution would be to use MYBB_ROOT or to differ like it is done in the function remove_avatars():
if(defined('IN_ADMINCP'))
{
    $avatarpath = '../'.$mybb->settings['avataruploadpath'];
}
else
{
    $avatarpath = $mybb->settings['avataruploadpath'];
}



[F] Orphaned attachment deletion - Ryan Gordon - 03-30-2009

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


RE: [F] Orphaned attachment deletion [C-Imad Jomaa] - Technoman - 04-01-2009

ok so im a bit thick when it comes to understanding instructions, can you explain what i need to do to fix this by going in the admin panel ?

thanks