mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 08:17:47 +02:00
Merge pull request #5131 from kasimi/ticket/15561
[ticket/15561] Add events for adding columns to search index
This commit is contained in:
@@ -963,14 +963,37 @@ class fulltext_postgres extends \phpbb\search\base
|
||||
$this->get_stats();
|
||||
}
|
||||
|
||||
$sql_queries = [];
|
||||
|
||||
if (!isset($this->stats['post_subject']))
|
||||
{
|
||||
$this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))");
|
||||
$sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))";
|
||||
}
|
||||
|
||||
if (!isset($this->stats['post_content']))
|
||||
{
|
||||
$this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))");
|
||||
$sql_queries[] = "CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_content ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text || ' ' || post_subject))";
|
||||
}
|
||||
|
||||
$stats = $this->stats;
|
||||
|
||||
/**
|
||||
* Event to modify SQL queries before the Postgres search index is created
|
||||
*
|
||||
* @event core.search_postgres_create_index_before
|
||||
* @var array sql_queries Array with queries for creating the search index
|
||||
* @var array stats Array with statistics of the current index (read only)
|
||||
* @since 3.2.3-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'sql_queries',
|
||||
'stats',
|
||||
);
|
||||
extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_create_index_before', compact($vars)));
|
||||
|
||||
foreach ($sql_queries as $sql_query)
|
||||
{
|
||||
$this->db->sql_query($sql_query);
|
||||
}
|
||||
|
||||
$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
|
||||
@@ -996,14 +1019,37 @@ class fulltext_postgres extends \phpbb\search\base
|
||||
$this->get_stats();
|
||||
}
|
||||
|
||||
$sql_queries = [];
|
||||
|
||||
if (isset($this->stats['post_subject']))
|
||||
{
|
||||
$this->db->sql_query('DROP INDEX ' . $this->stats['post_subject']['relname']);
|
||||
$sql_queries[] = 'DROP INDEX ' . $this->stats['post_subject']['relname'];
|
||||
}
|
||||
|
||||
if (isset($this->stats['post_content']))
|
||||
{
|
||||
$this->db->sql_query('DROP INDEX ' . $this->stats['post_content']['relname']);
|
||||
$sql_queries[] = 'DROP INDEX ' . $this->stats['post_content']['relname'];
|
||||
}
|
||||
|
||||
$stats = $this->stats;
|
||||
|
||||
/**
|
||||
* Event to modify SQL queries before the Postgres search index is created
|
||||
*
|
||||
* @event core.search_postgres_delete_index_before
|
||||
* @var array sql_queries Array with queries for deleting the search index
|
||||
* @var array stats Array with statistics of the current index (read only)
|
||||
* @since 3.2.3-RC1
|
||||
*/
|
||||
$vars = array(
|
||||
'sql_queries',
|
||||
'stats',
|
||||
);
|
||||
extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_delete_index_before', compact($vars)));
|
||||
|
||||
foreach ($sql_queries as $sql_query)
|
||||
{
|
||||
$this->db->sql_query($sql_query);
|
||||
}
|
||||
|
||||
$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
|
||||
|
Reference in New Issue
Block a user