aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/search/fulltext_mysql.php
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2018-02-22 20:34:24 +0100
committerMarc Alexander <admin@m-a-styles.de>2018-02-22 20:34:24 +0100
commit50cf6443b981c6072f5a42c60b8dea3d548345c8 (patch)
tree2d44b54d84e5abe5c9ef6957b8f8f819718dd009 /phpBB/phpbb/search/fulltext_mysql.php
parentcf517509c86c8a747dc0c58e61cb3f9d4535deae (diff)
parenta6dc32b381dea235c979d089fc7897dd7e213011 (diff)
downloadforums-50cf6443b981c6072f5a42c60b8dea3d548345c8.tar
forums-50cf6443b981c6072f5a42c60b8dea3d548345c8.tar.gz
forums-50cf6443b981c6072f5a42c60b8dea3d548345c8.tar.bz2
forums-50cf6443b981c6072f5a42c60b8dea3d548345c8.tar.xz
forums-50cf6443b981c6072f5a42c60b8dea3d548345c8.zip
Merge pull request #5131 from kasimi/ticket/15561
[ticket/15561] Add events for adding columns to search index
Diffstat (limited to 'phpBB/phpbb/search/fulltext_mysql.php')
-rw-r--r--phpBB/phpbb/search/fulltext_mysql.php57
1 files changed, 50 insertions, 7 deletions
diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php
index cc8180ec69..137ed7433d 100644
--- a/phpBB/phpbb/search/fulltext_mysql.php
+++ b/phpBB/phpbb/search/fulltext_mysql.php
@@ -1025,17 +1025,37 @@ class fulltext_mysql extends \phpbb\search\base
$alter_list[] = $alter_entry;
}
- if (count($alter_list))
+ $sql_queries = [];
+
+ foreach ($alter_list as $alter)
{
- foreach ($alter_list as $alter)
- {
- $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
- }
+ $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter);
}
if (!isset($this->stats['post_text']))
{
- $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ADD FULLTEXT post_text (post_text)');
+ $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ADD FULLTEXT post_text (post_text)';
+ }
+
+ $stats = $this->stats;
+
+ /**
+ * Event to modify SQL queries before the MySQL search index is created
+ *
+ * @event core.search_mysql_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_mysql_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);
@@ -1078,9 +1098,32 @@ class fulltext_mysql extends \phpbb\search\base
$alter[] = 'DROP INDEX post_text';
}
+ $sql_queries = [];
+
if (count($alter))
{
- $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
+ $sql_queries[] = 'ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter);
+ }
+
+ $stats = $this->stats;
+
+ /**
+ * Event to modify SQL queries before the MySQL search index is deleted
+ *
+ * @event core.search_mysql_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_mysql_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);