Skip to content

Commit

Permalink
Show error when Sphinx is unavailable.
Browse files Browse the repository at this point in the history
Show error to the user instead of misleading "no results"
when Sphinx server is unavailable.
  • Loading branch information
figvam committed Jun 28, 2010
1 parent 35c2dfb commit 8cec532
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sphinx_plugin/includes/search/fulltext_sphinx.php
Expand Up @@ -439,7 +439,7 @@ function split_keywords(&$keywords, $terms)
*/
function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
global $config, $db, $auth;
global $config, $db, $auth, $user;

// No keywords? No posts.
if (!strlen($this->search_query) && !sizeof($author_ary))
Expand Down Expand Up @@ -563,6 +563,11 @@ function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_d
usleep(CONNECT_WAIT_TIME);
$result = $this->sphinx->Query($search_query_prefix . str_replace('"', '"', $this->search_query), $this->indexes);
}
if (!$result)
{
$user->add_lang('mods/fulltext_sphinx');
trigger_error($user->lang['FULLTEXT_SPHINX_SERVER_ERROR']);
}

$id_ary = array();
if (isset($result['matches']))
Expand Down
1 change: 1 addition & 0 deletions sphinx_plugin/language/en/mods/fulltext_sphinx.php
Expand Up @@ -64,6 +64,7 @@
'FULLTEXT_SPHINX_WRONG_DATABASE' => 'The sphinx plugin for phpBB currently only supports MySQL',
'FULLTEXT_SPHINX_STOPWORDS_FILE' => 'Stopwords activated',
'FULLTEXT_SPHINX_STOPWORDS_FILE_EXPLAIN' => 'This setting only works with autoconf enabled. You can place a file called sphinx_stopwords.txt containing one word in each line in your config directory. If this file is present these words will be excluded from the indexing process.',
'FULLTEXT_SPHINX_SERVER_ERROR' => 'There has been an error accessing the search server. Please try again in a few minutes.',
));

?>

0 comments on commit 8cec532

Please sign in to comment.