I will run the code on my local dev site to see what I find.
--------------- Added [DATE]1509428993[/DATE] at [TIME]1509428993[/TIME] ---------------
Okay, this should work:
PHP Code:
global $vbulletin;
require_once(DIR . '/includes/functions_databuild.php');
$deleted = 0;
$curtime = TIMENOW;
$physicaldel = false;
$del_user = fetch_userinfo(1);
$del_forumid = '4';
$reason = 'Thema alt entfernt via cron.';
$delinfo = array(
'userid' => $del_user['userid'],
'username' => $del_user['username'],
'reason' => $reason,
'keepattachments' => true
);
$countposts = ($vbulletin->forumcache["$del_forumid"]['options'] & $vbulletin->bf_misc_forumoptions['countposts']);
$query = "SELECT thread.* FROM " . TABLE_PREFIX . "thread AS thread WHERE lastpost <= " . ($curtime - 365*86400) . " AND forumid = " . $del_forumid;
$threads_delete = $vbulletin->db->query_read($query);
$mthread =& datamanager_init('Thread', $vbulletin, ERRTYPE_SILENT, 'threadpost');
while ($thread_delete = $vbulletin->db->fetch_array($threads_delete))
{
if (!$deleted)
{
$deleted = true;
}
$mthread->set_existing($thread_delete);
$mthread->delete($countposts, $physicaldel, $delinfo, false);
}
unset($mthread);
if ($deleted)
{
build_forum_counters($del_forumid);
}
$move_prefixid = 'reportthread_solved';
$source_forumid = 10;
$destination_forumid = 12;
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "thread
SET forumid = " . $destination_forumid . "
WHERE forumid = " . $source_forumid . "
AND lastpost <= " . ($curtime - 100*86400) . "
AND prefixid = '" . $move_prefixid . "'
");
build_forum_counters($source_forumid);
build_forum_counters($destination_forumid);
--------------- Added [DATE]1509429187[/DATE] at [TIME]1509429187[/TIME] ---------------
I move that these double-post merges go away.