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

Affected version
1.2.3

Kirby

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

DChapman

Member
Thanks for reporting this. We spent three days fighting the importer thinking the issue was on our end until I came across this thread.
 
Top