Fixed vBGallery importer fails with database error when importing ratings

Affected version
2.1.8

Kirby

Well-known member
Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry 'xfmg_media-122067-224099' for key 'content_type_id_user_id' src/XF/Db/AbstractStatement.php:228
Generiert durch: Unbekanntes Benutzerkonto 21. Juli 2020 um 16:18 Uhr
Stracktrace
INSERT  INTO `xf_mg_rating` (`rating_id`, `content_id`, `content_type`, `user_id`, `username`, `rating`, `rating_date`) 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(218): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Import/Data/EntityEmulator.php(326): XF\Db\AbstractAdapter->insert('xf_mg_rating', Array)
#5 src/XF/Import/Data/AbstractEmulatedData.php(55): XF\Import\Data\EntityEmulator->insert(52615, Object(XF\Db\Mysqli\Adapter))
#6 src/XF/Import/Data/AbstractData.php(127): XF\Import\Data\AbstractEmulatedData->write(52615)
#7 src/addons/XFMG/Import/Importer/vBGallery.php(620): XF\Import\Data\AbstractData->save(52615)
#8 src/XF/Import/Runner.php(231): XFMG\Import\Importer\vBGallery->stepRatings(Object(XF\Import\StepState), Array, 8)
#9 src/XF/Import/Runner.php(59): XF\Import\Runner->runStep('ratings', Object(XF\Import\StepState), 8)
#10 src/XF/Import/Runner.php(151): XF\Import\Runner->run()
#11 src/XF/Import/Runner.php(128): XF\Import\Runner->runUntilCompleteInternal(Object(XF\Import\Manager), Object(Closure))
#12 src/XF/Cli/Command/Import.php(144): XF\Import\Runner->runUntilComplete(Object(XF\Import\Manager), Object(Closure))
#13 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))
#14 src/vendor/symfony/console/Application.php(987): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 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))
#16 src/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 src/XF/Cli/Runner.php(63): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 cmd.php(15): XF\Cli\Runner->run()
#19 {main}

This does happen when importing ratings given by users that were unique in the source system but got merged into one user on XenForo.
 

XF Bug Bot

XenForo bug fixer bot
Staff member
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 XFMG release (2.2.0 RC3).

Change log:
Avoid a duplicate key exception when importing ratings from vBGallery in some cases.
There may be a delay before changes are rolled out to the XenForo Community.
 
Top