MDL-60346 core_search: Solr connection ignores proxy settings
authorsam marshall <s.marshall@open.ac.uk>
Wed, 4 Oct 2017 10:55:29 +0000 (11:55 +0100)
committersam marshall <s.marshall@open.ac.uk>
Fri, 6 Oct 2017 10:39:38 +0000 (11:39 +0100)
search/engine/solr/classes/engine.php

index 50042c3..8941014 100644 (file)
@@ -1144,6 +1144,7 @@ class engine extends \core_search\engine {
      * @return \SolrClient
      */
     protected function get_search_client($triggerexception = true) {
+        global $CFG;
 
         // Type comparison as it is set to false if not available.
         if ($this->client !== null) {
@@ -1165,6 +1166,11 @@ class engine extends \core_search\engine {
             'timeout' => !empty($this->config->server_timeout) ? $this->config->server_timeout : '30'
         );
 
+        if ($CFG->proxyhost && !is_proxybypass('http://' . $this->config->server_hostname . '/')) {
+            $options['proxy_host'] = $CFG->proxyhost;
+            $options['proxy_port'] = $CFG->proxyport;
+        }
+
         if (!class_exists('\SolrClient')) {
             throw new \core_search\engine_exception('enginenotinstalled', 'search', '', 'solr');
         }