mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
SphinxSearch engine default values uniformisation
This commit is contained in:
@@ -88,31 +88,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel
|
||||
{
|
||||
$configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : array();
|
||||
|
||||
if (!isset($configuration['charset_tables'])) {
|
||||
$configuration['charset_tables'] = array("common", "latin");
|
||||
}
|
||||
|
||||
if (!isset($configuration['date_fields'])) {
|
||||
$configuration['date_fields'] = array();
|
||||
}
|
||||
|
||||
if (!isset($configuration['host'])) {
|
||||
$configuration['host'] = '127.0.0.1';
|
||||
}
|
||||
|
||||
if (!isset($configuration['port'])) {
|
||||
$configuration['port'] = 9306;
|
||||
}
|
||||
|
||||
if (!isset($configuration['rt_host'])) {
|
||||
$configuration['rt_host'] = '127.0.0.1';
|
||||
}
|
||||
|
||||
if (!isset($configuration['rt_port'])) {
|
||||
$configuration['rt_port'] = 9308;
|
||||
}
|
||||
|
||||
return $configuration;
|
||||
return self::populateConfiguration($configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,11 +141,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel
|
||||
*/
|
||||
public function generateSphinxConf(array $databoxes, array $configuration)
|
||||
{
|
||||
$defaults = array(
|
||||
'charset_tables' => array(),
|
||||
);
|
||||
|
||||
$options = array_merge($defaults, $configuration);
|
||||
$options = self::populateConfiguration($configuration);
|
||||
|
||||
$options['charset_tables'] = array_unique($options['charset_tables']);
|
||||
|
||||
@@ -657,8 +629,8 @@ searchd
|
||||
# listen = 192.168.0.1:9312
|
||||
# listen = 9312
|
||||
# listen = /var/run/searchd.sock
|
||||
listen = 127.0.0.1:19306
|
||||
listen = 127.0.0.1:19308:mysql41
|
||||
listen = '.$options['host'].':'.$options['port'].'
|
||||
listen = '.$options['rt_host'].':'.$options['rt_port'].':mysql41
|
||||
|
||||
# log file, searchd run info is logged here
|
||||
# optional, default is \'searchd.log\'
|
||||
@@ -756,4 +728,23 @@ searchd
|
||||
|
||||
return $conf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates a configuration with the default options, if missing.
|
||||
*
|
||||
* @param array $configuration
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function populateConfiguration(array $configuration)
|
||||
{
|
||||
return array_replace(array(
|
||||
'charset_tables' => array("common", "latin"),
|
||||
'date_fields' => array(),
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 9312,
|
||||
'rt_host' => '127.0.0.1',
|
||||
'rt_port' => 9306,
|
||||
), $configuration);
|
||||
}
|
||||
}
|
||||
|
@@ -571,6 +571,8 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
*/
|
||||
public static function create(Application $app, array $options = array())
|
||||
{
|
||||
$options = ConfigurationPanel::populateConfiguration($options);
|
||||
|
||||
return new static($app, $options['host'], $options['port'], $options['rt_host'], $options['rt_port']);
|
||||
}
|
||||
|
||||
|
@@ -34,7 +34,7 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest
|
||||
|
||||
$app = new Application('test');
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
self::$searchEngine = new SphinxSearchEngine($app, '127.0.0.1', 19306, '127.0.0.1', 19308);
|
||||
self::$searchEngine = new SphinxSearchEngine($app, '127.0.0.1', 9312, '127.0.0.1', 9306);
|
||||
|
||||
self::$config = tempnam(sys_get_temp_dir(), 'tmp_sphinx.conf');
|
||||
$configuration = self::$searchEngine->getConfigurationPanel()->getConfiguration();
|
||||
@@ -63,7 +63,7 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest
|
||||
self::$searchd = new Process($searchd . ' -c ' . self::$config);
|
||||
self::$searchd->run();
|
||||
|
||||
self::$searchEngine = new SphinxSearchEngine($app, '127.0.0.1', 19306, '127.0.0.1', 19308);
|
||||
self::$searchEngine = new SphinxSearchEngine($app, '127.0.0.1', 9312, '127.0.0.1', 9306);
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
|
Reference in New Issue
Block a user