1. 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)

Discussion in 'Resolved Bug Reports' started by Omar Bazavilvazo, Dec 23, 2014.

  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;
     
    Chris D likes this.
  2. Chris D

    Chris D XenForo Developer Staff Member

    What version of SMF started using the file_hash?
     
  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 :)
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    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.
     
  5. Sweet!

    I think is additive and won't break any functionality from what you have.

    Just curious... Where is the legacy code?
     
    Last edited: Dec 30, 2014
  6. Chris D

    Chris D XenForo Developer Staff Member

    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. BlackDawn187

    BlackDawn187 Member

    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.

    [​IMG]

    I can't manage to get past this screen.. :(
     
  8. Are you using 1.4.4?
     
  9. BlackDawn187

    BlackDawn187 Member

    Yep I sure am
     
  10. Chris D

    Chris D XenForo Developer Staff Member

    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.
     
  11. Hmm... That's why I never got that screen then :)
     
  12. BlackDawn187

    BlackDawn187 Member

    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: Feb 4, 2015
  13. Chris D

    Chris D XenForo Developer Staff Member

    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. BlackDawn187

    BlackDawn187 Member

    I'm all imported now, Thanks for the help.
     
    Chris D likes this.

Share This Page