mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-29 18:50:25 +02:00
[ticket/13238] Do not drop indexes that do not exist from fulltext search
PHPBB3-13238
This commit is contained in:
parent
8f1a1874a9
commit
aab98b8626
@ -15,10 +15,18 @@ namespace phpbb\db\migration\data\v310;
|
|||||||
|
|
||||||
class mysql_fulltext_drop extends \phpbb\db\migration\migration
|
class mysql_fulltext_drop extends \phpbb\db\migration\migration
|
||||||
{
|
{
|
||||||
|
protected $indexes;
|
||||||
|
|
||||||
public function effectively_installed()
|
public function effectively_installed()
|
||||||
{
|
{
|
||||||
// This migration is irrelevant for all non-MySQL DBMSes.
|
// This migration is irrelevant for all non-MySQL DBMSes.
|
||||||
return strpos($this->db->get_sql_layer(), 'mysql') === false;
|
if (strpos($this->db->get_sql_layer(), 'mysql') === false)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->find_indexes_to_drop();
|
||||||
|
return empty($this->indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function depends_on()
|
static public function depends_on()
|
||||||
@ -30,6 +38,11 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration
|
|||||||
|
|
||||||
public function update_schema()
|
public function update_schema()
|
||||||
{
|
{
|
||||||
|
if (empty($this->indexes))
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drop FULLTEXT indexes related to MySQL fulltext search.
|
* Drop FULLTEXT indexes related to MySQL fulltext search.
|
||||||
* Doing so is equivalent to dropping the search index from the ACP.
|
* Doing so is equivalent to dropping the search index from the ACP.
|
||||||
@ -40,12 +53,28 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration
|
|||||||
*/
|
*/
|
||||||
return array(
|
return array(
|
||||||
'drop_keys' => array(
|
'drop_keys' => array(
|
||||||
$this->table_prefix . 'posts' => array(
|
$this->table_prefix . 'posts' => $this->indexes,
|
||||||
'post_subject',
|
|
||||||
'post_text',
|
|
||||||
'post_content',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function find_indexes_to_drop()
|
||||||
|
{
|
||||||
|
if ($this->indexes !== null)
|
||||||
|
{
|
||||||
|
return $this->indexes;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->indexes = array();
|
||||||
|
$potential_keys = array('post_subject', 'post_text', 'post_content');
|
||||||
|
foreach ($potential_keys as $key)
|
||||||
|
{
|
||||||
|
if ($this->db_tools->sql_index_exists($this->table_prefix . 'posts', $key))
|
||||||
|
{
|
||||||
|
$this->indexes[] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->indexes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,18 @@ namespace phpbb\db\migration\data\v310;
|
|||||||
|
|
||||||
class postgres_fulltext_drop extends \phpbb\db\migration\migration
|
class postgres_fulltext_drop extends \phpbb\db\migration\migration
|
||||||
{
|
{
|
||||||
|
protected $indexes;
|
||||||
|
|
||||||
public function effectively_installed()
|
public function effectively_installed()
|
||||||
{
|
{
|
||||||
// This migration is irrelevant for all non-PostgreSQL DBMSes.
|
// This migration is irrelevant for all non-PostgreSQL DBMSes.
|
||||||
return strpos($this->db->get_sql_layer(), 'postgres') === false;
|
if (strpos($this->db->get_sql_layer(), 'postgres') === false)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->find_indexes_to_drop();
|
||||||
|
return empty($this->indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function depends_on()
|
static public function depends_on()
|
||||||
@ -30,6 +38,11 @@ class postgres_fulltext_drop extends \phpbb\db\migration\migration
|
|||||||
|
|
||||||
public function update_schema()
|
public function update_schema()
|
||||||
{
|
{
|
||||||
|
if (empty($this->indexes))
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Drop FULLTEXT indexes related to PostgreSQL fulltext search.
|
* Drop FULLTEXT indexes related to PostgreSQL fulltext search.
|
||||||
* Doing so is equivalent to dropping the search index from the ACP.
|
* Doing so is equivalent to dropping the search index from the ACP.
|
||||||
@ -40,12 +53,28 @@ class postgres_fulltext_drop extends \phpbb\db\migration\migration
|
|||||||
*/
|
*/
|
||||||
return array(
|
return array(
|
||||||
'drop_keys' => array(
|
'drop_keys' => array(
|
||||||
$this->table_prefix . 'posts' => array(
|
$this->table_prefix . 'posts' => $this->indexes,
|
||||||
'post_subject',
|
|
||||||
'post_text',
|
|
||||||
'post_content',
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function find_indexes_to_drop()
|
||||||
|
{
|
||||||
|
if ($this->indexes !== null)
|
||||||
|
{
|
||||||
|
return $this->indexes;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->indexes = array();
|
||||||
|
$potential_keys = array('post_subject', 'post_text', 'post_content');
|
||||||
|
foreach ($potential_keys as $key)
|
||||||
|
{
|
||||||
|
if ($this->db_tools->sql_index_exists($this->table_prefix . 'posts', $key))
|
||||||
|
{
|
||||||
|
$this->indexes[] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->indexes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user