Browse Source

Zend_Search_Lucene: Fix for MultiSearcher distributor callback logic. ZF-8293.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19635 44c647ce-9c0f-0410-b52a-842ac1e357ba
alexander 16 years ago
parent
commit
5a02652c3b
1 changed files with 7 additions and 2 deletions
  1. 7 2
      library/Zend/Search/Lucene/MultiSearcher.php

+ 7 - 2
library/Zend/Search/Lucene/MultiSearcher.php

@@ -794,10 +794,15 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
      * Set callback for choosing target index.
      *
      * @param callback $callback
+     * @throws Zend_Search_Lucene_Exception
      */
     public function setDocumentDistributorCallback($callback)
     {
-        if ($callback !== null  &&  !is_callable($callback))
+        if ($callback !== null  &&  !is_callable($callback)) {
+            require_once 'Zend/Search/Lucene/Exception.php';
+            throw new Zend_Search_Lucene_Exception('$callback parameter must be a valid callback.');
+        }
+
         $this->_documentDistributorCallBack = $callback;
     }
 
@@ -822,7 +827,7 @@ class Zend_Search_Lucene_Interface_MultiSearcher implements Zend_Search_Lucene_I
         if ($this->_documentDistributorCallBack !== null) {
             $index = call_user_func($this->_documentDistributorCallBack, $document, $this->_indices);
         } else {
-            $index = $this->_indices[ array_rand($this->_indices) ];
+            $index = $this->_indices[array_rand($this->_indices)];
         }
 
         $index->addDocument($document);