• 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
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".

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

  Username cannot contain a comma

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 --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
-                    $testUsername = $originalUsername . $i;
+                    $testUsername = $user->username . $i;

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