shawn
Well-known member
Probably should be:
AND node_id IN (?)
Make sure $sourceForum is always an array, even if it only contains a single node_id.
Right, but once I change it to node_id IN, I get the error all the time. I checked the options line in the db, it's a simple serialized array. Tried adding an unserialize() to the script, just in case... but that threw an error.
I have found some mention out on the internets with people having problems with IN (?) vs IN ('?'), but I tried it every way I can think of, but still can't get it to work. Here's the whole script as it sits right now. Maybe somebody can spot the problem. My next course of action was to write a page that would just print all the variables, but I haven't been able to find the time.
PHP:
public static function runMoveDeletedThreads()
{
$options = XenForo_Application::get('options');
if ($options->xefDeletedThread === '1')
{
if (empty($options->xefModeratedForums[0]))
{
return;
}
else
{
$sourceNodes = array($options->xefModeratedForums);
}
$db = XenForo_Application::getDb();
$threads = $db->fetchAll("
SELECT *
FROM xf_thread
WHERE discussion_state = 'deleted'
AND node_id IN ( ? )
", $sourceNodes);
if ($threads)
{
foreach ($threads AS $thread)
{
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
$dw->setExistingData($thread);
$dw->set('node_id', $options->xefRecycleForum);
$dw->save();
}
}
}
}
And this is what the xefModeratedForums options field looks like in the DB, first with several options, then with only one:
PHP:
a:8:{i:0;s:2:"70";i:1;s:2:"73";i:2;s:2:"67";i:3;s:2:"68";i:4;s:2:"74";i:5;s:2:"69";i:6;s:2:"71";i:7;s:2:"72";}
a:1:{i:0;s:2:"70";}