From 31a2defbbd332bb3c09bac1da5b89ebb3c67c355 Mon Sep 17 00:00:00 2001 From: Stephen Shkardoon Date: Tue, 25 Nov 2014 02:48:10 +1300 Subject: [PATCH] Fix compatibility with solr 4 Remove waitFlush parameter. Fixes #34. Also fixes a minor bug where the wrong service was being returned. --- code/solr/SolrService.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/solr/SolrService.php b/code/solr/SolrService.php index 814c661..2fde7bd 100644 --- a/code/solr/SolrService.php +++ b/code/solr/SolrService.php @@ -47,9 +47,19 @@ class SolrService extends Apache_Solr_Service { public function serviceForCore($core) { if (!isset($this->_serviceCache[$core])) { - $this->_serviceCache[$core] = new Apache_Solr_Service($this->_host, $this->_port, $this->_path."$core", $this->_httpTransport); + $this->_serviceCache[$core] = new self($this->_host, $this->_port, $this->_path."$core", $this->_httpTransport); } return $this->_serviceCache[$core]; } + + /** + * A version of commit() that won't send the waitFlush parameter, which is useless and removed in SOLR 4 + */ + public function commit($expungeDeletes = false, $waitFlush = true, $waitSearcher = true, $timeout = 3600) { + $expungeValue = $expungeDeletes ? 'true' : 'false'; + $searcherValue = $waitSearcher ? 'true' : 'false'; + $rawPost = ''; + return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); + } }