From e5eb7025141238a3486a0395c42c55411dafb259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= Date: Mon, 13 Feb 2017 14:03:54 -0500 Subject: [PATCH 1/8] [ticket/14992] Add indexes to user_notifications table [ticket/14992] Change how index length is checked [ticket/14992] Remove duplicates from user_notifications table [ticket/14992] Add unique index to user_notifications table [ticket/14992] Shorten unique index name [ticket/14992] Shorten another index for user notifications --- .../v32x/user_notifications_table_indexes.php | 50 +++++++++++++++++ ..._notifications_table_remove_duplicates.php | 55 +++++++++++++++++++ .../user_notifications_table_unique_index.php | 46 ++++++++++++++++ phpBB/phpbb/db/tools/tools.php | 14 ++--- 4 files changed, 157 insertions(+), 8 deletions(-) create mode 100644 phpBB/phpbb/db/migration/data/v32x/user_notifications_table_indexes.php create mode 100644 phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php create mode 100644 phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_indexes.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_indexes.php new file mode 100644 index 0000000000..86a3891b46 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_indexes.php @@ -0,0 +1,50 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_indexes extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\cookie_notice_p2', + ); + } + + public function update_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'user_id' => array('user_id'), + 'user_id_item_id' => array('user_id', 'item_id'), + 'user_itm_type_id' => array('user_id', 'item_type', 'item_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'user_id', + 'user_id_item_id', + 'user_itm_type_id', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php new file mode 100644 index 0000000000..f5f0305fda --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php @@ -0,0 +1,55 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_remove_duplicates extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_indexes', + ); + } + + public function update_data() + { + return array( + array('custom', array(array($this, 'remove_duplicates'))), + ); + } + + public function remove_duplicates() + { + $insert_buffer = new \phpbb\db\sql_insert_buffer($this->db, $this->table_prefix . 'user_notifications'); + + $sql = "SELECT item_type, item_id, user_id, method, MAX(notify) AS notify + FROM {$this->table_prefix}user_notifications + GROUP BY item_type, item_id, user_id, method + HAVING COUNT(item_type) > 1"; + + $result = $this->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + // Delete the duplicate entries + $this->sql_query("DELETE FROM {$this->table_prefix}user_notifications + WHERE user_id = {$row['user_id']} + AND item_type = '{$row['item_type']}' + AND method = '{$row['method']}'"); + + // And re-insert as a single one + $insert_buffer->insert($row); + } + $this->db->sql_freeresult($result); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php new file mode 100644 index 0000000000..925197a02b --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php @@ -0,0 +1,46 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_unique_index extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_remove_duplicates', + ); + } + + public function update_schema() + { + return array( + 'add_unique_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id', 'method'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/tools/tools.php b/phpBB/phpbb/db/tools/tools.php index 9273d69cd6..4218addb8e 100644 --- a/phpBB/phpbb/db/tools/tools.php +++ b/phpBB/phpbb/db/tools/tools.php @@ -1487,17 +1487,17 @@ class tools implements tools_interface { $statements = array(); - $this->check_index_name_length($table_name, $index_name); - switch ($this->sql_layer) { case 'oracle': case 'sqlite3': + $this->check_index_name_length($table_name, $table_name . '_' . $index_name); $statements[] = 'CREATE UNIQUE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; case 'mysql_40': case 'mysql_41': + $this->check_index_name_length($table_name, $index_name); $statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX ' . $index_name . '(' . implode(', ', $column) . ')'; break; } @@ -1512,8 +1512,6 @@ class tools implements tools_interface { $statements = array(); - $this->check_index_name_length($table_name, $index_name); - // remove index length unless MySQL4 if ('mysql_40' != $this->sql_layer) { @@ -1524,6 +1522,7 @@ class tools implements tools_interface { case 'oracle': case 'sqlite3': + $this->check_index_name_length($table_name, $table_name . '_' . $index_name); $statements[] = 'CREATE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; @@ -1539,6 +1538,7 @@ class tools implements tools_interface } // no break case 'mysql_41': + $this->check_index_name_length($table_name, $index_name); $statements[] = 'ALTER TABLE ' . $table_name . ' ADD INDEX ' . $index_name . ' (' . implode(', ', $column) . ')'; break; } @@ -1554,11 +1554,9 @@ class tools implements tools_interface */ protected function check_index_name_length($table_name, $index_name) { - $table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config) - if (strlen($table_name . $index_name) - strlen($table_prefix) > 24) + if (strlen($index_name) > 30) { - $max_length = strlen($table_prefix) + 24; - trigger_error("Index name '{$table_name}_$index_name' on table '$table_name' is too long. The maximum is $max_length characters.", E_USER_ERROR); + trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); } } From 59ac4a71b6dc53f2edf8bb5c669b14df9ce5544a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= Date: Wed, 1 Mar 2017 22:55:13 -0500 Subject: [PATCH 2/8] [ticket/14992] Check index name length in a more proper way [ticket/14992] Add indexes to user_notifications table --- ... => user_notifications_table_index_p1.php} | 6 +-- .../user_notifications_table_index_p2.php | 46 +++++++++++++++++++ .../user_notifications_table_index_p3.php | 46 +++++++++++++++++++ ..._notifications_table_remove_duplicates.php | 2 +- .../user_notifications_table_temp_index.php | 46 +++++++++++++++++++ .../user_notifications_table_unique_index.php | 7 ++- phpBB/phpbb/db/tools/tools.php | 45 ++++++++++++++---- 7 files changed, 181 insertions(+), 17 deletions(-) rename phpBB/phpbb/db/migration/data/v32x/{user_notifications_table_indexes.php => user_notifications_table_index_p1.php} (76%) create mode 100644 phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php create mode 100644 phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p3.php create mode 100644 phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_indexes.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p1.php similarity index 76% rename from phpBB/phpbb/db/migration/data/v32x/user_notifications_table_indexes.php rename to phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p1.php index 86a3891b46..93ff31ec6c 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_indexes.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p1.php @@ -13,7 +13,7 @@ namespace phpbb\db\migration\data\v32x; -class user_notifications_table_indexes extends \phpbb\db\migration\migration +class user_notifications_table_index_p1 extends \phpbb\db\migration\migration { static public function depends_on() { @@ -28,8 +28,6 @@ class user_notifications_table_indexes extends \phpbb\db\migration\migration 'add_index' => array( $this->table_prefix . 'user_notifications' => array( 'user_id' => array('user_id'), - 'user_id_item_id' => array('user_id', 'item_id'), - 'user_itm_type_id' => array('user_id', 'item_type', 'item_id'), ), ), ); @@ -41,8 +39,6 @@ class user_notifications_table_indexes extends \phpbb\db\migration\migration 'drop_keys' => array( $this->table_prefix . 'user_notifications' => array( 'user_id', - 'user_id_item_id', - 'user_itm_type_id', ), ), ); diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php new file mode 100644 index 0000000000..e492b4e1f8 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php @@ -0,0 +1,46 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_index_p2 extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_index_p1', + ); + } + + public function update_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'usr_id_itm_id' => array('user_id', 'item_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'usr_id_itm_id', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p3.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p3.php new file mode 100644 index 0000000000..1636b3024a --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p3.php @@ -0,0 +1,46 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_index_p3 extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_index_p2', + ); + } + + public function update_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'usr_itm_tpe' => array('user_id', 'item_type', 'item_id'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'usr_itm_tpe', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php index f5f0305fda..50d0642056 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php @@ -18,7 +18,7 @@ class user_notifications_table_remove_duplicates extends \phpbb\db\migration\mig static public function depends_on() { return array( - '\phpbb\db\migration\data\v32x\user_notifications_table_indexes', + '\phpbb\db\migration\data\v32x\user_notifications_table_temp_index', ); } diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php new file mode 100644 index 0000000000..eea44e168c --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php @@ -0,0 +1,46 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_temp_index extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_index_p3', + ); + } + + public function update_schema() + { + return array( + 'add_index' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id', 'method'), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd', + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php index 925197a02b..51cf90c8a0 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php @@ -25,7 +25,12 @@ class user_notifications_table_unique_index extends \phpbb\db\migration\migratio public function update_schema() { return array( - 'add_unique_index' => array( + 'drop_keys' => array( + $this->table_prefix . 'user_notifications' => array( + 'itm_usr_mthd', + ), + ), + 'add_unique_index' => array( $this->table_prefix . 'user_notifications' => array( 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id', 'method'), ), diff --git a/phpBB/phpbb/db/tools/tools.php b/phpBB/phpbb/db/tools/tools.php index 4218addb8e..112438fcdd 100644 --- a/phpBB/phpbb/db/tools/tools.php +++ b/phpBB/phpbb/db/tools/tools.php @@ -946,7 +946,8 @@ class tools implements tools_interface { case 'oracle': case 'sqlite3': - $row[$col] = substr($row[$col], strlen($table_name) + 1); + $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name, false); + $row[$col] = strpos($row[$col], $table_name) === 0 ? substr($row[$col], strlen($table_name) + 1) : $row[$col]; break; } @@ -1359,12 +1360,14 @@ class tools implements tools_interface { case 'mysql_40': case 'mysql_41': + $index_name = $this->check_index_name_length($table_name, $index_name, false); $statements[] = 'DROP INDEX ' . $index_name . ' ON ' . $table_name; break; case 'oracle': case 'sqlite3': - $statements[] = 'DROP INDEX ' . $table_name . '_' . $index_name; + $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name, false); + $statements[] = 'DROP INDEX ' . $index_name; break; } @@ -1491,13 +1494,13 @@ class tools implements tools_interface { case 'oracle': case 'sqlite3': - $this->check_index_name_length($table_name, $table_name . '_' . $index_name); - $statements[] = 'CREATE UNIQUE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name); + $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; case 'mysql_40': case 'mysql_41': - $this->check_index_name_length($table_name, $index_name); + $index_name = $this->check_index_name_length($table_name, $index_name); $statements[] = 'ALTER TABLE ' . $table_name . ' ADD UNIQUE INDEX ' . $index_name . '(' . implode(', ', $column) . ')'; break; } @@ -1522,8 +1525,8 @@ class tools implements tools_interface { case 'oracle': case 'sqlite3': - $this->check_index_name_length($table_name, $table_name . '_' . $index_name); - $statements[] = 'CREATE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name); + $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; case 'mysql_40': @@ -1538,7 +1541,7 @@ class tools implements tools_interface } // no break case 'mysql_41': - $this->check_index_name_length($table_name, $index_name); + $index_name = $this->check_index_name_length($table_name, $index_name); $statements[] = 'ALTER TABLE ' . $table_name . ' ADD INDEX ' . $index_name . ' (' . implode(', ', $column) . ')'; break; } @@ -1551,13 +1554,35 @@ class tools implements tools_interface * * @param string $table_name * @param string $index_name + * @param bool $throw_error + * @return string The index name, shortened if too long */ - protected function check_index_name_length($table_name, $index_name) + protected function check_index_name_length($table_name, $index_name, $throw_error = true) { if (strlen($index_name) > 30) { - trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); + // Try removing the table prefix if it's at the beginning + $table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config) + if (strpos($index_name, $table_prefix) === 0) + { + $index_name = substr($index_name, strlen($table_prefix) + 1); + return $this->check_index_name_length($table_name, $index_name); + } + + // Try removing the table name then + if (strpos($index_name, $table_name) === 0) + { + $index_name = substr($index_name, strlen($table_name) + 1); + return $this->check_index_name_length($table_name, $index_name); + } + + if ($throw_error) + { + trigger_error("Index name '$index_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR); + } } + + return $index_name; } /** From 11f968e774fed238030f851c4ad90facf86e583f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 21 May 2017 14:18:10 +0200 Subject: [PATCH 3/8] [ticket/14992] Shorten index name for user_id and item_id PHPBB3-14992 --- .../migration/data/v32x/user_notifications_table_index_p2.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php index e492b4e1f8..0a471766a0 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_index_p2.php @@ -27,7 +27,7 @@ class user_notifications_table_index_p2 extends \phpbb\db\migration\migration return array( 'add_index' => array( $this->table_prefix . 'user_notifications' => array( - 'usr_id_itm_id' => array('user_id', 'item_id'), + 'uid_itm_id' => array('user_id', 'item_id'), ), ), ); @@ -38,7 +38,7 @@ class user_notifications_table_index_p2 extends \phpbb\db\migration\migration return array( 'drop_keys' => array( $this->table_prefix . 'user_notifications' => array( - 'usr_id_itm_id', + 'uid_itm_id', ), ), ); From bcc85ab679f6f100d169597990a8ab4138dd3158 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 21 May 2017 15:59:59 +0200 Subject: [PATCH 4/8] [ticket/14992] Correctly remove table name and prefix from keys PHPBB3-14992 --- phpBB/phpbb/db/tools/tools.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/tools/tools.php b/phpBB/phpbb/db/tools/tools.php index 112438fcdd..76036554d2 100644 --- a/phpBB/phpbb/db/tools/tools.php +++ b/phpBB/phpbb/db/tools/tools.php @@ -947,7 +947,19 @@ class tools implements tools_interface case 'oracle': case 'sqlite3': $index_name = $this->check_index_name_length($table_name, $table_name . '_' . $index_name, false); - $row[$col] = strpos($row[$col], $table_name) === 0 ? substr($row[$col], strlen($table_name) + 1) : $row[$col]; + $table_prefix = substr(CONFIG_TABLE, 0, -6); // strlen(config) + + if (strpos($index_name , $table_name) === false) + { + if (strpos($index_name, $table_prefix) !== false) + { + $row[$col] = substr($row[$col], strlen($table_prefix) + 1); + } + else + { + $row[$col] = substr($row[$col], strlen($table_name) + 1); + } + } break; } From f3c782b3584c1c006e5d3da602ff953381f3e6b9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 21 May 2017 16:14:11 +0200 Subject: [PATCH 5/8] [ticket/14992] Make unit tests run more verbose PHPBB3-14992 --- .travis.yml | 2 +- .../migration/data/v32x/user_notifications_table_temp_index.php | 2 +- .../data/v32x/user_notifications_table_unique_index.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2d88c25b34..2f31eb74db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,6 @@ script: - travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION $NOTESTS ./ - sh -c "if [ '$SLOWTESTS' != '1' -a '$DB' = 'mysqli' ]; then phpBB/vendor/bin/phpunit tests/lint_test.php; fi" - - sh -c "if [ '$NOTESTS' != '1' -a '$SLOWTESTS' != '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml; fi" + - sh -c "if [ '$NOTESTS' != '1' -a '$SLOWTESTS' != '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --verbose --stop-on-error; fi" - sh -c "if [ '$SLOWTESTS' = '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --group slow; fi" - sh -c "set -x;if [ '$NOTESTS' = '1' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi" diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php index eea44e168c..a6a321dbde 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php @@ -27,7 +27,7 @@ class user_notifications_table_temp_index extends \phpbb\db\migration\migration return array( 'add_index' => array( $this->table_prefix . 'user_notifications' => array( - 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id', 'method'), + 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id'), ), ), ); diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php index 51cf90c8a0..d279af7fec 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php @@ -32,7 +32,7 @@ class user_notifications_table_unique_index extends \phpbb\db\migration\migratio ), 'add_unique_index' => array( $this->table_prefix . 'user_notifications' => array( - 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id', 'method'), + 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id'), ), ), ); From c2711fb6c46b47a4004319b6887d07487baef0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= Date: Tue, 23 May 2017 13:57:28 -0400 Subject: [PATCH 6/8] [ticket/14992] Remove temp index migration --- ..._notifications_table_remove_duplicates.php | 2 +- .../user_notifications_table_temp_index.php | 46 ------------------- .../user_notifications_table_unique_index.php | 5 -- 3 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php index 50d0642056..371cdf9b3a 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_remove_duplicates.php @@ -18,7 +18,7 @@ class user_notifications_table_remove_duplicates extends \phpbb\db\migration\mig static public function depends_on() { return array( - '\phpbb\db\migration\data\v32x\user_notifications_table_temp_index', + '\phpbb\db\migration\data\v32x\user_notifications_table_index_p3', ); } diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php deleted file mode 100644 index a6a321dbde..0000000000 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_temp_index.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @license GNU General Public License, version 2 (GPL-2.0) - * - * For full copyright and license information, please see - * the docs/CREDITS.txt file. - * - */ - -namespace phpbb\db\migration\data\v32x; - -class user_notifications_table_temp_index extends \phpbb\db\migration\migration -{ - static public function depends_on() - { - return array( - '\phpbb\db\migration\data\v32x\user_notifications_table_index_p3', - ); - } - - public function update_schema() - { - return array( - 'add_index' => array( - $this->table_prefix . 'user_notifications' => array( - 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id'), - ), - ), - ); - } - - public function revert_schema() - { - return array( - 'drop_keys' => array( - $this->table_prefix . 'user_notifications' => array( - 'itm_usr_mthd', - ), - ), - ); - } -} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php index d279af7fec..3145b634c8 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php @@ -25,11 +25,6 @@ class user_notifications_table_unique_index extends \phpbb\db\migration\migratio public function update_schema() { return array( - 'drop_keys' => array( - $this->table_prefix . 'user_notifications' => array( - 'itm_usr_mthd', - ), - ), 'add_unique_index' => array( $this->table_prefix . 'user_notifications' => array( 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id'), From 4c67f65d5db539ffc94259549d1cbf270703d7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= Date: Wed, 24 May 2017 16:56:24 -0400 Subject: [PATCH 7/8] [ticket/14992] 'method' is needed for the unique index --- .../data/v32x/user_notifications_table_unique_index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php index 3145b634c8..157a12472b 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php @@ -27,7 +27,7 @@ class user_notifications_table_unique_index extends \phpbb\db\migration\migratio return array( 'add_unique_index' => array( $this->table_prefix . 'user_notifications' => array( - 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id'), + 'itm_usr_mthd' => array('item_type', 'item_id', 'user_id', 'method'), ), ), ); From a6317dc52dded6eeb3adb174b5d843673b7dbc15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Col=C3=B3n?= Date: Wed, 24 May 2017 17:34:17 -0400 Subject: [PATCH 8/8] [ticket/14992] Reduce notification table col sizes --- ...otifications_table_reduce_column_sizes.php | 48 +++++++++++++++++++ .../user_notifications_table_unique_index.php | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 phpBB/phpbb/db/migration/data/v32x/user_notifications_table_reduce_column_sizes.php diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_reduce_column_sizes.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_reduce_column_sizes.php new file mode 100644 index 0000000000..c2efb8fd4f --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_reduce_column_sizes.php @@ -0,0 +1,48 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\db\migration\data\v32x; + +class user_notifications_table_reduce_column_sizes extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return array( + '\phpbb\db\migration\data\v32x\user_notifications_table_remove_duplicates', + ); + } + + public function update_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'user_notifications' => array( + 'item_type' => array('VCHAR:165', ''), + 'method' => array('VCHAR:165', ''), + ), + ), + ); + } + + public function revert_schema() + { + return array( + 'change_columns' => array( + $this->table_prefix . 'user_notifications' => array( + 'item_type' => array('VCHAR:255', ''), + 'method' => array('VCHAR:255', ''), + ), + ), + ); + } +} diff --git a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php index 157a12472b..e46c231b7b 100644 --- a/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php +++ b/phpBB/phpbb/db/migration/data/v32x/user_notifications_table_unique_index.php @@ -18,7 +18,7 @@ class user_notifications_table_unique_index extends \phpbb\db\migration\migratio static public function depends_on() { return array( - '\phpbb\db\migration\data\v32x\user_notifications_table_remove_duplicates', + '\phpbb\db\migration\data\v32x\user_notifications_table_reduce_column_sizes', ); }