XFI vBulletin: Duplicate key error when importing custom BB codes

Kirby

Well-known member
Affected version
1.5.0
Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry 'Spoiler' for key 'PRIMARY' src/XF/Db/AbstractStatement.php:228
Generated by: Unknown account Jul 6, 2021 at 10:51 AM
Stack trace
INSERT  INTO `xf_bb_code` (`bb_code_id`, `bb_code_mode`, `has_option`, `replace_html`, `replace_html_email`, `replace_text`, `callback_class`, `callback_method`, `option_regex`, `trim_lines_after`, `plain_children`, `disable_smilies`, `disable_nl2br`, `disable_autolink`, `allow_empty`, `allow_signature`, `editor_icon_type`, `editor_icon_value`, `active`, `addon_id`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL query err...', 1062, '23000')
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1062, '23000')
#2 src/XF/Db/AbstractAdapter.php(94): XF\Db\Mysqli\Statement->execute()
#3 src/XF/Db/AbstractAdapter.php(221): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Import/Data/EntityEmulator.php(327): XF\Db\AbstractAdapter->insert('xf_bb_code', Array)
#5 src/XF/Import/Data/AbstractEmulatedData.php(71): XF\Import\Data\EntityEmulator->insert(19, Object(XF\Db\Mysqli\Adapter))
#6 src/XF/Import/Data/AbstractData.php(127): XF\Import\Data\AbstractEmulatedData->write(19)
#7 src/addons/XFI/Import/Importer/vBulletin.php(1850): XF\Import\Data\AbstractData->save(19)
#8 src/XF/Import/Runner.php(242): XFI\Import\Importer\vBulletin->stepCustomBbCodes(Object(XF\Import\StepState), Array, 8)
#9 src/XF/Import/Runner.php(59): XF\Import\Runner->runStep('customBbCodes', Object(XF\Import\StepState), 8)
#10 src/XF/Import/Runner.php(152): XF\Import\Runner->run()
#11 src/XF/Import/ParallelRunner.php(40): XF\Import\Runner->runUntilCompleteInternal(Object(XF\Import\Manager), Object(Closure))
#12 src/XF/Import/Runner.php(128): XF\Import\ParallelRunner->runUntilCompleteInternal(Object(XF\Import\Manager), Object(Closure))
#13 src/XF/Cli/Command/Import.php(155): XF\Import\Runner->runUntilComplete(Object(XF\Import\Manager), Object(Closure))
#14 src/vendor/symfony/console/Command/Command.php(255): XF\Cli\Command\Import->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 src/vendor/symfony/console/Application.php(992): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 src/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(XF\Cli\Command\Import), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 src/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 src/XF/Cli/Runner.php(109): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 cmd.php(15): XF\Cli\Runner->run()
#20 {main}

This error occured because the source database had Spoiler and spoiler.
Normally this should not happen, though I think even if it does happen the importer should not stop with such an error.
 
Last edited:
I am afraid whether Spoiler is not a built-in function among official vB3 releases.

The error you are facing now is because that XenForo already supports spoiler tag and it only considered (at this moment) importing data from official vanilla vB3 instances.
 
I am afraid whether Spoiler is not a built-in function among official vB3 releases.
Yes, of course - it was a custom BB code (actually two, see below) and the importer can import custom BB codes.

The error you are facing now is because that XenForo already supports spoiler tag and it only considered (at this moment) importing data from official vanilla vB3 instances.
Nope. Importing a custom BB code with a tag that is already implemented as a hardcoded tag in the XenForo BB code renderer is not a problem, this does work just fine and would override the native code - you can test this by creating a custom BB code spoiler.

The problem did occur because the source DB had spoiler and Spoiler (I have no idea why this was even possible with vBulletin, doesn't make sense ^.^) and the importer doesn't handle this conflict - this is was this bug report is about.

So it is completely unrelated to wether vBulletin had built-in support for a certain BB code nor not.
 
Top Bottom