diff -urp sphinx.install sphinx.install --- sphinx.install 2008-09-25 21:26:20.000000000 +0200 +++ sphinx.install 2009-08-27 15:16:50.368438800 +0200 @@ -94,6 +94,9 @@ function sphinx_requirements($phase) { ); if ($api_exists) { $cl = new SphinxClient(); + $server = variable_get('sphinx_default_server', 'localhost'); + $port = variable_get('sphinx_default_port', '3312'); + $cl->SetServer($server, $port); $connect = $cl->_Connect(); $requirements['sphinx_daemon'] = array( 'title' => $t('Sphinx daemon'), diff -urp sphinx.module sphinx.module --- sphinx.module 2008-09-25 21:26:20.000000000 +0200 +++ sphinx.module 2009-08-27 15:20:27.364272400 +0200 @@ -177,6 +177,10 @@ function _sphinx_search_page($index_name $res = db_query($sql, $iid); $index = db_fetch_object($res); $client = new SphinxClient(); + //set the right server settings + $host = variable_get('sphinx_default_server', 'localhost'); + $port = variable_get('sphinx_default_port', '3312'); + $client->SetServer($host, $port); $connect = $client->_Connect(); if (!$connect) { drupal_set_message(variable_get('sphinx_offline_message', '')); diff -urp sphinx_admin.inc.php sphinx_admin.inc.php --- sphinx_admin.inc.php 2008-09-25 21:26:20.000000000 +0200 +++ sphinx_admin.inc.php 2009-08-27 15:18:44.569371100 +0200 @@ -3,7 +3,7 @@ function _check_searchd($host = 'localhost', $port = '3312') { $cl = new SphinxClient(); - //$cl->SetServer($host, $port); + $cl->SetServer($host, $port); $connect = $cl->_Connect(); if (!$connect) { drupal_set_message(t('Searchd not running'), 'warning'); @@ -14,12 +14,18 @@ function _check_searchd($host = 'localho * The admin page callback */ function _sphinx_admin() { - _check_searchd(); + //get configuration + $server = variable_get('sphinx_default_server', 'localhost'); + $port = variable_get('sphinx_default_port', '3312'); + _check_searchd($server, $port); return drupal_get_form('sphinx_admin_form'); } function _sphinx_admin_indexes($op = '', $iid = '') { - _check_searchd(); + //get configuration + $server = variable_get('sphinx_default_server', 'localhost'); + $port = variable_get('sphinx_default_port', '3312'); + _check_searchd($server, $port); if (!empty($op) && !empty($iid)) { switch ($op) { case 'delete': @@ -71,11 +77,11 @@ function _sphinx_admin_indexes($op = '', $sql = 'SELECT {sphinx_indexes}.*, {sphinx_attributes}.display_name AS sort_field FROM {sphinx_indexes} LEFT JOIN {sphinx_attributes} ON default_sort_key_fid = aid '. tablesort_sql($header); $result = pager_query($sql, 10); $client = new SphinxClient(); - $connect = $client->_Connect(); while ($indexes = db_fetch_object($result)) { + $client->SetServer($indexes->server, (int)$indexes->port); + $connect = $client->_Connect(); if ($indexes->active) { - $client->SetServer($indexes->server, (int)$indexes->port); $client->SetLimits(0, 1); $res = $client->Query('', $indexes->index_name); if ($res) { @@ -156,7 +162,7 @@ function sphinx_admin_form() { $form['sphinx']['sphinx_default_port'] = array( '#type' => 'textfield', '#title' => t('Default port'), - '#default_value' => variable_get('sphinx_default_port ', '3312'), + '#default_value' => variable_get('sphinx_default_port', '3312'), '#description' => t('Type the port on which your default searchd is listening (this setting can be altered per index)'), ); $form['sphinx']['sphinx_default_index'] = array( @@ -184,7 +190,7 @@ function sphinx_admin_form_submit($form_ variable_set('sphinx_offline_message', $form_values['sphinx_offline_message']); variable_set('sphinx_default_server', $form_values['sphinx_default_server']); - variable_set('sphinx_default_port', $form_values['sphinx_default_port']); + variable_set('sphinx_default_port', (int)$form_values['sphinx_default_port']); variable_set('sphinx_default_index', $form_values['sphinx_default_index']); variable_set('sphinx_results_per_page', $form_values['sphinx_results_per_page']); drupal_set_message(t('Your Sphinx settings are saved'));