phpBB

Code Changes

File: phpbb/search/fulltext_postgres.php

  Unmodified   Added   Modified   Removed
Line 888Line 888
		$split_title = ($subject) ? $this->split_message($subject) : array();

$words = array_unique(array_merge($split_text, $split_title));

		$split_title = ($subject) ? $this->split_message($subject) : array();

$words = array_unique(array_merge($split_text, $split_title));

 

/**
* Event to modify method arguments and words before the PostgreSQL search index is updated
*
* @event core.search_postgres_index_before
* @var string mode Contains the post mode: edit, post, reply, quote
* @var int post_id The id of the post which is modified/created
* @var string message New or updated post content
* @var string subject New or updated post subject
* @var int poster_id Post author's user id
* @var int forum_id The id of the forum in which the post is located
* @var array words Array of words added to the index
* @var array split_text Array of words from the message
* @var array split_title Array of words from the title
* @since 3.2.3-RC1
*/
$vars = array(
'mode',
'post_id',
'message',
'subject',
'poster_id',
'forum_id',
'words',
'split_text',
'split_title',
);
extract($this->phpbb_dispatcher->trigger_event('core.search_postgres_index_before', compact($vars)));


unset($split_text);
unset($split_title);


unset($split_text);
unset($split_title);

Line 934Line 962
		{
$this->get_stats();
}

		{
$this->get_stats();
}

 

$sql_queries = [];


if (!isset($this->stats['post_subject']))
{


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']))
{

		}

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);

		}

$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);

Line 967Line 1018
		{
$this->get_stats();
}

		{
$this->get_stats();
}

 

$sql_queries = [];


if (isset($this->stats['post_subject']))
{


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']))
{

		}

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);

		}

$this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);