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

Fixed XenForo_Search_Searcher::setUser is useless

Xon

Well-known member
#1
Setting _viewingUser explicitly false, disables calling $this->_searchModel->getViewableSearchResults, except you can never trigger this code path without extending XenForo_Search_Searcher as the setUser function has a too-restrictive type argument (array|null, can't set it to false).

Code:
    /**
    * User viewing for permission checks.
    *
    * @var array|null|false Means disable checks; null means current user
    */
    protected $_viewingUser = null;
...
    /**
    * Sets the viewing user.
    *
    * @param array|null $viewingUser
    */
    public function setUser(array $viewingUser = null)
    {
        $this->_viewingUser = $viewingUser;
    }
 

Mike

XenForo developer
Staff member
#2
We don't expose direct extension of this class (via class events), so while I believe it would be safe to change the signature of the method, adding a new method -- setNoUser -- is likely a better approach to resolving this.