• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 SMF importer: no avatars and only some attachments imported


Recently I tried to import the data from my forum (SMF 2.0.9) to Xenforo 1.4.6.

Apparently everything went smoothly, but after a more detailed inspection I found some issues:

  • Some attachments are not imported. There are two differents folders and it appears those with "id_folder=1" are ignored, whereas the others with "id_folder=2" look fine.
  • There are no avatars in the XF forum, so it seems they aren't imported.

Is someone else having similar problems?

Unfortunately I don't have time to look more seriously into this, as the little time I had I used it to improvise a ****ty importer Aeva Media -> XF Media Gallery (but hey, it works for me), so I can't provide much more information, but if you need anything please tell me.

Thank you.

Moderator comment: Do not attempt to bypass the censor.

Chris D

XenForo developer
Staff member
The importer asks you to define the file locations of attachments and avatars. Where there is more than one folder configured in SMF, you should be presented with more than one file location to configure when the importer is set up.

If you have a pre-import back up and the size is relatively small it may be interesting for us to take a look at this to make sure it is working as we would expect and also work out why some were missed.

If this is something you can provide, please open a ticket and we will look into it.

It's worth noting, however, if the file locations provided weren't the correct locations for the attachments then that could be one explanation. The importer config does check to make sure the folders exist, but if the files weren't in there or not readable for whatever reason then those attachments would be skipped.
I did more research on this on a new folder, with correct permissions, etc

It looks like the older attachments with id_folder=1 have an empty "file_hash" value, which is used in $filePath, so it fails at checking the existence of the file.

Reading another thread, it seems that I should look at "getLegacyAttachmentFilename" to solve this, unless there's a possibility of getting an "official try-this fix", in which case I'll wait :)

Chris D

XenForo developer
Staff member
It looks like there is code to handle this for Avatars, but no code to handle this for Attachments... I'd have said your avatars should have imported... but to ensure the attachments are imported I think you need to find:

$filePath= "$attachmentPath/$attachment[id_attach]_$attachment[file_hash]";
And change it to:

if ($attachment['file_hash'] === '')
    $filePath = "$attachmentPath/$attachment[filename]";
    $filePath = "$attachmentPath/$attachment[id_attach]_$attachment[file_hash]";
I was tempted to do that, but first I checked with one of the filenames and it didn't exist. It seems they are "hashed" too, hence my idea of looking at getLegacyAttachmentFilename.

Example: filename=diamond1.jpg -> filepath=attachments/59028_diamond1_jpg7454555c1d946706d0aa039af12bf214

About the avatars, it appears that some of them are imported, or at least they are on the "data" folder, so it seems fine. When I complete this latest import step, I'll see if they have been assigned to the proper user.

UPDATE: I integrated getLegacyAttachmentFilename plus your suggested modification into the importer and things seem to be working, we'll see...
Last edited: