From 0228424983e35badc779923a1f0398fc3ab7c8b2 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Mon, 26 Aug 2013 15:16:56 +0530 Subject: [PATCH 1/8] [ticket/11621] Remove mysql extra indexes Remove post_text index as post_content index is sufficient to search post text. PHPBB3-11621 --- phpBB/phpbb/search/fulltext_mysql.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index a1e1b089b9..eed962b833 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -779,7 +779,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $alter[] = 'ADD FULLTEXT (post_subject)'; } - if (!isset($this->stats['post_text'])) + if (!isset($this->stats['post_content'])) { if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) { @@ -789,11 +789,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base { $alter[] = 'MODIFY post_text mediumtext NOT NULL'; } - $alter[] = 'ADD FULLTEXT (post_text)'; - } - if (!isset($this->stats['post_content'])) - { $alter[] = 'ADD FULLTEXT post_content (post_subject, post_text)'; } @@ -832,11 +828,6 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $alter[] = 'DROP INDEX post_subject'; } - if (isset($this->stats['post_text'])) - { - $alter[] = 'DROP INDEX post_text'; - } - if (isset($this->stats['post_content'])) { $alter[] = 'DROP INDEX post_content'; @@ -862,7 +853,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base $this->get_stats(); } - return (isset($this->stats['post_text']) && isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false; + return (isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false; } /** @@ -902,11 +893,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base if ($index_type == 'FULLTEXT') { - if ($row['Key_name'] == 'post_text') - { - $this->stats['post_text'] = $row; - } - else if ($row['Key_name'] == 'post_subject') + if ($row['Key_name'] == 'post_subject') { $this->stats['post_subject'] = $row; } From 79928ebf432d03f5ec3a55a34468ea089586a568 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 10 Oct 2013 23:59:05 +0200 Subject: [PATCH 2/8] [ticket/11621] Swap columns of post_content index. PHPBB3-11621 --- phpBB/phpbb/search/fulltext_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index 23f27e65d0..260b07fdf9 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -792,7 +792,7 @@ class fulltext_mysql extends \phpbb\search\base $alter[] = 'MODIFY post_text mediumtext NOT NULL'; } - $alter[] = 'ADD FULLTEXT post_content (post_subject, post_text)'; + $alter[] = 'ADD FULLTEXT post_content (post_text, post_subject)'; } if (sizeof($alter)) From 6e9e07bae2d3b6aefc9292c9447e039e6f713166 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 11 Oct 2013 00:14:50 +0200 Subject: [PATCH 3/8] [ticket/11621] Remove unnecessary things around index_created() return value. PHPBB3-11621 --- phpBB/phpbb/search/fulltext_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/search/fulltext_mysql.php b/phpBB/phpbb/search/fulltext_mysql.php index 260b07fdf9..ca2f42358f 100644 --- a/phpBB/phpbb/search/fulltext_mysql.php +++ b/phpBB/phpbb/search/fulltext_mysql.php @@ -855,7 +855,7 @@ class fulltext_mysql extends \phpbb\search\base $this->get_stats(); } - return (isset($this->stats['post_subject']) && isset($this->stats['post_content'])) ? true : false; + return isset($this->stats['post_subject']) && isset($this->stats['post_content']); } /** From 39f77149b2922224bc1a9d741357bf54abec49d9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 11 Oct 2013 00:23:04 +0200 Subject: [PATCH 4/8] [ticket/11621] Add migration dropping MySQL search indexes. Possibly time-consuming index-regeneration will be left to the user. PHPBB3-11621 --- .../data/v310/mysql_fulltext_drop.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php diff --git a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php new file mode 100644 index 0000000000..2bb64bdef4 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php @@ -0,0 +1,38 @@ +db->sql_layer, 'mysql') === false) + { + return array(); + } + + return array( + 'drop_keys' => array( + $this->table_prefix . 'posts' => array( + 'post_subject', + 'post_text', + 'post_content', + ), + ), + ); + } +} From a30f1729d8cb36d9d52167c08a139c99c63c4fdf Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 11 Oct 2013 14:09:29 +0200 Subject: [PATCH 5/8] [ticket/11621] Use effectively_installed() instead. PHPBB3-11621 --- .../db/migration/data/v310/mysql_fulltext_drop.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php index 2bb64bdef4..13db2f2a40 100644 --- a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php +++ b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php @@ -11,6 +11,12 @@ namespace phpbb\db\migration\data\v310; class mysql_fulltext_drop extends \phpbb\db\migration\migration { + public function effectively_installed() + { + // This migration is irrelevant for all non-MySQL DBMSes. + return strpos($this->db->sql_layer, 'mysql') === false; + } + static public function depends_on() { return array( @@ -20,11 +26,6 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration public function update_schema() { - if (strpos($this->db->sql_layer, 'mysql') === false) - { - return array(); - } - return array( 'drop_keys' => array( $this->table_prefix . 'posts' => array( From a049c4f0afdf558d1f895b20917bddee81a18350 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 11 Oct 2013 14:16:58 +0200 Subject: [PATCH 6/8] [ticket/11621] Put mysql_fulltext_drop into alpha1 migration. PHPBB3-11621 --- phpBB/phpbb/db/migration/data/v310/alpha1.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/phpbb/db/migration/data/v310/alpha1.php b/phpBB/phpbb/db/migration/data/v310/alpha1.php index 04f195daeb..bd4861b1f5 100644 --- a/phpBB/phpbb/db/migration/data/v310/alpha1.php +++ b/phpBB/phpbb/db/migration/data/v310/alpha1.php @@ -24,6 +24,7 @@ class alpha1 extends \phpbb\db\migration\migration '\phpbb\db\migration\data\v310\config_db_text', '\phpbb\db\migration\data\v310\forgot_password', '\phpbb\db\migration\data\v310\mod_rewrite', + '\phpbb\db\migration\data\v310\mysql_fulltext_drop', '\phpbb\db\migration\data\v310\namespaces', '\phpbb\db\migration\data\v310\notifications_cron', '\phpbb\db\migration\data\v310\notification_options_reconvert', From 4c560806085f38e33fa0a2e726f99e7d5c457369 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 11 Oct 2013 16:02:56 +0200 Subject: [PATCH 7/8] [ticket/11621] Correct GPLv2 link in file header. PHPBB3-11621 --- phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php index 13db2f2a40..def4163190 100644 --- a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php +++ b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php @@ -3,7 +3,7 @@ * * @package migration * @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2 +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ From 6ccceca064929af4f1c59da56586e3d3003bcdda Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 13 Oct 2013 14:25:28 +0200 Subject: [PATCH 8/8] [ticket/11621] Add explanation to mysql_fulltext_drop. PHPBB3-11621 --- .../phpbb/db/migration/data/v310/mysql_fulltext_drop.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php index def4163190..97d174d4bc 100644 --- a/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php +++ b/phpBB/phpbb/db/migration/data/v310/mysql_fulltext_drop.php @@ -26,6 +26,14 @@ class mysql_fulltext_drop extends \phpbb\db\migration\migration public function update_schema() { + /* + * Drop FULLTEXT indexes related to MySQL fulltext search. + * Doing so is equivalent to dropping the search index from the ACP. + * Possibly time-consuming recreation of the search index (i.e. + * FULLTEXT indexes) is left as a task to the admin to not + * unnecessarily stall the upgrade process. The new search index will + * then require about 40% less table space (also see PHPBB3-11621). + */ return array( 'drop_keys' => array( $this->table_prefix . 'posts' => array(