Fixed Importing From vB 4.2.4

hIBEES

Active member
Step 3 get this error... importer 1.0.1a

ErrorException: [E_WARNING] htmlspecialchars_decode() expects parameter 1 to be string, array given in src/addons/XFI/Import/Importer/vBulletin.php at line 1326

XF::handlePhpError()
htmlspecialchars_decode() in src/addons/XFI/Import/Importer/vBulletin.php at line 1326
XFI\Import\Importer\vBulletin->mapUserFields() in src/addons/XFI/Import/Importer/vBulletin.php at line 1177
XFI\Import\Importer\vBulletin->setupImportUser() in src/addons/XFI/Import/Importer/vBulletin.php at line 1008
XFI\Import\Importer\vBulletin->stepUsers() in src/XF/Import/Runner.php at line 160
XF\Import\Runner->runStep() in src/XF/Import/Runner.php at line 74
XF\Import\Runner->run() in src/XF/Admin/Controller/Import.php at line 232
XF\Admin\Controller\Import->actionRun() in src/XF/Mvc/Dispatcher.php at line 249
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 89
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 41
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1931
XF\App->run() in src/XF.php at line 328
XF::runApp() in admin.php at line 13
 
Confirmed.

src/addons/XFI/Import/Importer/vBulletin.php

The mapUserFields() function doesn't correctly handle multiple choice fields where $fieldValue is an array.

I was able to fix this by adding the red code:

Rich (BB code):
protected function mapUserFields(array $user, array $profileFieldChoices)
	{
		$fieldValues = [];

		foreach ($this->typeMap('user_field') AS $fieldId => $newFieldId)
		{
			$fieldName = 'field' . $fieldId;

			if ($user[$fieldName] !== '')
			{
				if (array_key_exists($fieldId, $profileFieldChoices))
				{
					// choices

					$fieldInfo = $profileFieldChoices[$fieldId];

					if ($fieldInfo['multiple'])
					{
						// multiple choice
						$fieldValue = [];

						foreach ($fieldInfo['choices'] AS $bitValue => $stringValue)
						{
							if ($user[$fieldName] & $bitValue)
							{
								$fieldValue[$stringValue] = $stringValue;
							}
						}
					}
					else if (array_key_exists($user[$fieldName], $fieldInfo['choices']))
					{
						$fieldValue = $fieldInfo['choices'][$user[$fieldName]];
					}
				}
				else
				{
					// freeform input

					$fieldValue = $user[$fieldName];
				}

				if (!empty($fieldValue))
				{
					if (is_array($fieldValue))
					{
						$fieldValues[$newFieldId] = array();
						foreach ($fieldValue AS $key => $value)
						{
							$fieldValues[$newFieldId][$key] = htmlspecialchars_decode($value);
						}
					}
					else
					{
						$fieldValues[$newFieldId] = htmlspecialchars_decode($fieldValue);
					}
				}
			}
		}

		return $fieldValues;
	}
 
Top Bottom