Fixed vBulletin 4.x Import: "Username cannot contain a comma"

Affected version
2.0.0 Release Candidate 3


Well-known member
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



Well-known member
I think this error was caused by custom code. Please close this thread. I'll let you know if the error reoccurs. Sorry!


Well-known member
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: