Replace Sphinx API to the composer version

This commit is contained in:
Yuriy Pikhtarev 2017-01-30 23:05:12 +03:00
commit fcc05aa677
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
4 changed files with 9 additions and 1711 deletions

View file

@ -42,6 +42,7 @@
},
"require": {
"php": "^5.3 || ^7.0",
"gigablah/sphinxphp": "^2.0",
"google/recaptcha": "^1.0"
},
"autoload": {

File diff suppressed because it is too large Load diff

View file

@ -2239,13 +2239,14 @@ function init_sphinx()
global $sphinx;
if (!isset($sphinx)) {
require(INC_DIR . 'api/sphinx.php');
$sphinx = new SphinxClient();
$sphinx = \Sphinx\SphinxClient::create();
$sphinx->SetConnectTimeout(5);
$sphinx->SetRankingMode(SPH_RANK_NONE);
$sphinx->SetMatchMode(SPH_MATCH_BOOLEAN);
$sphinx->SetRankingMode($sphinx::SPH_RANK_NONE);
$sphinx->SetMatchMode($sphinx::SPH_MATCH_BOOLEAN);
}
return $sphinx;
}
function log_sphinx_error($err_type, $err_msg, $query = '')
@ -2271,7 +2272,7 @@ function get_title_match_topics($title_match_sql, $forum_ids = array())
$title_match_sql = encode_text_match($title_match_sql);
if ($bb_cfg['search_engine_type'] == 'sphinx') {
init_sphinx();
$sphinx = init_sphinx();
$where = ($title_match) ? 'topics' : 'posts';
@ -2280,7 +2281,7 @@ function get_title_match_topics($title_match_sql, $forum_ids = array())
$sphinx->SetFilter('forum_id', $forum_ids, false);
}
if (preg_match('#^"[^"]+"$#u', $title_match_sql)) {
$sphinx->SetMatchMode(SPH_MATCH_PHRASE);
$sphinx->SetMatchMode($sphinx::SPH_MATCH_PHRASE);
}
if ($result = $sphinx->Query($title_match_sql, $where, $userdata['username'] . ' (' . CLIENT_IP . ')')) {
if (!empty($result['matches'])) {

View file

@ -29,7 +29,7 @@ if (!defined('BB_ROOT')) {
function get_sql_log()
{
global $DBS, $CACHES, $sphinx, $datastore;
global $DBS, $CACHES, $datastore;
$log = '';
@ -45,8 +45,6 @@ function get_sql_log()
}
}
$log .= !empty($sphinx) ? get_sql_log_html($sphinx, '$sphinx') : '';
if (!empty($datastore->db->dbg)) {
$log .= get_sql_log_html($datastore->db, 'cache: datastore [' . $datastore->engine . ']');
} elseif (!empty($datastore->dbg)) {