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

Fixed vBulletin 4.x Import: Wrong avatar filenames?

Affected version
2.0.0 Release Candidate 3
#1
I'm trying to import custom user avatars from a vBulletin 4 installation that stores avatars in the file system (i.e. not in the database).

The importer looks for avatar files in the directory "{path}/{filename}" where the filename is taken from the "vb_customavatar" table. But what the "filename" column of the "vb_customavatar" table actually contains seems to be the filename as uploaded by the user. In some cases it can even be empty (don't ask me why :)). The actual filename used by vBulletin 4 is "avatar{userid}_{avatarrevision}.gif".

The following patch seems to be working:

Diff:
diff --git a/xenforo/src/XF/Import/Importer/vBulletin.php b/xenforo/src/XF/Import/Importer/vBulletin.php
--- a/xenforo/src/XF/Import/Importer/vBulletin.php
+++ b/xenforo/src/XF/Import/Importer/vBulletin.php
@@ -1160,8 +1160,8 @@ class vBulletin extends AbstractForumImporter
         $timer = new \XF\Timer($maxTime);

         $users = $this->sourceDb->fetchPairs("
-            SELECT userid, filename
-            FROM {$this->prefix}customavatar
+            SELECT userid, avatarrevision
+            FROM {$this->prefix}user
             WHERE userid > ? AND userid <= ?
             ORDER BY userid
             LIMIT {$limit}
@@ -1177,7 +1177,7 @@ class vBulletin extends AbstractForumImporter

         $this->lookup('user', array_keys($users));

-        foreach ($users AS $userId => $fileName)
+        foreach ($users AS $userId => $avatarRevision)
         {
             $state->startAfter = $userId;

@@ -1186,12 +1186,17 @@ class vBulletin extends AbstractForumImporter
                 continue;
             }

+            if (!$avatarRevision)
+            {
+                continue;
+            }
+
             $avatarTempFile = \XF\Util\File::getTempFile();

             if ($stepConfig['path'])
             {
                 // avatars stored as files
-                $avatarOrigFile = "{$stepConfig['path']}/{$fileName}";
+                $avatarOrigFile = "{$stepConfig['path']}/avatar{$userId}_{$avatarRevision}.gif";

                 if (!file_exists($avatarOrigFile))
                 {
I'm now getting some "libpng warning: iCCP: known incorrect sRGB profile" warnings and at 7% an error "Failed to save image to temporary file; image may be corrupt or check internal_data/data permissions" but these issues seem to be independent.
 

Kier

XenForo Developer
Staff member
#2
You're right - the use of customavatar.filename is wrong for vB3 and vB4 - I've adjusted the code to compensate now.