mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +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']);
|
$search = $search_backend_factory->get($cfg_array['search_type']);
|
||||||
if (confirm_box(true))
|
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']);
|
$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
|
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}
|
* {@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()
|
public function init()
|
||||||
{
|
{
|
||||||
if (!$this->is_available())
|
if (!$this->is_available())
|
||||||
|
@ -164,15 +144,7 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
$info = $this->db->sql_fetchrow($result);
|
$info = $this->db->sql_fetchrow($result);
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
$engine = '';
|
$engine = $info['Engine'] ?? $info['Type'] ?? '';
|
||||||
if (isset($info['Engine']))
|
|
||||||
{
|
|
||||||
$engine = $info['Engine'];
|
|
||||||
}
|
|
||||||
else if (isset($info['Type']))
|
|
||||||
{
|
|
||||||
$engine = $info['Type'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$fulltext_supported = $engine === 'Aria' || $engine === 'MyISAM'
|
$fulltext_supported = $engine === 'Aria' || $engine === 'MyISAM'
|
||||||
/**
|
/**
|
||||||
|
@ -214,6 +186,30 @@ class fulltext_mysql extends base implements search_backend_interface
|
||||||
return false;
|
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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -157,6 +157,14 @@ class fulltext_native extends base implements search_backend_interface
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -137,6 +137,19 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
return $this->db->get_sql_layer() == 'postgres';
|
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}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -171,21 +184,6 @@ class fulltext_postgres extends base implements search_backend_interface
|
||||||
return $this->phrase_search;
|
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}
|
* {@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
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return string|bool Language key of the error/incompatibility encountered, or false if successful
|
|
||||||
*/
|
*/
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,6 +29,15 @@ interface search_backend_interface
|
||||||
*/
|
*/
|
||||||
public function is_available();
|
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
|
* Returns the search_query
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue