• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Target post datawriter missing forum info when posts are merged

xfrocks

Well-known member
#1
File: library/XenForo/Model/Post.php
Line: 1387
I think the $targetPostDw should be set with the forum information just like source posts. This can be fixed quite easy since we have all the forum data (in $forums)... I hope this can be fixed real soon!

Code:
$targetPostDw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
$targetPostDw->setExistingData($targetPost, true);
$targetPostDw->set('message', $newMessage);
$targetPostDw->set('attach_count', $targetPostDw->get('attach_count') + array_sum($attachPosts));
 
if ($likePosts)
{
$latestLikeUsers = $this->getModelFromCache('XenForo_Model_Like')->getLatestContentLikeUsers(
'post', $targetPost['post_id']
);
$targetPostDw->set('likes', $targetPostDw->get('likes') + $likesMoved);
$targetPostDw->set('like_users', $latestLikeUsers);
}
 
$targetPostDw->save();
 
$forums = $this->getModelFromCache('XenForo_Model_Forum')->getForumsByThreadIds(array_keys($threads));
 
foreach ($posts AS $post)
{
$sourcePostDw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post');
$sourcePostDw->setOption(XenForo_DataWriter_DiscussionMessage::OPTION_DELETE_DISCUSSION_FIRST_MESSAGE, false);
$sourcePostDw->setExistingData($post, true);
$sourcePostDw->set('attach_count', 0); // moved these away, no need to try to delete
 
if (array_key_exists($sourcePostDw->get('thread_id'), $threads))
{
$thread = $threads[$sourcePostDw->get('thread_id')];
 
if (array_key_exists($thread['node_id'], $forums))
{
$sourcePostDw->setExtraData(XenForo_DataWriter_DiscussionMessage_Post::DATA_FORUM, $forums[$thread['node_id']]);
}
}
 
$sourcePostDw->delete();
}