Fixed Duplicate fetch of thread in Posts search handler

Xon

Well-known member
Minor thing, in XenForo_Search_DataHandler_Post::getSearchFormControllerResponse

Code:
        $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.
 
Back
Top Bottom