Merge branch 'MDL-53271-master' of git://github.com/merrill-oakland/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Wed, 9 Mar 2016 03:05:44 +0000 (11:05 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Wed, 9 Mar 2016 03:05:44 +0000 (11:05 +0800)
1  2 
search/engine/solr/classes/engine.php

@@@ -309,6 -309,10 +309,10 @@@ class engine extends \core_search\engin
              $result = $this->get_search_client()->addDocument($solrdoc, true, static::AUTOCOMMIT_WITHIN);
          } catch (\SolrClientException $e) {
              debugging('Solr client error adding document with id ' . $doc['id'] . ': ' . $e->getMessage(), DEBUG_DEVELOPER);
+         } catch (\SolrServerException $e) {
+             // We only use the first line of the message, as it's a fully java stacktrace behind it.
+             $msg = strtok($e->getMessage(), "\n");
+             debugging('Solr server error adding document with id ' . $doc['id'] . ': ' . $msg, DEBUG_DEVELOPER);
          }
      }
  
       *
       * @return void
       */
 -    public function commit() {
 +    protected function commit() {
          $this->get_search_client()->commit();
      }
  
 +    /**
 +     * Do any area cleanup needed, and do anything to confirm contents.
 +     *
 +     * Return false to prevent the search area completed time and stats from being updated.
 +     *
 +     * @param \core_search\area\base $searcharea The search area that was complete
 +     * @param int $numdocs The number of documents that were added to the index
 +     * @param bool $fullindex True if a full index is being performed
 +     * @return bool True means that data is considered indexed
 +     */
 +    public function area_index_complete($searcharea, $numdocs = 0, $fullindex = false) {
 +        $this->commit();
 +
 +        return true;
 +    }
 +
      /**
       * Defragments the index.
       *
       * @return void
       */
      public function optimize() {
 -        $this->get_search_client()->optimize();
 +        $this->get_search_client()->optimize(1, true, false);
      }
  
      /**
       */
      public function delete_by_id($id) {
          $this->get_search_client()->deleteById($id);
 +        $this->commit();
      }
  
      /**
          } else {
              $this->get_search_client()->deleteByQuery('*:*');
          }
 +        $this->commit();
      }
  
      /**
              'ssl_password' => !empty($this->config->ssl_keypassword) ? $this->config->ssl_keypassword : '',
              'ssl_cainfo' => !empty($this->config->ssl_cainfo) ? $this->config->ssl_cainfo : '',
              'ssl_capath' => !empty($this->config->ssl_capath) ? $this->config->ssl_capath : '',
 +            'timeout' => !empty($this->config->server_timeout) ? $this->config->server_timeout : '30'
          );
  
          $this->client = new \SolrClient($options);