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

Fixed Failed User Imports

Valhalla

Well-known member
#1
I'm attempting to run the Importer coming from MyBB 1.6.

At the end of the user import stage, I get told "The following users could not be imported due to errors". It then lists about seven users who it was unable to import (I assume due to characters in their username, like commas). But I am not given any option to offer an alternative username.

I saw a similar thread, here, which suggested there should be a text box for me to correct them, but I cannot see this. I don't think there is one in my case (I checked using Inspect Element). The only option, at the end of the list of usernames, is "Import Users".
 

Chris D

XenForo developer
Staff member
#2
Easiest solution is to change the usernames beforehand.

Usernames containing commas in XenForo aren't valid (due to situations where commas are used as a delimiter, e.g. sending a conversation to multiple users).
 

Jake Bunce

XenForo moderator
Staff member
#3
I think you found a bug. Looking at the code I can see a problem which explains why the text field for the username doesn't show in the MyBB importer.

library/XenForo/Importer/MyBb.php

Change the red piece to the word 'failure' instead of 'conflict'.

Code:
	public function stepUsersFailed($start, array $options)
	{
		$sDb = $this->_sourceDb;

		$manual = $this->_session->getExtraData('userFailed');

		if ($manual)
		{
			$users = $this->_sourceDb->fetchAll($this->_getSelectUserSql('users.uid IN (' . $sDb->quote(array_keys($manual)) . ')'));

			$resolve = $this->_controller->getInput()->filterSingle('resolve', XenForo_Input::ARRAY_SIMPLE);
			if ($resolve && !empty($options['shownForm']))
			{
				$this->_session->unsetExtraData('userFailed');
				$this->_resolveUserConflicts($users, $resolve);
			}
			else
			{
				// prevents infinite loop if redirected back to step
				$options['shownForm'] = true;
				$this->_session->setStepInfo(0, $options);

				$failedUsers = array();
				foreach ($users AS $user)
				{
					$failedUsers[$user['uid']] = array(
						'username' => $this->_convertToUtf8($user['username'], true),
						'email' => $this->_convertToUtf8($user['email'], true),
						'message_count' => $user['postnum'],
						'register_date' => $user['regdate'],
						'conflict' => $manual[$user['uid']]
					);
				}

				return $this->_controller->responseView(
					'XenForo_ViewAdmin_Import_FailedUsers', 'import_failed_users', array('users' => $failedUsers)
				);
			}
		}

		return $this->_getNextUserStep();
	}
Then run the import again. That should fix the problem.

Moving to bugs.