1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-19 06:51:33 +02:00

[ticket/15540] Display only available search backends

PHPBB3-15540
This commit is contained in:
rubencm
2021-03-22 17:51:51 +01:00
parent 911a31d898
commit 457c750773
6 changed files with 74 additions and 36 deletions

View File

@@ -16,6 +16,7 @@ namespace phpbb\search\backend;
use phpbb\auth\auth;
use phpbb\config\config;
use phpbb\db\driver\driver_interface;
use phpbb\db\tools\tools_interface;
use phpbb\event\dispatcher_interface;
use phpbb\user;
@@ -85,13 +86,13 @@ class fulltext_sphinx implements search_backend_interface
/**
* Database connection
* @var \phpbb\db\driver\driver_interface
* @var driver_interface
*/
protected $db;
/**
* Database Tools object
* @var \phpbb\db\tools\tools_interface
* @var tools_interface
*/
protected $db_tools;
@@ -180,6 +181,14 @@ class fulltext_sphinx implements search_backend_interface
return 'Sphinx Fulltext';
}
/**
* {@inheritdoc}
*/
public function is_available(): bool
{
return ($this->db->get_sql_layer() == 'mysqli' || $this->db->get_sql_layer() == 'postgres') && class_exists('SphinxClient');
}
/**
* {@inheritdoc}
*/
@@ -211,7 +220,7 @@ class fulltext_sphinx implements search_backend_interface
*/
public function init()
{
if ($this->db->get_sql_layer() != 'mysqli' && $this->db->get_sql_layer() != 'postgres')
if (!$this->is_available())
{
return $this->user->lang['FULLTEXT_SPHINX_WRONG_DATABASE'];
}
@@ -922,9 +931,7 @@ class fulltext_sphinx implements search_backend_interface
}
/**
* Returns an associative array containing information about the indexes
*
* @return string|bool Language string of error false otherwise
* {@inheritdoc}
*/
public function index_stats()
{