Changeset 15476
- Timestamp:
- 02/13/09 10:13:32 (4 years ago)
- Files:
-
- plugins/sfSphinxPlugin/trunk/README (modified) (1 diff)
- plugins/sfSphinxPlugin/trunk/lib/sfSphinxClient.class.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfSphinxPlugin/trunk/README
r15426 r15476 100 100 101 101 <?php $res = $pager->getResults() ?> 102 <?php if ($sphinx->getLastError()): ?> 103 Error: <?php echo $sphinx->getLastError() ?> 104 <?php elseif (empty($res)): ?> 102 <?php if (empty($res)): ?> 105 103 No result matches your query 106 104 <?php else: ?> plugins/sfSphinxPlugin/trunk/lib/sfSphinxClient.class.php
r15436 r15476 293 293 294 294 /** 295 * check if there's an error or not 296 * @return string 297 */ 298 public function isError() 299 { 300 return !empty($this->error); 301 } 302 303 /** 295 304 * get last error message 296 305 * @return string … … 324 333 * connect to searchd server 325 334 * @return resource 335 * @throws Exception 326 336 */ 327 337 protected function Connect() … … 341 351 $errstr = trim($errstr); 342 352 $this->error = "connection to {$this->host}:{$this->port} failed (errno=$errno, msg=$errstr)"; 343 return false;353 throw new Exception($this->error); 344 354 } 345 355 … … 351 361 fclose($fp); 352 362 $this->error = "expected searchd protocol version 1+, got version '$v'"; 353 return false;363 throw new Exception($this->error); 354 364 } 355 365 … … 364 374 * @param integer $client_ver 365 375 * @return string 376 * @throws Exception 366 377 */ 367 378 protected function GetResponse($fp, $client_ver) … … 389 400 ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)" 390 401 : 'received zero-sized searchd response'; 391 return false;402 throw new Exception($this->error); 392 403 } 393 404 … … 396 407 { 397 408 $this->error = 'searchd error: ' . substr($response, 4); 398 return false;409 throw new Exception($this->error); 399 410 } 400 411 if ($status == self::SEARCHD_RETRY) 401 412 { 402 413 $this->error = 'temporary searchd error: ' . substr($response, 4); 403 return false;414 throw new Exception($this->error); 404 415 } 405 416 if ($status != self::SEARCHD_OK) 406 417 { 407 418 $this->error = "unknown status code '$status'"; 408 return false;419 throw new Exception($this->error); 409 420 } 410 421 … … 662 673 * 'words' 663 674 * hash which maps query terms (stemmed!) to ('docs', 'hits') hash 675 * @throws Exception 664 676 */ 665 677 public function Query($query, $index = '*', $comment = '') … … 670 682 { 671 683 // probably network error; error message should be already filled 672 return $this->res = false;684 throw new Exception($this->error); 673 685 } 674 686 $this->error = $results[0]['error']; … … 676 688 if ($results[0]['status'] == self::SEARCHD_ERROR) 677 689 { 678 return $this->res = false;690 throw new Exception($this->error); 679 691 } 680 692 else 681 693 { 682 return $this->res = $results[0]; 694 $this->res = $results[0]; 695 return $this->res; 683 696 } 684 697 } … … 702 715 { 703 716 $this->error = 'no queries defined, issue AddQuery() first'; 704 return false;717 throw new Exception($this->error); 705 718 } 706 719 … … 711 724 { 712 725 $this->MBPop(); 713 return false;726 throw new Exception($this->error); 714 727 } 715 728 … … 726 739 { 727 740 $this->MBPop(); 728 return false;741 throw new Exception($this->error); 729 742 } 730 743 … … 934 947 * 'around' 935 948 * how much words to highlight around each match, default is 5 936 * @return array strings of excerpts, or false in case of failure 949 * @return array strings of excerpts 950 * @throws Exception 937 951 */ 938 952 public function BuildExcerpts($docs, $index, $words, $opts = array()) … … 943 957 { 944 958 $this->MBPop(); 945 return false;959 throw new Exception($this->error); 946 960 } 947 961 … … 993 1007 { 994 1008 $this->MBPop(); 995 return false;1009 throw new Exception($this->error); 996 1010 } 997 1011 … … 1010 1024 $this->error = 'incomplete reply'; 1011 1025 $this->MBPop(); 1012 return false;1026 throw new Exception($this->error); 1013 1027 } 1014 1028 $res[] = substr($response, $pos, $len); … … 1026 1040 * @param boolean $hits 1027 1041 * @return array 1042 * @throws Exception 1028 1043 */ 1029 1044 public function BuildKeywords($query, $index, $hits) … … 1034 1049 { 1035 1050 $this->MBPop(); 1036 return false;1051 throw new Exception($this->error); 1037 1052 } 1038 1053 … … 1052 1067 { 1053 1068 $this->MBPop(); 1054 return false;1069 throw new Exception($this->error); 1055 1070 } 1056 1071 … … 1088 1103 $this->error = 'incomplete reply'; 1089 1104 $this->MBPop(); 1090 return false;1105 throw new Exception($this->error); 1091 1106 } 1092 1107 }