1. 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

Discussion in 'Resolved Bug Reports' started by xfrocks, Apr 10, 2012.

  1. xfrocks

    xfrocks Well-Known Member

    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!

    $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);
    $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']]);
    Hamidou Djaber likes this.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  3. xfrocks

    xfrocks Well-Known Member

    Because that information is available and it will be useful for add-on to get forum info without querying the db again. Also, why the source posts get that info but not the target post?
    ragtek likes this.
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Fair enough.
    xfrocks likes this.
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I believe it has to do with updating counters. The source post is deleted so it needs to update some counters.
  6. Kier

    Kier XenForo Developer Staff Member

    xfrocks likes this.

Share This Page