Fixed Duplicate entry 'ogolnie-Forum' for key 'node_name_unique' src/XF/Db/AbstractStatement.php:228

Fajfie

Member
Affected version
v2.2.6 Patch 2
Discourse import bug:


Code:
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry 'ogolnie-Forum' for key 'node_name_unique' src/XF/Db/AbstractStatement.php:228


Code:
INSERT  INTO `xf_node` (`node_id`, `title`, `node_name`, `description`, `node_type_id`, `parent_node_id`, `display_order`, `style_id`, `effective_style_id`, `display_in_list`, `breadcrumb_data`, `navigation_id`, `effective_navigation_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(218): XF\Db\AbstractAdapter->query('INSERT  INTO `x...', Array)
#4 src/XF/Import/Data/EntityEmulator.php(327): XF\Db\AbstractAdapter->insert('xf_node', Array)
#5 src/XF/Import/Data/AbstractEmulatedData.php(71): XF\Import\Data\EntityEmulator->insert(79, Object(XF\Db\Mysqli\Adapter))
#6 src/XF/Import/Data/AbstractData.php(127): XF\Import\Data\AbstractEmulatedData->write(79)
#7 src/addons/XFI/Import/Importer/Discourse.php(1498): XF\Import\Data\AbstractData->save(79)
#8 src/addons/XFI/Import/Importer/Discourse.php(1577): XFI\Import\Importer\Discourse->importCategoryTree(Array, Array, Array, 11, 11)
#9 src/addons/XFI/Import/Importer/Discourse.php(1430): XFI\Import\Importer\Discourse->importCategoryTree(Array, Array, Array)
#10 src/XF/Import/Runner.php(242): XFI\Import\Importer\Discourse->stepCategories(Object(XF\Import\StepState), Array, 8)
#11 src/XF/Import/Runner.php(59): XF\Import\Runner->runStep('categories', Object(XF\Import\StepState), 8)
#12 src/XF/Admin/Controller/Import.php(234): XF\Import\Runner->run()
#13 src/XF/Mvc/Dispatcher.php(350): XF\Admin\Controller\Import->actionRun(Object(XF\Mvc\ParameterBag))
#14 src/XF/Mvc/Dispatcher.php(257): XF\Mvc\Dispatcher->dispatchClass('XF:Import', 'Run', Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Import), NULL)
#15 src/XF/Mvc/Dispatcher.php(113): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XF\Admin\Controller\Import), NULL)
#16 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#17 src/XF/App.php(2344): XF\Mvc\Dispatcher->run()
#18 src/XF.php(512): XF\App->run()
#19 admin.php(13): XF::runApp('XF\\Admin\\App')
#20 {main}


Code:
array(4) {
  ["url"] => string(25) "/for/admin.php?import/run"
  ["referrer"] => string(46) "XXX/admin.php?import/run"
  ["_GET"] => array(1) {
    ["import/run"] => string(0) ""
  }
  ["_POST"] => array(1) {
    ["_xfToken"] => string(8) "********"
  }
}
 
Last edited:
As of right now, the available data we have to test this importer is rather basic. I'm looking at reproducing this, but it might be more helpful to have a dump of the categories table from your Discourse installation. If you're comfortable sharing that, you're welcome to send it to me in a private message. It would remain confidential and only be used for testing purposes.
 
It looks like category slugs in Discourse are only unique to their parent category, so we cannot attempt to import them. This will be sorted in the next release, but since I'm not exactly sure when that will be, you may want to apply the patch manually:

Diff:
diff --git a/src/addons/XFI/Import/Importer/Discourse.php b/src/addons/XFI/Import/Importer/Discourse.php
index 5c82ed7447..b76a79a832 100644
--- a/src/addons/XFI/Import/Importer/Discourse.php
+++ b/src/addons/XFI/Import/Importer/Discourse.php
@@ -1468,8 +1468,7 @@ protected function importCategoryTree(
 
             $nodeData = $this->mapXfKeys($category, [
                 'title' => 'name',
-                'description',
-                'node_name' => 'slug'
+                'description'
             ]);
             $nodeData['display_order'] = $category['position'] * 10;
             $nodeData['parent_node_id'] = $targetParentId;
 
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 XFI release (1.5.1).

Change log:
Do not attempt to import category slugs from Discourse
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom