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

Fixed [SMF] Import - Some avatars not imported (when they should)

#1
For some old SMF forums, the avatars used a different file format not using the hash.

I changed in my local impotrt cariation, so if you want to implement the fix is something like (only change is 1 line before the break)...

In SMF.php change:
PHP:
                    // Attachment directory
                    case 0:

                        if (!isset($options['attachmentPaths'][$avatar['id_folder']]))
                        {
                            // Going to have to assume that it was a single attachment directory environment.
                            $attachmentPath = $options['attachmentPaths'][0];
                        }
                        else
                        {
                            $attachmentPath = $options['attachmentPaths'][$avatar['id_folder']];
                        }


                        $filePath = "$attachmentPath/$avatar[id_attach]_$avatar[file_hash]";
                        break;
to this:
PHP:
                    // Attachment directory
                    case 0:

                        if (!isset($options['attachmentPaths'][$avatar['id_folder']]))
                        {
                            // Going to have to assume that it was a single attachment directory environment.
                            $attachmentPath = $options['attachmentPaths'][0];
                        }
                        else
                        {
                            $attachmentPath = $options['attachmentPaths'][$avatar['id_folder']];
                        }

                        if (trim($avatar['file_hash']) != '')
                        {
                            $filePath = "$attachmentPath/$avatar[id_attach]_$avatar[file_hash]";
                        }
                        else
                        {
                            $filePath = "$attachmentPath/$avatar[filename]";
                        }
                        break;
 
#3
Sadly, I don't remember, just my forum is pretty old.

I *think* it may changed because from legible files changed to hash, but i never read the changelogs. (I may be mistaken and could be only happen to me, but I read another user had some problems with avatars, dunno).

My forum is from YaBB SE -> SMF 1.x -> SMF 2.x

Just wanted to share the code if you want to use it, if not, well, is ok too :)
 

Chris D

XenForo developer
Staff member
#4
I've located the relevant function that handles legacy attachment and avatar paths in SMF and I'm not entirely sure making changes here is entirely the right thing to do, but it doesn't hurt so we've made the suggested change.
 

Chris D

XenForo developer
Staff member
#6
Subs.php function: getLegacyAttachmentFilename.

You asked about the ETA of this. It will be released with XF 1.4.4 but no ETA yet.
 
#7
Sorry if this is considered a necro bump, considering the thread is from 2014. But, I'm having the same issues. Importing avatars. I honestly couldn't even care about attatchments/avatars at this point. I just want the rest of SMF.


I can't manage to get past this screen.. :(
 

Chris D

XenForo developer
Staff member
#10
Sorry I missed this.

Actually it may have been better to post this as a new bug, as it's not really related to this thread.

Give this code change a try:

Find file: library/XenForo/Importer/SMF.php

Around line 50 find:
PHP:
if ($attachPaths)
{
    $path = array($attachPaths);
}
Change to:
PHP:
if ($attachPaths)
{
    $path = array($attachPaths);
}
else
{
    $path = array('');
}
That should now account for all cases, and if it can't automatically detect a file path from your SMF install then it should display an empty field. You will then need to populate that with the correct, full path to your SMF attachments.
 
#12
Sorry I missed this.

Actually it may have been better to post this as a new bug, as it's not really related to this thread.

Give this code change a try:

Find file: library/XenForo/Importer/SMF.php

Around line 50 find:
PHP:
if ($attachPaths)
{
    $path = array($attachPaths);
}
Change to:
PHP:
if ($attachPaths)
{
    $path = array($attachPaths);
}
else
{
    $path = array('');
}
That should now account for all cases, and if it can't automatically detect a file path from your SMF install then it should display an empty field. You will then need to populate that with the correct, full path to your SMF attachments.
I don't have any attachments or avatars, I'm just looking to get past this step so I can import the rest of the database.

/Edit: I just created some void directories on my web server and, it let me continue. Thanks :)
 
Last edited:

Chris D

XenForo developer
Staff member
#13
You'll still need to follow the instructions above to get past this config step. There should be two fields after applying the code edits, one for attachments and one for avatars. You will then need to specify a valid path. It has to exist, but it doesn't have to have any data in.

After that you can start the import.
 
#14
You'll still need to follow the instructions above to get past this config step. There should be two fields after applying the code edits, one for attachments and one for avatars. You will then need to specify a valid path. It has to exist, but it doesn't have to have any data in.

After that you can start the import.
I'm all imported now, Thanks for the help.