Fixed Merge 2 xenforo forums error

Denis M

Member
When you try to merge 2 xenforo forum getting such errors

Code:
InvalidArgumentException: Constraint error for discussion_state: Please enter a valid value.. in src/XF/Import/Data/EntityEmulator.php at line 154
XF\Import\Data\EntityEmulator->set() insrc/XF/Import/Data/AbstractEmulatedData.php at line 24
XF\Import\Data\AbstractEmulatedData->set() insrc/XF/Import/Data/AbstractData.php at line 97
XF\Import\Data\AbstractData->bulkSet() insrc/addons/XFI/Import/Importer/XenForo2.php at line 1575
XFI\Import\Importer\XenForo2->stepThreads() insrc/XF/Import/Runner.php at line 160
XF\Import\Runner->runStep() in src/XF/Import/Runner.php at line 74
XF\Import\Runner->run() in src/XF/Admin/Controller/Import.php at line232
XF\Admin\Controller\Import->actionRun() insrc/XF/Mvc/Dispatcher.php at line 249
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line89
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line41
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1931
XF\App->run() in src/XF.php at line 328
XF::runApp() in admin.php at line 13
ssh log:

Code:
Starting import from XenForo 2.0 (Beta)...
- Step 1 of 21: User groups 00:00:01 [15]
- Step 2 of 21: Custom user fields 00:00:00 [12]
- Step 3 of 21: Users 00:04:51 [95,027]
- Step 4 of 21: Avatars 00:02:07 [35,129]
- Step 5 of 21: Following and ignored users 00:00:03 [8,238]
- Step 6 of 21: Conversations 00:24:06 [243,334]
- Step 7 of 21: Profile posts 00:00:04 [2,274]
- Step 8 of 21: Nodes 00:00:01 [294]
- Step 9 of 21: Node permissions 00:00:00 [212]
- Step 10 of 21: Moderators 00:00:00 [14]
- Step 11 of 21: Watched forums 00:00:01 [382]
- Step 12 of 21: Thread prefixes 00:00:00 [39]
- Step 13 of 21: Custom thread fields 00:00:00 [0]

An unexpected error occurred. Please try again later.
Both Forum version XenForo 2.0.9

Importer version 1.0.2
 
Just to confirm, I can really only see this coming from an add-on that might've been installed on the source forum that has changed core data structured (adding valid values to something) or something that has otherwise inserted invalid data into the database.

You can run this query to get more info:
Code:
SELECT discussion_state, COUNT(*) FROM xf_thread GROUP BY discussion_state;

The only valid values for the discussion state are 'visible', 'moderated', 'deleted'. Anything else could cause this issue. The state of those threads would need to be changed in the source forum before importing.

The biggest question would be how that data got into the DB in the first place (if it isn't from an add-on, for example).
 
Just to confirm, I can really only see this coming from an add-on that might've been installed on the source forum that has changed core data structured (adding valid values to something) or something that has otherwise inserted invalid data into the database.

You can run this query to get more info:
Code:
SELECT discussion_state, COUNT(*) FROM xf_thread GROUP BY discussion_state;

The only valid values for the discussion state are 'visible', 'moderated', 'deleted'. Anything else could cause this issue. The state of those threads would need to be changed in the source forum before importing.

The biggest question would be how that data got into the DB in the first place (if it isn't from an add-on, for example).

Thank you for your answer,

You can run this query to get more info:
Code:
SELECT discussion_state, COUNT(*) FROM xf_thread GROUP BY discussion_state;

First forum

192199

Code:
discussion_state  COUNT(*)
visible  13739
deleted  1778

Second forum

Code:
 SELECT discussion_state, COUNT(*) FROM xf_thread GROUP BY discussion_state;
+------------------+----------+
| discussion_state | COUNT(*) |
+------------------+----------+
|                  |        1 |
| visible          |   159719 |
| moderated        |        1 |
| deleted          |    11993 |
+------------------+----------+
4 rows in set (0.09 sec)
 
Last edited:
To confirm, you've run that on the original (source) forum DB, not the partial import? If that's data from the source DB, then I don't see how that would fail, unless you're triggering a PHP 7.3.0 bug that we're aware of (though I don't think it should apply here anyway).

At that point, I'd really have to reproduce the issue directly. To do so, I'd either need access to the server where the import is to the point that it's failing or a copy of the SQL data that you're importing.
 
To confirm, you've run that on the original (source) forum DB, not the partial import? If that's data from the source DB, then I don't see how that would fail, unless you're triggering a PHP 7.3.0 bug that we're aware of (though I don't think it should apply here anyway).

At that point, I'd really have to reproduce the issue directly. To do so, I'd either need access to the server where the import is to the point that it's failing or a copy of the SQL data that you're importing.
Answer in PM
 
This was due to invalid data in the source XenForo forum. I can only assume that this data was inserted manually into the DB--outside of XF--as XF would not have allowed it to be inserted due to using MySQL's strict mode.

I have added code to the XF importer for the next importer release that won't import content with invalid (empty) discussion or message state values.
 
Back
Top Bottom