mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/15540] Method init
PHPBB3-15540
This commit is contained in:
parent
457c750773
commit
fd45ce1e91
6 changed files with 66 additions and 56 deletions
|
@ -155,7 +155,8 @@ class acp_search
|
|||
$search = $search_backend_factory->get($cfg_array['search_type']);
|
||||
if (confirm_box(true))
|
||||
{
|
||||
if (!method_exists($search, 'init') || !($error = $search->init()))
|
||||
// Initialize search backend, if $error is false means that everything is ok
|
||||
if (!($error = $search->init()))
|
||||
{
|
||||
$config->set('search_type', $cfg_array['search_type']);
|
||||
|
||||
|
|
|
@ -121,38 +121,18 @@ class fulltext_mysql extends base implements search_backend_interface
|
|||
*/
|
||||
public function is_available(): bool
|
||||
{
|
||||
return $this->db->get_sql_layer() == 'mysqli';
|
||||
// Check if we are using mysql
|
||||
if($this->db->get_sql_layer() != 'mysqli')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_search_query(): string
|
||||
{
|
||||
return $this->search_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_common_words(): array
|
||||
{
|
||||
return $this->common_words;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_word_length(): array
|
||||
{
|
||||
return $this->word_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for correct MySQL version and stores min/max word length in the config
|
||||
*
|
||||
* @return string|bool Language key of the error/incompatibility occurred
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (!$this->is_available())
|
||||
|
@ -164,15 +144,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
|||
$info = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$engine = '';
|
||||
if (isset($info['Engine']))
|
||||
{
|
||||
$engine = $info['Engine'];
|
||||
}
|
||||
else if (isset($info['Type']))
|
||||
{
|
||||
$engine = $info['Type'];
|
||||
}
|
||||
$engine = $info['Engine'] ?? $info['Type'] ?? '';
|
||||
|
||||
$fulltext_supported = $engine === 'Aria' || $engine === 'MyISAM'
|
||||
/**
|
||||
|
@ -182,7 +154,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
|||
* fixed for proper overall operation. Hence we require 5.6.8.
|
||||
*/
|
||||
|| ($engine === 'InnoDB'
|
||||
&& phpbb_version_compare($this->db->sql_server_info(true), '5.6.8', '>='));
|
||||
&& phpbb_version_compare($this->db->sql_server_info(true), '5.6.8', '>='));
|
||||
|
||||
if (!$fulltext_supported)
|
||||
{
|
||||
|
@ -214,6 +186,30 @@ class fulltext_mysql extends base implements search_backend_interface
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_search_query(): string
|
||||
{
|
||||
return $this->search_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_common_words(): array
|
||||
{
|
||||
return $this->common_words;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_word_length(): array
|
||||
{
|
||||
return $this->word_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -157,6 +157,14 @@ class fulltext_native extends base implements search_backend_interface
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -137,6 +137,19 @@ class fulltext_postgres extends base implements search_backend_interface
|
|||
return $this->db->get_sql_layer() == 'postgres';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (!$this->is_available())
|
||||
{
|
||||
return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -171,21 +184,6 @@ class fulltext_postgres extends base implements search_backend_interface
|
|||
return $this->phrase_search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for correct PostgreSQL version and stores min/max word length in the config
|
||||
*
|
||||
* @return string|bool Language key of the error/incompatibility occurred
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (!$this->is_available())
|
||||
{
|
||||
return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE'];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -214,9 +214,7 @@ class fulltext_sphinx implements search_backend_interface
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks permissions and paths, if everything is correct it generates the config file
|
||||
*
|
||||
* @return string|bool Language key of the error/incompatibility encountered, or false if successful
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
|
|
|
@ -29,6 +29,15 @@ interface search_backend_interface
|
|||
*/
|
||||
public function is_available();
|
||||
|
||||
/**
|
||||
* Method executed when a search backend is set from acp.
|
||||
*
|
||||
* Checks permissions and paths, if everything is correct it generates the config file
|
||||
*
|
||||
* @return string|false False if everything was ok or string with error message
|
||||
*/
|
||||
public function init();
|
||||
|
||||
/**
|
||||
* Returns the search_query
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue