XF 2.2 Import from SMF2.1 - Attachments issues/questions


New member
Hi, I'm working on an import from SMF2.1. Currently I am using a very small test install to check before moving on to the full forum.

I had/have a couple of issues with the attachments. I will file a bug report when I have the second figured out a bit further.

I am using Xenforo 2.2.15. The SMF install is the latest, 2.1.4.

1. The attachment file names in SMF has a ".dat" prefix. To work around this I changed line 1537 of addons/XFI/Import/Importer/SMF.php to add the extension:
$attachPath = $this->getAttachmentFilename($attachment) . '.dat';
[Updated: this would be better fixed in the getAttachmentFilename function, I will look into that.]

2. Embedded attachments don't have the BBCode converted. In the SMF BBcode there is e.g.
[attach id=4]_MG_4380.jpg[/attach]
For Xenforo I believe this should be converted to
[ATTACH type="full" alt="_MG_4380.jpg"]4[/ATTACH]

In addons/XFI/Import/Importer/SMF.php I see there is call to rewriteEmbeddedAttachments:
$import->setContainerCallback([$this, 'rewriteEmbeddedAttachments']);

This function, in XF/Import/Importer/AbstractImporter.php has the code:
$message = preg_replace_callback(
                                function ($match) use ($attachment, $container) ....

It looks to me like this can not match the BBcode in the SMF post, and that its purpose is only to convert existing XenForo BBCode to a different attachment ID. Would that be right?

I suppose I can work around #2 by preprocessing the SQL dump from the SMF database before importing to the database for migration to Xenforo, but I thought I should first ask if there's better way. Thank you for any thoughts on this :)
Top Bottom