• 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: "Username cannot contain a comma"

Affected version
2.0.0 Release Candidate 3
#1
There is code in XF/Import/Importer/AbstractImporter/Helper.php that is supposed to handle this case (it automatically replaces actual commas with the string "comma"). But it isn't working because prior to that a LogicException is thrown when running "php cmd.php xf:import".

Code:
Starting import from vBulletin 4.x (Beta)...
- [...]
- Step 3 of 10: Users - x%

[LogicException]               
  Username cannot contain a comma

xf:import
 
#3
After all, this is a bug in the importer. :)

If the username that XenForo automatically generates by stripping commas does not yet exist then everything is fine. But if it already exists then the importer appends a number and tries again. The bug is that it appends a number to the original username and not to the stripped username. Therefore the resulting username still contains a comma which then causes the LogicException.

Diff:
diff --git a/xenforo/src/XF/Import/Helper.php b/xenforo/src/XF/Import/Helper.php
--- a/xenforo/src/XF/Import/Helper.php
+++ b/xenforo/src/XF/Import/Helper.php
@@ -94,7 +94,7 @@ class Helper
                 do
                 {
                     $i++;
-                    $testUsername = $originalUsername . $i;
+                    $testUsername = $user->username . $i;

                     $hasConflict = $db->fetchOne("SELECT user_id FROM xf_user WHERE username = ?", $testUsername);
                 }
 
Last edited by a moderator: