Delete Video File from xf_attachment

Bugfix

Member
Hello!

I have a short question about attachments:
I uploaded a video in XF MG1.1 and after that, I deleted the user.

Question: When does the file be deleted? Or does it even be deleted?
I saw that the hourly cron only deletes images from xf_attachment with flag unassociated = 1.
Question: When does the file get the flag unassociated = 1 instead of unassociated = 0?
Is there also a cronjob for this? I did not find anything in XenForo_CronEntry_CleanUp.

Thank you,
Harald
 
Deleted the user or deleted the media item?

Deleting a user does not delete their content.

The unassociated flag gets set when the content is permanently deleted.

The hourly cron handles the deletion (it is content agnostic do it doesn't matter whether it's an image or video in the gallery a file in the resource manager or an image attached to a post).
 
Deleted the user or deleted the media item?
Deleted the user.
Deleting a user does not delete their content.
Sorry - there was missing an info: I have an addon to delete the content (but i only deleted it from xengallery_media).
The unassociated flag gets set when the content is permanently deleted.
That was the info I was looking for - so I have to manually set the flag unassociated = 1 in my addon when I delete a user :)

Thank you!
 
That was the info I was looking for - so I have to manually set the flag unassociated = 1 in my addon when I delete a user :)
This happens automatically if the content is properly deleted using the Media DataWriter.
 
One question:
Is it enough to use the XenGallery_DataWriter_Album?
PHP:
        $userId = $this->get('user_id');
        $deletedUserId= $db->quote($userId);
        $albums = $db->fetchAll('
            SELECT *
            FROM `xengallery_album`
            WHERE `album_user_id` = ?
        ', $deletedUserId);
        foreach ($albums AS $album)
        {
            $albumWriter = XenForo_DataWriter::create('XenGallery_DataWriter_Album');
            $albumWriter ->setExistingData($album);
            $albumWriter ->delete();
        }
Because in _preDelete the media is deleted anyway and every media is in an album - right?
 
Top Bottom