diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index a2f3b97186..53fc6f5925 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -79,29 +79,29 @@ class acp_search
foreach ($search_types as $search)
{
- $type = get_class($search);
+ // Only show available search backends
+ if($search->is_available()) {
- $name = $search->get_name();
+ $name = $search->get_name();
- $selected = ($config['search_type'] == $type) ? ' selected="selected"' : '';
- $identifier = substr($type, strrpos($type, '\\') + 1);
- $search_options .= "";
+ $type = get_class($search);
- if (method_exists($search, 'acp'))
- {
- $vars = $search->acp();
+ $selected = ($config['search_type'] == $type) ? ' selected="selected"' : '';
+ $identifier = substr($type, strrpos($type, '\\') + 1);
+ $search_options .= "";
- if (!$submit)
- {
- $template->assign_block_vars('backend', array(
- 'NAME' => $name,
- 'SETTINGS' => $vars['tpl'],
- 'IDENTIFIER' => $identifier,
- ));
- }
- else if (is_array($vars['config']))
- {
- $settings = array_merge($settings, $vars['config']);
+ if (method_exists($search, 'acp')) {
+ $vars = $search->acp();
+
+ if (!$submit) {
+ $template->assign_block_vars('backend', array(
+ 'NAME' => $name,
+ 'SETTINGS' => $vars['tpl'],
+ 'IDENTIFIER' => $identifier,
+ ));
+ } else if (is_array($vars['config'])) {
+ $settings = array_merge($settings, $vars['config']);
+ }
}
}
}
diff --git a/phpBB/phpbb/search/backend/fulltext_mysql.php b/phpBB/phpbb/search/backend/fulltext_mysql.php
index 116ab67201..e95596022b 100644
--- a/phpBB/phpbb/search/backend/fulltext_mysql.php
+++ b/phpBB/phpbb/search/backend/fulltext_mysql.php
@@ -116,6 +116,14 @@ class fulltext_mysql extends base implements search_backend_interface
return 'MySQL Fulltext';
}
+ /**
+ * {@inheritdoc}
+ */
+ public function is_available(): bool
+ {
+ return $this->db->get_sql_layer() == 'mysqli';
+ }
+
/**
* {@inheritdoc}
*/
@@ -147,7 +155,7 @@ class fulltext_mysql extends base implements search_backend_interface
*/
public function init()
{
- if ($this->db->get_sql_layer() != 'mysqli')
+ if (!$this->is_available())
{
return $this->user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE'];
}
diff --git a/phpBB/phpbb/search/backend/fulltext_native.php b/phpBB/phpbb/search/backend/fulltext_native.php
index b7105f8cd6..81541930a7 100644
--- a/phpBB/phpbb/search/backend/fulltext_native.php
+++ b/phpBB/phpbb/search/backend/fulltext_native.php
@@ -23,12 +23,12 @@ use phpbb\user;
*/
class fulltext_native extends base implements search_backend_interface
{
- const UTF8_HANGUL_FIRST = "\xEA\xB0\x80";
- const UTF8_HANGUL_LAST = "\xED\x9E\xA3";
- const UTF8_CJK_FIRST = "\xE4\xB8\x80";
- const UTF8_CJK_LAST = "\xE9\xBE\xBB";
- const UTF8_CJK_B_FIRST = "\xF0\xA0\x80\x80";
- const UTF8_CJK_B_LAST = "\xF0\xAA\x9B\x96";
+ protected const UTF8_HANGUL_FIRST = "\xEA\xB0\x80";
+ protected const UTF8_HANGUL_LAST = "\xED\x9E\xA3";
+ protected const UTF8_CJK_FIRST = "\xE4\xB8\x80";
+ protected const UTF8_CJK_LAST = "\xE9\xBE\xBB";
+ protected const UTF8_CJK_B_FIRST = "\xF0\xA0\x80\x80";
+ protected const UTF8_CJK_B_LAST = "\xF0\xAA\x9B\x96";
/**
* Associative array holding index stats
@@ -149,6 +149,14 @@ class fulltext_native extends base implements search_backend_interface
return 'phpBB Native Fulltext';
}
+ /**
+ * {@inheritdoc}
+ */
+ public function is_available(): bool
+ {
+ return true;
+ }
+
/**
* {@inheritdoc}
*/
diff --git a/phpBB/phpbb/search/backend/fulltext_postgres.php b/phpBB/phpbb/search/backend/fulltext_postgres.php
index 41b28bff61..234b820f29 100644
--- a/phpBB/phpbb/search/backend/fulltext_postgres.php
+++ b/phpBB/phpbb/search/backend/fulltext_postgres.php
@@ -56,7 +56,7 @@ class fulltext_postgres extends base implements search_backend_interface
/**
* Database connection
- * @var \phpbb\db\driver\driver_interface
+ * @var driver_interface
*/
protected $db;
@@ -129,6 +129,14 @@ class fulltext_postgres extends base implements search_backend_interface
return 'PostgreSQL Fulltext';
}
+ /**
+ * {@inheritdoc}
+ */
+ public function is_available(): bool
+ {
+ return $this->db->get_sql_layer() == 'postgres';
+ }
+
/**
* {@inheritdoc}
*/
@@ -170,7 +178,7 @@ class fulltext_postgres extends base implements search_backend_interface
*/
public function init()
{
- if ($this->db->get_sql_layer() != 'postgres')
+ if (!$this->is_available())
{
return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE'];
}
@@ -1047,7 +1055,7 @@ class fulltext_postgres extends base implements search_backend_interface
}
/**
- * Computes the stats and store them in the $this->stats associative array
+ * {@inheritdoc}
*/
protected function get_stats()
{
diff --git a/phpBB/phpbb/search/backend/fulltext_sphinx.php b/phpBB/phpbb/search/backend/fulltext_sphinx.php
index da8c949b56..c53116af71 100644
--- a/phpBB/phpbb/search/backend/fulltext_sphinx.php
+++ b/phpBB/phpbb/search/backend/fulltext_sphinx.php
@@ -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()
{
diff --git a/phpBB/phpbb/search/backend/search_backend_interface.php b/phpBB/phpbb/search/backend/search_backend_interface.php
index 7c7b60cb12..26c87909b9 100644
--- a/phpBB/phpbb/search/backend/search_backend_interface.php
+++ b/phpBB/phpbb/search/backend/search_backend_interface.php
@@ -22,6 +22,13 @@ interface search_backend_interface
*/
public function get_name();
+ /**
+ * Returns if the search engine is available
+ *
+ * @return bool
+ */
+ public function is_available();
+
/**
* Returns the search_query
*
@@ -142,7 +149,7 @@ interface search_backend_interface
/**
* Returns an associative array containing information about the indexes
*
- * @return array|bool Language string of error false otherwise
+ * @return array|false Language string of error false otherwise
*/
public function index_stats();