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

Fixed Duplicate fetch of thread in Posts search handler

Discussion in 'Resolved Bug Reports' started by Xon, Mar 14, 2015.

  1. Xon

    Xon Well-Known Member

    Minor thing, in XenForo_Search_DataHandler_Post::getSearchFormControllerResponse

            $viewParams['search']['thread'] = array();
            if (!empty($params['thread']))
                $threadModel = $this->_getThreadModel();
                $thread = $threadModel->getThreadById($params['thread'], array(
                    'join' => XenForo_Model_Thread::FETCH_FORUM,
                    'permissionCombinationId' => XenForo_Visitor::getPermissionCombinationId(),
                if ($thread)
                    $permissions = XenForo_Permission::unserializePermissions($thread['node_permission_cache']);
                    if ($threadModel->canViewThreadAndContainer($thread, $thread, $null, $permissions))
                        $viewParams['search']['thread'] = $this->_getThreadModel()->getThreadById($params['thread']);
    If there any reason $viewParams['search']['thread'] isn't just assigned $thread?

    getThreadById with no fetch options gets less data than getThreadById with that join option. This looks like another db query for no particular reason.
    Marcus likes this.
  2. Mike

    Mike XenForo Developer Staff Member

    Yeah I don't see a particular reason for this extra fetch.

Share This Page