Fixed XenForo_Search_Searcher::setUser is useless

Xon

Well-known member
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;
    }
 
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.
 
Top Bottom