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

Fixed Installed but not enabled sets default ordering anyway

Discussion in 'Enhanced Search Resolved Bugs' started by Ralle, Sep 24, 2016.

  1. Ralle

    Ralle Active Member

    Hey guys,

    I just purchased the ES addon. I am excited to use it. I am taking things slowly, so I installed this addon, and had a look at my search dialog before enabling ES. I found that the default order was not set, most likely because the ES addon sets the default order to "relevance", even if it is not enabled yet.

    I made the following change:
    --- a/library/XenES/Proxy/ControllerSearch.php
    +++ b/library/XenES/Proxy/ControllerSearch.php
    @@ -12,6 +12,7 @@ class XenES_Proxy_ControllerSearch extends XFCP_XenES_Proxy_ControllerSearch
                    if ($result instanceof XenForo_ControllerResponse_View
                            && !empty($result->params['search'])
                            && empty($result->params['search']['existing'])
    +                       && XenForo_Application::getOptions()->enableElasticsearch
                            $result->params['search']['order'] = XenForo_Application::getOptions()->esDefaultSearchOrder;
    @@ -22,7 +23,7 @@ class XenES_Proxy_ControllerSearch extends XFCP_XenES_Proxy_ControllerSearch
            public function actionSearch()
    -               if (!$this->_request->getParam('order'))
    +               if (!$this->_request->getParam('order') && XenForo_Application::getOptions()->enableElasticsearch)
                            $this->_request->setParam('order', XenForo_Application::getOptions()->esDefaultSearchOrder);
    Which makes it refrain from changing the default unless the ES addon is enabled.

    Skærmbillede 2016-09-24 10.58.11.png
    Skærmbillede 2016-09-24 10.58.38.png

    I hope you will accept this patch.
    Chris D likes this.
  2. Chris D

    Chris D XenForo Developer Staff Member

    Thanks we will look into it.
  3. Ralle

    Ralle Active Member

    One more note. I think my fix was not completely in line with your way of coding. If you have a look at the file XenES_Listener you see this:
    if (XenForo_Application::get('options')->enableElasticsearch)
                $class = 'XenES_Search_SourceHandler_ElasticSearch';
                return false; // stop running other listeners
    So I would probably alter the listener similarly instead of adding the condition to check if it is enabled before extending it.
  4. Mike

    Mike XenForo Developer Staff Member

    Just checking that it's been activated in the options is basically the correct fix, so I've done that now, thanks.

Share This Page