vBulletin 4: Attachment import is messed up

Kirby

Well-known member
Affected version
1.6.1
XFI\Import\Importer\vBulletin4::getAttachmentsForFileDataIds

PHP:
protected function getAttachmentsForFileDataIds(array $fileDataIds, $contentIdKey = 'postid')
{
    $fileDataIds = $this->sourceDb->quote($fileDataIds);

    return $this->sourceDb->fetchAll("
        SELECT
            attachment.attachmentid, attachment.filename, attachment.userid,
            attachment.dateline, attachment.counter,
            attachment.contentid AS {$contentIdKey},
            filedata.filedataid,
            filedata.userid AS filedata_userid
        FROM attachment AS
            attachment
        INNER JOIN filedata AS
            filedata ON (filedata.filedataid = attachment.filedataid)
        WHERE filedata.filedataid IN({$fileDataIds})
        ORDER BY filedata.filedataid
    ");
}

This method gets all attachments for the given $fileDataIds and assumes that all those attachments belong to the currently processed content type (like a forum post).
In vBulletin 4 one filedataid can be used by multiple attachments even from multiple content types.

So if for example one filedataid is used by a forum post, an album image and a blog entry this code will treat the contentid of all attachments as a postid and those might import attachments attached to wrong content.

This can quite seriously mess up imported content and pose privacy issues so should be fixed ASAP.

Suggested Fix
Pass the contenttype that is currently processed to this method and only query attachments for this content type.

Related Issues
 
Back
Top Bottom