Fixed vBulletin: Endless loop in \XFI\Import\Importer\vBulletin::stepForums()

Kirby

Well-known member
Affected version
1.2.3
\XFI\Import\Importer\vBulletin::stepForums does call getForums() do get a list of forums ordered by parentid, forumid:

PHP:
protected function getForums(array $stepConfig)
{
    return $this->sourceDb->fetchAllKeyed("
        SELECT * FROM forum ORDER BY parentid, forumid
    ", 'forumid');
}

and afterwards processes the array, starting with the array key of the first element as $oldParentId.
Due to primary the sorting by parentid this will be -1.

PHP:
$oldParentId = array_keys($forumTree)[0];

while (!empty($forumTree))
{
    $state->imported += $this->importNodeTree($forumTree, $forumPermissions, $oldParentId);
}

However, if the source database does contain a single forum that has a non-existing parentid (which is an inconsistent source DB state), this results in an endless loop as after processing $forumTree this entry will still be in the array and never does get processed as $oldParentid never does get set to the remaning, non-existent ID.

This bug was apparently introduced by the fix for https://xenforo.com/community/threads/vbulletin-node-tree-messed-up-after-import.161000/ as previous versions die have the assignment for $oldParentId inside the loop.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (1.2.5).

Change log:
Fix endless loop caused by inconsistent source data when importing forums from vBulletin.
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom