Fixed XF\Db\Exception: MySQL query error [1366]: Incorrect integer value: '' for column `XXX`.`xf_deletion_log`.`delete_user_id` at row 1

Fajfie

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

Code:
[LIST]
[*]XF\Db\Exception: MySQL query error [1366]: Incorrect integer value: '' for column `XXX`.`xf_deletion_log`.`delete_user_id` at row 1
[*]src/XF/Db/AbstractStatement.php:228
[/LIST]

Code:
INSERT  INTO `xf_deletion_log` (`content_type`, `content_id`, `delete_date`, `delete_user_id`, `delete_username`, `delete_reason`) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE delete_date = LEAST(delete_date, VALUES(delete_date))
------------

#0 src/XF/Db/Mysqli/Statement.php(196): XF\Db\AbstractStatement->getException('MySQL query err...', 1366, '22007')
#1 src/XF/Db/Mysqli/Statement.php(77): XF\Db\Mysqli\Statement->getException('MySQL query err...', 1366, '22007')
#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(522): XF\Db\AbstractAdapter->insert('xf_deletion_log', Array, false, 'delete_date = L...')
#5 src/XF/Import/Data/AbstractEmulatedData.php(101): XF\Import\Data\EntityEmulator->insertStateRecord(Object(XF\Db\Mysqli\Adapter), 'deleted', 1524996608, Array)
#6 src/XF/Import/Data/Thread.php(93): XF\Import\Data\AbstractEmulatedData->insertStateRecord('deleted', 1524996608)
#7 src/XF/Import/Data/AbstractData.php(136): XF\Import\Data\Thread->postSave(7, 36)
#8 src/addons/XFI/Import/Importer/Discourse.php(1964): XF\Import\Data\AbstractData->save(7)
#9 src/XF/Import/Runner.php(242): XFI\Import\Importer\Discourse->stepThreads(Object(XF\Import\StepState), Array, 8)
#10 src/XF/Import/Runner.php(59): XF\Import\Runner->runStep('threads', Object(XF\Import\StepState), 8)
#11 src/XF/Import/Runner.php(152): XF\Import\Runner->run()
#12 src/XF/Import/Runner.php(128): XF\Import\Runner->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}

Code:
array(1) {
  ["cli"] => string(17) "cmd.php xf:import"
}
 
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:
Properly import Discourse content which was soft-deleted by a user who no longer exists
There may be a delay before changes are rolled out to the XenForo Community.
 
I believe this should sort this one:

Diff:
diff --git a/src/addons/XFI/Import/Importer/Discourse.php b/src/addons/XFI/Import/Importer/Discourse.php
index b76a79a832..dea571b8ec 100644
--- a/src/addons/XFI/Import/Importer/Discourse.php
+++ b/src/addons/XFI/Import/Importer/Discourse.php
@@ -2859,7 +2859,7 @@ protected function extractDeletionLogData(array $record): array
 	{
 		return [
 			'date' => $this->convertTimestamp($record['deleted_at']),
-			'user_id' => $this->lookupId('user', $record['deleted_by_id']),
+			'user_id' => $this->lookupId('user', $record['deleted_by_id'], 0),
 			'username' => $record['deleted_by_username'] ?? ''
 		];
 	}
 
Back
Top Bottom