From cf4b639be5a178c73224246b1232e5044b9a5738 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 3 Jul 2011 02:15:40 -0400 Subject: [PATCH 1/6] [ticket/10247] Remove unecessary attempt_id primary key column The database update drops any key of the same name (potential primary key) and afterwards the column. This does not work on some of the supported DBMS and needs further changes. PHPBB3-10247 --- phpBB/develop/create_schema_files.php | 2 -- phpBB/install/database_update.php | 12 +++++++++++- phpBB/install/schemas/firebird_schema.sql | 14 -------------- phpBB/install/schemas/mssql_schema.sql | 8 -------- phpBB/install/schemas/mysql_40_schema.sql | 2 -- phpBB/install/schemas/mysql_41_schema.sql | 2 -- phpBB/install/schemas/oracle_schema.sql | 20 +------------------- phpBB/install/schemas/postgres_schema.sql | 6 +----- phpBB/install/schemas/sqlite_schema.sql | 1 - 9 files changed, 13 insertions(+), 54 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index f4d89e5562..efe8837b26 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1223,7 +1223,6 @@ function get_schema_struct() $schema_data['phpbb_login_attempts'] = array( 'COLUMNS' => array( - 'attempt_id' => array('UINT', NULL, 'auto_increment'), 'attempt_ip' => array('VCHAR:40', ''), 'attempt_browser' => array('VCHAR:150', ''), 'attempt_forwarded_for' => array('VCHAR:255', ''), @@ -1232,7 +1231,6 @@ function get_schema_struct() 'username' => array('VCHAR_UNI:255', 0), 'username_clean' => array('VCHAR_CI', 0), ), - 'PRIMARY_KEY' => 'attempt_id', 'KEYS' => array( 'att_ip' => array('INDEX', array('attempt_ip', 'attempt_time')), 'att_for' => array('INDEX', array('attempt_forwarded_for', 'attempt_time')), diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 92bafcb32a..72eb8a6480 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -define('UPDATES_TO_VERSION', '3.0.9-RC3'); +define('UPDATES_TO_VERSION', '3.0.9-RC4'); // Enter any version to update from to test updates. The version within the db will not be updated. define('DEBUG_FROM_VERSION', false); @@ -974,6 +974,16 @@ function database_update_info() '3.0.9-RC1' => array(), // No changes from 3.0.9-RC2 to 3.0.9-RC3 '3.0.9-RC2' => array(), + + // Changes from 3.0.9-RC-3 to 3.0.9-RC4 + '3.0.9-RC3' => array( + 'drop_keys' => array( + LOGIN_ATTEMPT_TABLE => array('attempt_id') + ), + 'drop_columns' => array( + LOGIN_ATTEMPT_TABLE => array('attempt_id') + ), + ), ); } diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 5df7dfe9a5..40041b13cb 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -547,7 +547,6 @@ END;; # Table: 'phpbb_login_attempts' CREATE TABLE phpbb_login_attempts ( - attempt_id INTEGER NOT NULL, attempt_ip VARCHAR(40) CHARACTER SET NONE DEFAULT '' NOT NULL, attempt_browser VARCHAR(150) CHARACTER SET NONE DEFAULT '' NOT NULL, attempt_forwarded_for VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, @@ -557,24 +556,11 @@ CREATE TABLE phpbb_login_attempts ( username_clean VARCHAR(255) CHARACTER SET UTF8 DEFAULT 0 NOT NULL COLLATE UNICODE );; -ALTER TABLE phpbb_login_attempts ADD PRIMARY KEY (attempt_id);; - CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts(attempt_ip, attempt_time);; CREATE INDEX phpbb_login_attempts_att_for ON phpbb_login_attempts(attempt_forwarded_for, attempt_time);; CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts(attempt_time);; CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts(user_id);; -CREATE GENERATOR phpbb_login_attempts_gen;; -SET GENERATOR phpbb_login_attempts_gen TO 0;; - -CREATE TRIGGER t_phpbb_login_attempts FOR phpbb_login_attempts -BEFORE INSERT -AS -BEGIN - NEW.attempt_id = GEN_ID(phpbb_login_attempts_gen, 1); -END;; - - # Table: 'phpbb_moderator_cache' CREATE TABLE phpbb_moderator_cache ( forum_id INTEGER DEFAULT 0 NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 0bc76c05e6..c4fc2d4eec 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -653,7 +653,6 @@ GO Table: 'phpbb_login_attempts' */ CREATE TABLE [phpbb_login_attempts] ( - [attempt_id] [int] IDENTITY (1, 1) NOT NULL , [attempt_ip] [varchar] (40) DEFAULT ('') NOT NULL , [attempt_browser] [varchar] (150) DEFAULT ('') NOT NULL , [attempt_forwarded_for] [varchar] (255) DEFAULT ('') NOT NULL , @@ -664,13 +663,6 @@ CREATE TABLE [phpbb_login_attempts] ( ) ON [PRIMARY] GO -ALTER TABLE [phpbb_login_attempts] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_login_attempts] PRIMARY KEY CLUSTERED - ( - [attempt_id] - ) ON [PRIMARY] -GO - CREATE INDEX [att_ip] ON [phpbb_login_attempts]([attempt_ip], [attempt_time]) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 6b13485a3d..06d32166f3 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -371,7 +371,6 @@ CREATE TABLE phpbb_log ( # Table: 'phpbb_login_attempts' CREATE TABLE phpbb_login_attempts ( - attempt_id mediumint(8) UNSIGNED NOT NULL auto_increment, attempt_ip varbinary(40) DEFAULT '' NOT NULL, attempt_browser varbinary(150) DEFAULT '' NOT NULL, attempt_forwarded_for varbinary(255) DEFAULT '' NOT NULL, @@ -379,7 +378,6 @@ CREATE TABLE phpbb_login_attempts ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, username blob NOT NULL, username_clean blob NOT NULL, - PRIMARY KEY (attempt_id), KEY att_ip (attempt_ip, attempt_time), KEY att_for (attempt_forwarded_for, attempt_time), KEY att_time (attempt_time), diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index b400e8fcff..1db2790ec7 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -371,7 +371,6 @@ CREATE TABLE phpbb_log ( # Table: 'phpbb_login_attempts' CREATE TABLE phpbb_login_attempts ( - attempt_id mediumint(8) UNSIGNED NOT NULL auto_increment, attempt_ip varchar(40) DEFAULT '' NOT NULL, attempt_browser varchar(150) DEFAULT '' NOT NULL, attempt_forwarded_for varchar(255) DEFAULT '' NOT NULL, @@ -379,7 +378,6 @@ CREATE TABLE phpbb_login_attempts ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, username varchar(255) DEFAULT '0' NOT NULL, username_clean varchar(255) DEFAULT '0' NOT NULL, - PRIMARY KEY (attempt_id), KEY att_ip (attempt_ip, attempt_time), KEY att_for (attempt_forwarded_for, attempt_time), KEY att_time (attempt_time), diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 8c79e870cb..783261e365 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -744,15 +744,13 @@ END; Table: 'phpbb_login_attempts' */ CREATE TABLE phpbb_login_attempts ( - attempt_id number(8) NOT NULL, attempt_ip varchar2(40) DEFAULT '' , attempt_browser varchar2(150) DEFAULT '' , attempt_forwarded_for varchar2(255) DEFAULT '' , attempt_time number(11) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, username varchar2(765) DEFAULT '0' NOT NULL, - username_clean varchar2(255) DEFAULT '0' NOT NULL, - CONSTRAINT pk_phpbb_login_attempts PRIMARY KEY (attempt_id) + username_clean varchar2(255) DEFAULT '0' NOT NULL ) / @@ -765,22 +763,6 @@ CREATE INDEX phpbb_login_attempts_att_time ON phpbb_login_attempts (attempt_time CREATE INDEX phpbb_login_attempts_user_id ON phpbb_login_attempts (user_id) / -CREATE SEQUENCE phpbb_login_attempts_seq -/ - -CREATE OR REPLACE TRIGGER t_phpbb_login_attempts -BEFORE INSERT ON phpbb_login_attempts -FOR EACH ROW WHEN ( - new.attempt_id IS NULL OR new.attempt_id = 0 -) -BEGIN - SELECT phpbb_login_attempts_seq.nextval - INTO :new.attempt_id - FROM dual; -END; -/ - - /* Table: 'phpbb_moderator_cache' */ diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 359ec325d7..cf655cb1c7 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -527,18 +527,14 @@ CREATE INDEX phpbb_log_user_id ON phpbb_log (user_id); /* Table: 'phpbb_login_attempts' */ -CREATE SEQUENCE phpbb_login_attempts_seq; - CREATE TABLE phpbb_login_attempts ( - attempt_id INT4 DEFAULT nextval('phpbb_login_attempts_seq'), attempt_ip varchar(40) DEFAULT '' NOT NULL, attempt_browser varchar(150) DEFAULT '' NOT NULL, attempt_forwarded_for varchar(255) DEFAULT '' NOT NULL, attempt_time INT4 DEFAULT '0' NOT NULL CHECK (attempt_time >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), username varchar(255) DEFAULT '0' NOT NULL, - username_clean varchar_ci DEFAULT '0' NOT NULL, - PRIMARY KEY (attempt_id) + username_clean varchar_ci DEFAULT '0' NOT NULL ); CREATE INDEX phpbb_login_attempts_att_ip ON phpbb_login_attempts (attempt_ip, attempt_time); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 3158c1a177..dae1eb839c 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -359,7 +359,6 @@ CREATE INDEX phpbb_log_user_id ON phpbb_log (user_id); # Table: 'phpbb_login_attempts' CREATE TABLE phpbb_login_attempts ( - attempt_id INTEGER PRIMARY KEY NOT NULL , attempt_ip varchar(40) NOT NULL DEFAULT '', attempt_browser varchar(150) NOT NULL DEFAULT '', attempt_forwarded_for varchar(255) NOT NULL DEFAULT '', From 984fd07319d9c9dbd8af7298a94e08132e790f98 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 3 Jul 2011 02:29:51 -0400 Subject: [PATCH 2/6] [ticket/10247] Add empty data section to database update for RC4 PHPBB3-10247 --- phpBB/install/database_update.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 72eb8a6480..e1223335f0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1983,6 +1983,10 @@ function change_database_data(&$no_updates, $version) // No changes from 3.0.9-RC2 to 3.0.9-RC3 case '3.0.9-RC2': break; + + // No changes from 3.0.9-RC3 to 3.0.9-RC4 + case '3.0.9-RC3': + break; } } From 96eab49a7a5d803fcc121fe5490b2484c6499d40 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 3 Jul 2011 18:09:56 -0400 Subject: [PATCH 3/6] [ticket/10247] Add a db_tools test for the removal of a primary key column. The previous drop column test already deleted the primary key, so that one was replaced with an ordinary column. PHPBB3-10247 --- tests/dbal/db_tools_test.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index eb2af4c4cc..ddea500f83 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -241,6 +241,15 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case } public function test_column_remove() + { + $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_int_size')); + + $this->assertTrue($this->tools->sql_column_remove('prefix_table_name', 'c_int_size')); + + $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_int_size')); + } + + public function test_column_remove_primary() { $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_id')); @@ -264,5 +273,4 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case $this->tools->sql_table_drop('prefix_test_table'); } - } From cb7604dcd83bf3a4ddf6ace1282974eaf475c8d8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 4 Jul 2011 02:31:00 -0400 Subject: [PATCH 4/6] [ticket/10247] Removing attempt_id column from the 3.0.8 to 3.0.9-RC1 updater. To make sure that this column (which was too small and unecessary) does not remain on 3.0.9-RCX installations and boards that were updated to a 3.0.9 RC, the 3.0.10-RC1 release must correctly drop the column after db_tools has been corrected and fully reviewed. The current version is not capable of dropping primary keys correctly on all supported DBMSs. PHPBB3-10247 --- phpBB/install/database_update.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e1223335f0..a45424afea 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -946,7 +946,12 @@ function database_update_info() 'add_tables' => array( LOGIN_ATTEMPT_TABLE => array( 'COLUMNS' => array( - 'attempt_id' => array('UINT', NULL, 'auto_increment'), + // this column was removed from the database updater + // after 3.0.9-RC3 was released. It might still exist + // in 3.0.9-RCX installations and has to be dropped in + // 3.0.10 after the db_tools class is capable of properly + // removing a primary key. + // 'attempt_id' => array('UINT', NULL, 'auto_increment'), 'attempt_ip' => array('VCHAR:40', ''), 'attempt_browser' => array('VCHAR:150', ''), 'attempt_forwarded_for' => array('VCHAR:255', ''), @@ -974,16 +979,10 @@ function database_update_info() '3.0.9-RC1' => array(), // No changes from 3.0.9-RC2 to 3.0.9-RC3 '3.0.9-RC2' => array(), + // No changes from 3.0.9-RC3 to 3.0.9-RC4 + '3.0.9-RC3' => array(), - // Changes from 3.0.9-RC-3 to 3.0.9-RC4 - '3.0.9-RC3' => array( - 'drop_keys' => array( - LOGIN_ATTEMPT_TABLE => array('attempt_id') - ), - 'drop_columns' => array( - LOGIN_ATTEMPT_TABLE => array('attempt_id') - ), - ), + /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.10-RC1 */ ); } From d8ac2cc5f0c253842185506b174a8355dfd5f3fb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Jul 2011 00:40:45 +0200 Subject: [PATCH 5/6] [prep-release-3.0.9] Bumping version number for the final 3.0.9 release. --- build/build.xml | 6 +++--- phpBB/includes/constants.php | 2 +- phpBB/install/database_update.php | 6 +++--- phpBB/install/schemas/schema_data.sql | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/build.xml b/build/build.xml index ed9643c12f..42642dcefa 100644 --- a/build/build.xml +++ b/build/build.xml @@ -2,9 +2,9 @@ - - - + + + diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 2f485fb4d7..3940888216 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) */ // phpBB Version -define('PHPBB_VERSION', '3.0.9-RC3'); +define('PHPBB_VERSION', '3.0.9'); // QA-related // define('PHPBB_QA', 1); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a45424afea..a2cb4515da 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -define('UPDATES_TO_VERSION', '3.0.9-RC4'); +define('UPDATES_TO_VERSION', '3.0.9'); // Enter any version to update from to test updates. The version within the db will not be updated. define('DEBUG_FROM_VERSION', false); @@ -979,7 +979,7 @@ function database_update_info() '3.0.9-RC1' => array(), // No changes from 3.0.9-RC2 to 3.0.9-RC3 '3.0.9-RC2' => array(), - // No changes from 3.0.9-RC3 to 3.0.9-RC4 + // No changes from 3.0.9-RC3 to 3.0.9 '3.0.9-RC3' => array(), /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.10-RC1 */ @@ -1983,7 +1983,7 @@ function change_database_data(&$no_updates, $version) case '3.0.9-RC2': break; - // No changes from 3.0.9-RC3 to 3.0.9-RC4 + // No changes from 3.0.9-RC3 to 3.0.9 case '3.0.9-RC3': break; } diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index b3f136ff7a..0153bd8ec2 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -245,7 +245,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_path', 'files'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.9-RC3'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.9'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_expire_days', '90'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_gc', '14400'); From 7ca9c33157ad360750df8bf025a1155e14c6b2bb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Jul 2011 00:43:09 +0200 Subject: [PATCH 6/6] [prep-release-3.0.9] Update Changelog for 3.0.9 release. --- phpBB/docs/CHANGELOG.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 6b12cb81bf..c0ec93cafb 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -333,6 +333,8 @@
  • [PHPBB3-10234] - msg_handler() reports E_WARNING as "PHP Notice: "
  • +
  • [PHPBB3-10247] - mediumint(8) too small for phpbb_login_attempts.attempt_id +
  • Improvement