From b59463552644ca4afd9e8ca7edd761ae382fc8ed Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 13:09:34 -0500 Subject: [ticket/11103] Add tables to the database updater and installer PHPBB3-11103 --- phpBB/install/database_update.php | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0b470ced26..99e40ddee9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -106,6 +106,14 @@ if (!defined('EXT_TABLE')) { define('EXT_TABLE', $table_prefix . 'ext'); } +if (!defined('NOTIFICATIONS_TABLE')) +{ + define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); +} +if (!defined('USER_NOTIFICATIONS_TABLE')) +{ + define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications'); +} $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); $phpbb_class_loader_ext->register(); @@ -1097,6 +1105,45 @@ function database_update_info() 'ext_name' => array('UNIQUE', 'ext_name'), ), ), + NOTIFICATIONS_TABLE => array( + 'COLUMNS' => array( + 'item_type' => array('UINT', 0), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'unread' => array('BOOL', 1), + 'time' => array('TIMESTAMP', 1), + 'data' => array('TEXT_UNI', ''), + ), + 'PRIMARY_KEY' => array( + 'item_type', + 'item_id', + 'user_id', + ), + 'KEYS' => array( + 'item_type' => array('INDEX', 'item_type'), + 'item_id' => array('INDEX', 'item_id'), + 'user_id' => array('INDEX', 'user_id'), + 'time' => array('INDEX', 'time'), + ), + ), + USER_NOTIFICATIONS_TABLE => array( + 'COLUMNS' => array( + 'item_type' => array('UINT', 0), + 'item_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'method' => array('VCHAR:25', ''), + ), + 'PRIMARY_KEY' => array( + 'item_type', + 'item_id', + 'user_id', + 'method', + ), + 'KEYS' => array( + 'it' => array('INDEX', 'item_type'), + 'uid' => array('INDEX', 'user_id'), + ), + ), ), 'add_columns' => array( GROUPS_TABLE => array( -- cgit v1.2.1 From 1e53f7df9d430422e7bb827f3449ef744fc1ed6f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Sep 2012 16:02:32 -0500 Subject: [ticket/11103] Fixing some db columns that were of the incorrect type PHPBB3-11103 --- phpBB/install/database_update.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 99e40ddee9..c3c2da4451 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1107,7 +1107,7 @@ function database_update_info() ), NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), @@ -1128,7 +1128,7 @@ function database_update_info() ), USER_NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( - 'item_type' => array('UINT', 0), + 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'method' => array('VCHAR:25', ''), @@ -2676,10 +2676,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) -- cgit v1.2.1 From fb0ed78c8fffe95d40e47c8dd27d44973eba88ae Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 14 Sep 2012 15:59:13 -0500 Subject: [ticket/11103] Store the item's parent id for marking things read Mark topics/posts read from the markread() function. Identify unread items by a grey background in the header (for now) PHPBB3-11103 --- phpBB/install/database_update.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c3c2da4451..a79c04f8df 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1109,6 +1109,7 @@ function database_update_info() 'COLUMNS' => array( 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), + 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), 'time' => array('TIMESTAMP', 1), @@ -1122,8 +1123,10 @@ function database_update_info() 'KEYS' => array( 'item_type' => array('INDEX', 'item_type'), 'item_id' => array('INDEX', 'item_id'), + 'item_pid' => array('INDEX', 'item_parent_id'), 'user_id' => array('INDEX', 'user_id'), 'time' => array('INDEX', 'time'), + 'unread' => array('INDEX', 'unread'), ), ), USER_NOTIFICATIONS_TABLE => array( -- cgit v1.2.1 From 7589a3093d95048f5a8cfdc6259501f43fd3fe10 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 14 Sep 2012 18:30:12 -0500 Subject: [ticket/11103] Display all unread notifications by default Add unread count to the page title PHPBB3-11103 --- phpBB/install/database_update.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 562871be57..5048403881 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1127,6 +1127,7 @@ function database_update_info() ), NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( + 'notification_id' => array('UINT', NULL, 'auto_increment'), 'item_type' => array('VCHAR:25', ''), 'item_id' => array('UINT', 0), 'item_parent_id' => array('UINT', 0), @@ -1135,11 +1136,7 @@ function database_update_info() 'time' => array('TIMESTAMP', 1), 'data' => array('TEXT_UNI', ''), ), - 'PRIMARY_KEY' => array( - 'item_type', - 'item_id', - 'user_id', - ), + 'PRIMARY_KEY' => 'notification_id', 'KEYS' => array( 'item_type' => array('INDEX', 'item_type'), 'item_id' => array('INDEX', 'item_id'), -- cgit v1.2.1 From d07cb7b2af2cb7f4ec9459e035561e89f1e69f5c Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 27 Sep 2012 18:56:15 -0500 Subject: [ticket/11103] UCP Notifications module added to db updater PHPBB3-11103 --- phpBB/install/database_update.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1c9070a54a..39544bf9ca 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2465,6 +2465,13 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), + 'notification_options' => array( + 'base' => 'ucp_notification_options', + 'class' => 'ucp', + 'title' => 'UCP_NOTIFICATION_OPTIONS', + 'auth' => '', + 'cat' => 'UCP_MAIN', + ), ); _add_modules($modules_to_install); @@ -2732,7 +2739,7 @@ function change_database_data(&$no_updates, $version) // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } - + if (!isset($config['site_home_url'])) { $config->set('site_home_url', ''); -- cgit v1.2.1 From dfb17f444ae560a0af1b242cfbf85008cd993816 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 27 Sep 2012 19:04:47 -0500 Subject: [ticket/11103] Fix module setup, add explanation to template PHPBB3-11103 --- phpBB/install/database_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 39544bf9ca..b3a1213bb1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2465,8 +2465,8 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), - 'notification_options' => array( - 'base' => 'ucp_notification_options', + 'notifications' => array( + 'base' => 'ucp_notifications', 'class' => 'ucp', 'title' => 'UCP_NOTIFICATION_OPTIONS', 'auth' => '', -- cgit v1.2.1 From fa605402f79e54c5ac5e1af4f08683c1c17d5201 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 4 Oct 2012 20:48:19 -0500 Subject: [ticket/11103] Create schema files with notification tables PHPBB3-11103 --- phpBB/install/schemas/firebird_schema.sql | 45 ++++++++++++++++++++ phpBB/install/schemas/mssql_schema.sql | 71 ++++++++++++++++++++++++++++++- phpBB/install/schemas/mysql_40_schema.sql | 32 ++++++++++++++ phpBB/install/schemas/mysql_41_schema.sql | 32 ++++++++++++++ phpBB/install/schemas/oracle_schema.sql | 62 +++++++++++++++++++++++++++ phpBB/install/schemas/postgres_schema.sql | 38 +++++++++++++++++ phpBB/install/schemas/sqlite_schema.sql | 31 ++++++++++++++ 7 files changed, 310 insertions(+), 1 deletion(-) (limited to 'phpBB/install') diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 588557b92a..a122f5818f 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -618,6 +618,38 @@ BEGIN END;; +# Table: 'phpbb_notifications' +CREATE TABLE phpbb_notifications ( + notification_id INTEGER NOT NULL, + item_type VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL, + item_id INTEGER DEFAULT 0 NOT NULL, + item_parent_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + unread INTEGER DEFAULT 1 NOT NULL, + time INTEGER DEFAULT 1 NOT NULL, + data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_notifications ADD PRIMARY KEY (notification_id);; + +CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications(item_type);; +CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications(item_id);; +CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications(item_parent_id);; +CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications(user_id);; +CREATE INDEX phpbb_notifications_time ON phpbb_notifications(time);; +CREATE INDEX phpbb_notifications_unread ON phpbb_notifications(unread);; + +CREATE GENERATOR phpbb_notifications_gen;; +SET GENERATOR phpbb_notifications_gen TO 0;; + +CREATE TRIGGER t_phpbb_notifications FOR phpbb_notifications +BEFORE INSERT +AS +BEGIN + NEW.notification_id = GEN_ID(phpbb_notifications_gen, 1); +END;; + + # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( poll_option_id INTEGER DEFAULT 0 NOT NULL, @@ -1201,6 +1233,19 @@ CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch(topic_id);; CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch(user_id);; CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status);; +# Table: 'phpbb_user_notifications' +CREATE TABLE phpbb_user_notifications ( + item_type VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL, + item_id INTEGER DEFAULT 0 NOT NULL, + user_id INTEGER DEFAULT 0 NOT NULL, + method VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL +);; + +ALTER TABLE phpbb_user_notifications ADD PRIMARY KEY (item_type, item_id, user_id, method);; + +CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications(item_type);; +CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications(user_id);; + # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( group_id INTEGER DEFAULT 0 NOT NULL, diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 9d0e81a66d..d056e4ceb5 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -751,6 +751,47 @@ CREATE INDEX [class_left_id] ON [phpbb_modules]([module_class], [left_id]) ON [ GO +/* + Table: 'phpbb_notifications' +*/ +CREATE TABLE [phpbb_notifications] ( + [notification_id] [int] IDENTITY (1, 1) NOT NULL , + [item_type] [varchar] (25) DEFAULT ('') NOT NULL , + [item_id] [int] DEFAULT (0) NOT NULL , + [item_parent_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [unread] [int] DEFAULT (1) NOT NULL , + [time] [int] DEFAULT (1) NOT NULL , + [data] [varchar] (4000) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_notifications] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_notifications] PRIMARY KEY CLUSTERED + ( + [notification_id] + ) ON [PRIMARY] +GO + +CREATE INDEX [item_type] ON [phpbb_notifications]([item_type]) ON [PRIMARY] +GO + +CREATE INDEX [item_id] ON [phpbb_notifications]([item_id]) ON [PRIMARY] +GO + +CREATE INDEX [item_pid] ON [phpbb_notifications]([item_parent_id]) ON [PRIMARY] +GO + +CREATE INDEX [user_id] ON [phpbb_notifications]([user_id]) ON [PRIMARY] +GO + +CREATE INDEX [time] ON [phpbb_notifications]([time]) ON [PRIMARY] +GO + +CREATE INDEX [unread] ON [phpbb_notifications]([unread]) ON [PRIMARY] +GO + + /* Table: 'phpbb_poll_options' */ @@ -1110,7 +1151,7 @@ CREATE TABLE [phpbb_reports] ( [report_closed] [int] DEFAULT (0) NOT NULL , [report_time] [int] DEFAULT (0) NOT NULL , [report_text] [text] DEFAULT ('') NOT NULL , - [reported_post_text] [text] DEFAULT ('') NOT NULL + [reported_post_text] [text] DEFAULT ('') NOT NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO @@ -1474,6 +1515,34 @@ CREATE INDEX [notify_stat] ON [phpbb_topics_watch]([notify_status]) ON [PRIMARY GO +/* + Table: 'phpbb_user_notifications' +*/ +CREATE TABLE [phpbb_user_notifications] ( + [item_type] [varchar] (25) DEFAULT ('') NOT NULL , + [item_id] [int] DEFAULT (0) NOT NULL , + [user_id] [int] DEFAULT (0) NOT NULL , + [method] [varchar] (25) DEFAULT ('') NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_user_notifications] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_user_notifications] PRIMARY KEY CLUSTERED + ( + [item_type], + [item_id], + [user_id], + [method] + ) ON [PRIMARY] +GO + +CREATE INDEX [it] ON [phpbb_user_notifications]([item_type]) ON [PRIMARY] +GO + +CREATE INDEX [uid] ON [phpbb_user_notifications]([user_id]) ON [PRIMARY] +GO + + /* Table: 'phpbb_user_group' */ diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index e71afcd5b3..eff9dc46b8 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -430,6 +430,26 @@ CREATE TABLE phpbb_modules ( ); +# Table: 'phpbb_notifications' +CREATE TABLE phpbb_notifications ( + notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, + item_type varbinary(25) DEFAULT '' NOT NULL, + item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + time int(11) UNSIGNED DEFAULT '1' NOT NULL, + data blob NOT NULL, + PRIMARY KEY (notification_id), + KEY item_type (item_type), + KEY item_id (item_id), + KEY item_pid (item_parent_id), + KEY user_id (user_id), + KEY time (time), + KEY unread (unread) +); + + # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( poll_option_id tinyint(4) DEFAULT '0' NOT NULL, @@ -849,6 +869,18 @@ CREATE TABLE phpbb_topics_watch ( ); +# Table: 'phpbb_user_notifications' +CREATE TABLE phpbb_user_notifications ( + item_type varbinary(25) DEFAULT '' NOT NULL, + item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + method varbinary(25) DEFAULT '' NOT NULL, + PRIMARY KEY (item_type, item_id, user_id, method), + KEY it (item_type), + KEY uid (user_id) +); + + # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 20af6f3566..e7e3018572 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -430,6 +430,26 @@ CREATE TABLE phpbb_modules ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_notifications' +CREATE TABLE phpbb_notifications ( + notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, + item_type varchar(25) DEFAULT '' NOT NULL, + item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + time int(11) UNSIGNED DEFAULT '1' NOT NULL, + data text NOT NULL, + PRIMARY KEY (notification_id), + KEY item_type (item_type), + KEY item_id (item_id), + KEY item_pid (item_parent_id), + KEY user_id (user_id), + KEY time (time), + KEY unread (unread) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( poll_option_id tinyint(4) DEFAULT '0' NOT NULL, @@ -849,6 +869,18 @@ CREATE TABLE phpbb_topics_watch ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_user_notifications' +CREATE TABLE phpbb_user_notifications ( + item_type varchar(25) DEFAULT '' NOT NULL, + item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + method varchar(25) DEFAULT '' NOT NULL, + PRIMARY KEY (item_type, item_id, user_id, method), + KEY it (item_type), + KEY uid (user_id) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( group_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 04155fe28b..6269cfcdbc 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -840,6 +840,51 @@ END; / +/* + Table: 'phpbb_notifications' +*/ +CREATE TABLE phpbb_notifications ( + notification_id number(8) NOT NULL, + item_type varchar2(25) DEFAULT '' , + item_id number(8) DEFAULT '0' NOT NULL, + item_parent_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + unread number(1) DEFAULT '1' NOT NULL, + time number(11) DEFAULT '1' NOT NULL, + data clob DEFAULT '' , + CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) +) +/ + +CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type) +/ +CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id) +/ +CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id) +/ +CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id) +/ +CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time) +/ +CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread) +/ + +CREATE SEQUENCE phpbb_notifications_seq +/ + +CREATE OR REPLACE TRIGGER t_phpbb_notifications +BEFORE INSERT ON phpbb_notifications +FOR EACH ROW WHEN ( + new.notification_id IS NULL OR new.notification_id = 0 +) +BEGIN + SELECT phpbb_notifications_seq.nextval + INTO :new.notification_id + FROM dual; +END; +/ + + /* Table: 'phpbb_poll_options' */ @@ -1589,6 +1634,23 @@ CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id) CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status) / +/* + Table: 'phpbb_user_notifications' +*/ +CREATE TABLE phpbb_user_notifications ( + item_type varchar2(25) DEFAULT '' , + item_id number(8) DEFAULT '0' NOT NULL, + user_id number(8) DEFAULT '0' NOT NULL, + method varchar2(25) DEFAULT '' , + CONSTRAINT pk_phpbb_user_notifications PRIMARY KEY (item_type, item_id, user_id, method) +) +/ + +CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type) +/ +CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id) +/ + /* Table: 'phpbb_user_group' */ diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 659a32bf19..d8716be70d 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -596,6 +596,30 @@ CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); +/* + Table: 'phpbb_notifications' +*/ +CREATE SEQUENCE phpbb_notifications_seq; + +CREATE TABLE phpbb_notifications ( + notification_id INT4 DEFAULT nextval('phpbb_notifications_seq'), + item_type varchar(25) DEFAULT '' NOT NULL, + item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), + item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0), + time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0), + data varchar(4000) DEFAULT '' NOT NULL, + PRIMARY KEY (notification_id) +); + +CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type); +CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id); +CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id); +CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); +CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); +CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); + /* Table: 'phpbb_poll_options' */ @@ -1093,6 +1117,20 @@ CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch (topic_id); CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id); CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status); +/* + Table: 'phpbb_user_notifications' +*/ +CREATE TABLE phpbb_user_notifications ( + item_type varchar(25) DEFAULT '' NOT NULL, + item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), + user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), + method varchar(25) DEFAULT '' NOT NULL, + PRIMARY KEY (item_type, item_id, user_id, method) +); + +CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type); +CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id); + /* Table: 'phpbb_user_group' */ diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 8360bc30ea..4cb20b868f 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -417,6 +417,25 @@ CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); +# Table: 'phpbb_notifications' +CREATE TABLE phpbb_notifications ( + notification_id INTEGER PRIMARY KEY NOT NULL , + item_type varchar(25) NOT NULL DEFAULT '', + item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + unread INTEGER UNSIGNED NOT NULL DEFAULT '1', + time INTEGER UNSIGNED NOT NULL DEFAULT '1', + data text(65535) NOT NULL DEFAULT '' +); + +CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type); +CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id); +CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id); +CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); +CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); +CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); + # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( poll_option_id tinyint(4) NOT NULL DEFAULT '0', @@ -823,6 +842,18 @@ CREATE INDEX phpbb_topics_watch_topic_id ON phpbb_topics_watch (topic_id); CREATE INDEX phpbb_topics_watch_user_id ON phpbb_topics_watch (user_id); CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status); +# Table: 'phpbb_user_notifications' +CREATE TABLE phpbb_user_notifications ( + item_type varchar(25) NOT NULL DEFAULT '', + item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', + method varchar(25) NOT NULL DEFAULT '', + PRIMARY KEY (item_type, item_id, user_id, method) +); + +CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type); +CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id); + # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( group_id INTEGER UNSIGNED NOT NULL DEFAULT '0', -- cgit v1.2.1 From 0bab8ff777bcb82361b75441c085ee2e510db5cc Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Oct 2012 13:43:03 -0500 Subject: [ticket/11103] ACP option to enable/disable notifications output in header PHPBB3-11103 --- phpBB/install/database_update.php | 5 +++++ phpBB/install/schemas/schema_data.sql | 1 + 2 files changed, 6 insertions(+) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b3a1213bb1..9cb0785c89 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2746,6 +2746,11 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_text', ''); } + if (!isset($config['load_notifications'])) + { + $config->set('load_notifications', 1); + } + break; } } diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index dbb5fd7481..0d47f4995e 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -175,6 +175,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_cdn', INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jumpbox', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_moderators', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_notifications', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_guests', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time', '5'); -- cgit v1.2.1 From 948bd69495175db6967c0f5e99c3e0ba31e1882a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Oct 2012 13:54:27 -0500 Subject: [ticket/11103] Move UCP Notification Options to Board Preferences tab Also rename to "Edit notification options" for consistency PHPBB3-11103 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 9cb0785c89..965cb45dce 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2470,7 +2470,7 @@ function change_database_data(&$no_updates, $version) 'class' => 'ucp', 'title' => 'UCP_NOTIFICATION_OPTIONS', 'auth' => '', - 'cat' => 'UCP_MAIN', + 'cat' => 'UCP_PREFS', ), ); -- cgit v1.2.1 From cb937841269017d13058208378e4c9ad79718c6e Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 13 Oct 2012 20:02:38 -0500 Subject: [ticket/11103] UCP Notification List PHPBB3-11103 --- phpBB/install/database_update.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 76af67545a..958db6b531 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2465,13 +2465,20 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), - 'notifications' => array( + 'notification_options' => array( 'base' => 'ucp_notifications', 'class' => 'ucp', 'title' => 'UCP_NOTIFICATION_OPTIONS', 'auth' => '', 'cat' => 'UCP_PREFS', ), + 'notification_list' => array( + 'base' => 'ucp_notifications', + 'class' => 'ucp', + 'title' => 'UCP_NOTIFICATION_LIST', + 'auth' => '', + 'cat' => 'UCP_MAIN', + ), ); _add_modules($modules_to_install); -- cgit v1.2.1 From 94ffbb4050b2985ee62be0ecc0c6a244532e43ca Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 13 Oct 2012 23:24:30 -0500 Subject: [ticket/11103] Add is_disabled column to notifications table EXTENSION AUTHORS TAKE NOTE! This is to prevent errors with notifications from extensions! Set is_disabled to 1 for all your notifications when your extension is disabled so they are ignored and do not cause errors. When your extension is enabled again, set is_disabled to 0 and your notifications will be working again. PHPBB3-11103 --- phpBB/install/database_update.php | 2 ++ phpBB/install/schemas/firebird_schema.sql | 2 ++ phpBB/install/schemas/mssql_schema.sql | 4 ++++ phpBB/install/schemas/mysql_40_schema.sql | 4 +++- phpBB/install/schemas/mysql_41_schema.sql | 4 +++- phpBB/install/schemas/oracle_schema.sql | 3 +++ phpBB/install/schemas/postgres_schema.sql | 2 ++ phpBB/install/schemas/sqlite_schema.sql | 2 ++ 8 files changed, 21 insertions(+), 2 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 958db6b531..73637122ce 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1133,6 +1133,7 @@ function database_update_info() 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), + 'is_disabled' => array('BOOL', 0), 'time' => array('TIMESTAMP', 1), 'data' => array('TEXT_UNI', ''), ), @@ -1144,6 +1145,7 @@ function database_update_info() 'user_id' => array('INDEX', 'user_id'), 'time' => array('INDEX', 'time'), 'unread' => array('INDEX', 'unread'), + 'is_disabled' => array('INDEX', 'is_disabled'), ), ), USER_NOTIFICATIONS_TABLE => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index a122f5818f..1e4ae2e132 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -626,6 +626,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, unread INTEGER DEFAULT 1 NOT NULL, + is_disabled INTEGER DEFAULT 0 NOT NULL, time INTEGER DEFAULT 1 NOT NULL, data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; @@ -638,6 +639,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications(item_parent_id) CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications(user_id);; CREATE INDEX phpbb_notifications_time ON phpbb_notifications(time);; CREATE INDEX phpbb_notifications_unread ON phpbb_notifications(unread);; +CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications(is_disabled);; CREATE GENERATOR phpbb_notifications_gen;; SET GENERATOR phpbb_notifications_gen TO 0;; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index d056e4ceb5..5a397743c4 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -761,6 +761,7 @@ CREATE TABLE [phpbb_notifications] ( [item_parent_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , [unread] [int] DEFAULT (1) NOT NULL , + [is_disabled] [int] DEFAULT (0) NOT NULL , [time] [int] DEFAULT (1) NOT NULL , [data] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] @@ -791,6 +792,9 @@ GO CREATE INDEX [unread] ON [phpbb_notifications]([unread]) ON [PRIMARY] GO +CREATE INDEX [is_disabled] ON [phpbb_notifications]([is_disabled]) ON [PRIMARY] +GO + /* Table: 'phpbb_poll_options' diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index eff9dc46b8..fd7f9a6025 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -438,6 +438,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + is_disabled tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), @@ -446,7 +447,8 @@ CREATE TABLE phpbb_notifications ( KEY item_pid (item_parent_id), KEY user_id (user_id), KEY time (time), - KEY unread (unread) + KEY unread (unread), + KEY is_disabled (is_disabled) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index e7e3018572..8700b46c91 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -438,6 +438,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + is_disabled tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), @@ -446,7 +447,8 @@ CREATE TABLE phpbb_notifications ( KEY item_pid (item_parent_id), KEY user_id (user_id), KEY time (time), - KEY unread (unread) + KEY unread (unread), + KEY is_disabled (is_disabled) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 6269cfcdbc..f2f22e2f5e 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -850,6 +850,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, unread number(1) DEFAULT '1' NOT NULL, + is_disabled number(1) DEFAULT '0' NOT NULL, time number(11) DEFAULT '1' NOT NULL, data clob DEFAULT '' , CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) @@ -868,6 +869,8 @@ CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time) / CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread) / +CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled) +/ CREATE SEQUENCE phpbb_notifications_seq / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index d8716be70d..ffba657475 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -608,6 +608,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0), + is_disabled INT2 DEFAULT '0' NOT NULL CHECK (is_disabled >= 0), time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0), data varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (notification_id) @@ -619,6 +620,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); +CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled); /* Table: 'phpbb_poll_options' diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 4cb20b868f..b63569ce3e 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -425,6 +425,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', unread INTEGER UNSIGNED NOT NULL DEFAULT '1', + is_disabled INTEGER UNSIGNED NOT NULL DEFAULT '0', time INTEGER UNSIGNED NOT NULL DEFAULT '1', data text(65535) NOT NULL DEFAULT '' ); @@ -435,6 +436,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); +CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled); # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( -- cgit v1.2.1 From 471ca5e7dc8276e80e790e05a2ae36dfe35cfe10 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 19 Oct 2012 15:49:49 -0500 Subject: [ticket/11103] Change is_disabled to is_enabled If you're following along and would like to update your DB, you can run the following queries to do so: ALTER TABLE phpbb_notifications CHANGE `is_disabled` `is_enabled` TINYINT( 1 ) NOT NULL DEFAULT '1'; UPDATE `phpbb_notifications` SET is_enabled = 1; PHPBB3-11103 --- phpBB/install/database_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 73637122ce..eceb0c8fc3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1133,7 +1133,7 @@ function database_update_info() 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), - 'is_disabled' => array('BOOL', 0), + 'is_enabled' => array('BOOL', 0), 'time' => array('TIMESTAMP', 1), 'data' => array('TEXT_UNI', ''), ), @@ -1145,7 +1145,7 @@ function database_update_info() 'user_id' => array('INDEX', 'user_id'), 'time' => array('INDEX', 'time'), 'unread' => array('INDEX', 'unread'), - 'is_disabled' => array('INDEX', 'is_disabled'), + 'is_enabled' => array('INDEX', 'is_enabled'), ), ), USER_NOTIFICATIONS_TABLE => array( -- cgit v1.2.1 From 94d682f77431add84867bb0b196ad0719b293606 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 20 Oct 2012 20:54:18 -0500 Subject: [ticket/11103] Use the full class name as the item_type/method This is going to require you recreate the db tables. PHPBB3-11103 --- phpBB/install/database_update.php | 8 ++++---- phpBB/install/schemas/firebird_schema.sql | 10 +++++----- phpBB/install/schemas/mssql_schema.sql | 10 +++++----- phpBB/install/schemas/mysql_40_schema.sql | 10 +++++----- phpBB/install/schemas/mysql_41_schema.sql | 10 +++++----- phpBB/install/schemas/oracle_schema.sql | 10 +++++----- phpBB/install/schemas/postgres_schema.sql | 10 +++++----- phpBB/install/schemas/sqlite_schema.sql | 10 +++++----- 8 files changed, 39 insertions(+), 39 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index eceb0c8fc3..c24877fd74 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1128,12 +1128,12 @@ function database_update_info() NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( 'notification_id' => array('UINT', NULL, 'auto_increment'), - 'item_type' => array('VCHAR:25', ''), + 'item_type' => array('VCHAR:255', ''), 'item_id' => array('UINT', 0), 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'unread' => array('BOOL', 1), - 'is_enabled' => array('BOOL', 0), + 'is_enabled' => array('BOOL', 1), 'time' => array('TIMESTAMP', 1), 'data' => array('TEXT_UNI', ''), ), @@ -1150,10 +1150,10 @@ function database_update_info() ), USER_NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( - 'item_type' => array('VCHAR:25', ''), + 'item_type' => array('VCHAR:255', ''), 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), - 'method' => array('VCHAR:25', ''), + 'method' => array('VCHAR:255', ''), ), 'PRIMARY_KEY' => array( 'item_type', diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 1e4ae2e132..5e13f98f25 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -621,12 +621,12 @@ END;; # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id INTEGER NOT NULL, - item_type VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL, + item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, item_id INTEGER DEFAULT 0 NOT NULL, item_parent_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, unread INTEGER DEFAULT 1 NOT NULL, - is_disabled INTEGER DEFAULT 0 NOT NULL, + is_enabled INTEGER DEFAULT 1 NOT NULL, time INTEGER DEFAULT 1 NOT NULL, data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; @@ -639,7 +639,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications(item_parent_id) CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications(user_id);; CREATE INDEX phpbb_notifications_time ON phpbb_notifications(time);; CREATE INDEX phpbb_notifications_unread ON phpbb_notifications(unread);; -CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications(is_disabled);; +CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications(is_enabled);; CREATE GENERATOR phpbb_notifications_gen;; SET GENERATOR phpbb_notifications_gen TO 0;; @@ -1237,10 +1237,10 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch(notify_status) # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - item_type VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL, + item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, item_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, - method VARCHAR(25) CHARACTER SET NONE DEFAULT '' NOT NULL + method VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL );; ALTER TABLE phpbb_user_notifications ADD PRIMARY KEY (item_type, item_id, user_id, method);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 5a397743c4..d463afb17c 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -756,12 +756,12 @@ GO */ CREATE TABLE [phpbb_notifications] ( [notification_id] [int] IDENTITY (1, 1) NOT NULL , - [item_type] [varchar] (25) DEFAULT ('') NOT NULL , + [item_type] [varchar] (255) DEFAULT ('') NOT NULL , [item_id] [int] DEFAULT (0) NOT NULL , [item_parent_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , [unread] [int] DEFAULT (1) NOT NULL , - [is_disabled] [int] DEFAULT (0) NOT NULL , + [is_enabled] [int] DEFAULT (1) NOT NULL , [time] [int] DEFAULT (1) NOT NULL , [data] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] @@ -792,7 +792,7 @@ GO CREATE INDEX [unread] ON [phpbb_notifications]([unread]) ON [PRIMARY] GO -CREATE INDEX [is_disabled] ON [phpbb_notifications]([is_disabled]) ON [PRIMARY] +CREATE INDEX [is_enabled] ON [phpbb_notifications]([is_enabled]) ON [PRIMARY] GO @@ -1523,10 +1523,10 @@ GO Table: 'phpbb_user_notifications' */ CREATE TABLE [phpbb_user_notifications] ( - [item_type] [varchar] (25) DEFAULT ('') NOT NULL , + [item_type] [varchar] (255) DEFAULT ('') NOT NULL , [item_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , - [method] [varchar] (25) DEFAULT ('') NOT NULL + [method] [varchar] (255) DEFAULT ('') NOT NULL ) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index fd7f9a6025..9272e18735 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -433,12 +433,12 @@ CREATE TABLE phpbb_modules ( # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, - item_type varbinary(25) DEFAULT '' NOT NULL, + item_type varbinary(255) DEFAULT '' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - is_disabled tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), @@ -448,7 +448,7 @@ CREATE TABLE phpbb_notifications ( KEY user_id (user_id), KEY time (time), KEY unread (unread), - KEY is_disabled (is_disabled) + KEY is_enabled (is_enabled) ); @@ -873,10 +873,10 @@ CREATE TABLE phpbb_topics_watch ( # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - item_type varbinary(25) DEFAULT '' NOT NULL, + item_type varbinary(255) DEFAULT '' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - method varbinary(25) DEFAULT '' NOT NULL, + method varbinary(255) DEFAULT '' NOT NULL, PRIMARY KEY (item_type, item_id, user_id, method), KEY it (item_type), KEY uid (user_id) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 8700b46c91..a73fda41f5 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -433,12 +433,12 @@ CREATE TABLE phpbb_modules ( # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, - item_type varchar(25) DEFAULT '' NOT NULL, + item_type varchar(255) DEFAULT '' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - is_disabled tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, + is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), @@ -448,7 +448,7 @@ CREATE TABLE phpbb_notifications ( KEY user_id (user_id), KEY time (time), KEY unread (unread), - KEY is_disabled (is_disabled) + KEY is_enabled (is_enabled) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; @@ -873,10 +873,10 @@ CREATE TABLE phpbb_topics_watch ( # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - item_type varchar(25) DEFAULT '' NOT NULL, + item_type varchar(255) DEFAULT '' NOT NULL, item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - method varchar(25) DEFAULT '' NOT NULL, + method varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (item_type, item_id, user_id, method), KEY it (item_type), KEY uid (user_id) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index f2f22e2f5e..02be9566dc 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -845,12 +845,12 @@ END; */ CREATE TABLE phpbb_notifications ( notification_id number(8) NOT NULL, - item_type varchar2(25) DEFAULT '' , + item_type varchar2(255) DEFAULT '' , item_id number(8) DEFAULT '0' NOT NULL, item_parent_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, unread number(1) DEFAULT '1' NOT NULL, - is_disabled number(1) DEFAULT '0' NOT NULL, + is_enabled number(1) DEFAULT '1' NOT NULL, time number(11) DEFAULT '1' NOT NULL, data clob DEFAULT '' , CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) @@ -869,7 +869,7 @@ CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time) / CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread) / -CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled) +CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled) / CREATE SEQUENCE phpbb_notifications_seq @@ -1641,10 +1641,10 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status Table: 'phpbb_user_notifications' */ CREATE TABLE phpbb_user_notifications ( - item_type varchar2(25) DEFAULT '' , + item_type varchar2(255) DEFAULT '' , item_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, - method varchar2(25) DEFAULT '' , + method varchar2(255) DEFAULT '' , CONSTRAINT pk_phpbb_user_notifications PRIMARY KEY (item_type, item_id, user_id, method) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index ffba657475..784e3c8c68 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -603,12 +603,12 @@ CREATE SEQUENCE phpbb_notifications_seq; CREATE TABLE phpbb_notifications ( notification_id INT4 DEFAULT nextval('phpbb_notifications_seq'), - item_type varchar(25) DEFAULT '' NOT NULL, + item_type varchar(255) DEFAULT '' NOT NULL, item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0), - is_disabled INT2 DEFAULT '0' NOT NULL CHECK (is_disabled >= 0), + is_enabled INT2 DEFAULT '1' NOT NULL CHECK (is_enabled >= 0), time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0), data varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (notification_id) @@ -620,7 +620,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); -CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled); +CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled); /* Table: 'phpbb_poll_options' @@ -1123,10 +1123,10 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status Table: 'phpbb_user_notifications' */ CREATE TABLE phpbb_user_notifications ( - item_type varchar(25) DEFAULT '' NOT NULL, + item_type varchar(255) DEFAULT '' NOT NULL, item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - method varchar(25) DEFAULT '' NOT NULL, + method varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (item_type, item_id, user_id, method) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index b63569ce3e..2fdac43947 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -420,12 +420,12 @@ CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id INTEGER PRIMARY KEY NOT NULL , - item_type varchar(25) NOT NULL DEFAULT '', + item_type varchar(255) NOT NULL DEFAULT '', item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', unread INTEGER UNSIGNED NOT NULL DEFAULT '1', - is_disabled INTEGER UNSIGNED NOT NULL DEFAULT '0', + is_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1', time INTEGER UNSIGNED NOT NULL DEFAULT '1', data text(65535) NOT NULL DEFAULT '' ); @@ -436,7 +436,7 @@ CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); -CREATE INDEX phpbb_notifications_is_disabled ON phpbb_notifications (is_disabled); +CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled); # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( @@ -846,10 +846,10 @@ CREATE INDEX phpbb_topics_watch_notify_stat ON phpbb_topics_watch (notify_status # Table: 'phpbb_user_notifications' CREATE TABLE phpbb_user_notifications ( - item_type varchar(25) NOT NULL DEFAULT '', + item_type varchar(255) NOT NULL DEFAULT '', item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - method varchar(25) NOT NULL DEFAULT '', + method varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (item_type, item_id, user_id, method) ); -- cgit v1.2.1 From eddb56f8426161923d8870ca5f8f899c342075db Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 27 Oct 2012 12:03:11 -0500 Subject: [ticket/11103] Working on default notifications on install/update PHPBB3-11103 --- phpBB/install/database_update.php | 105 +++++++++++++++++++++++++++++++++- phpBB/install/schemas/schema_data.sql | 11 ++++ 2 files changed, 115 insertions(+), 1 deletion(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c24877fd74..3e4edc0b8f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2755,9 +2755,112 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_text', ''); } - if (!isset($config['load_notifications'])) + if (true)//!isset($config['load_notifications'])) { $config->set('load_notifications', 1); + + // Convert notifications + $convert_notifications = array( + array( + 'check' => ($config['allow_topic_notify']), + 'item_type' => 'phpbb_notification_type_post', + ), + array( + 'check' => ($config['allow_forum_notify']), + 'item_type' => 'phpbb_notification_type_topic', + ), + array( + 'check' => ($config['allow_bookmarks']), + 'item_type' => 'phpbb_notification_type_bookmark', + ), + array( + 'check' => ($config['allow_privmsg']), + 'item_type' => 'phpbb_notification_type_pm', + ), + ); + + foreach ($convert_notifications as $convert_data) + { + if ($convert_data['check']) + { + $sql = 'SELECT user_id, user_notify_type + FROM ' . USERS_TABLE . ' + WHERE user_notify = 1'; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + _sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'item_type' => $convert_data['item_type'], + 'item_id' => 0, + 'user_id' => $row['user_id'], + 'method' => '', + )), $errored, $error_ary); + + if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH) + { + _sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'item_type' => $convert_data['item_type'], + 'item_id' => 0, + 'user_id' => $row['user_id'], + 'method' => 'phpbb_notification_method_email', + )), $errored, $error_ary); + } + + if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH) + { + _sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'item_type' => $convert_data['item_type'], + 'item_id' => 0, + 'user_id' => $row['user_id'], + 'method' => 'phpbb_notification_method_jabber', + )), $errored, $error_ary); + } + } + $db->sql_freeresult($result); + } + } +/* + // Add default notifications + $default_notifications = array( + array( + 'check' => ($config['allow_topic_notify']), + 'item_type' => 'phpbb_notification_type_post', + ), + array( + 'check' => ($config['allow_forum_notify']), + 'item_type' => 'phpbb_notification_type_topic', + ), + array( + 'check' => ($config['allow_bookmarks']), + 'item_type' => 'phpbb_notification_type_bookmark', + ), + array( + 'check' => ($config['allow_privmsg']), + 'item_type' => 'phpbb_notification_type_pm', + ), + ); + + foreach ($default_notifications as $convert_data) + { + if ($convert_data['check']) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE user_id <> ' . ANONYMOUS . ' + AND user_type <> ' . USER_IGNORE; + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + _sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'item_type' => $convert_data['item_type'], + 'item_id' => 0, + 'user_id' => $row['user_id'], + 'method' => '', + )), $errored, $error_ary); + } + $db->sql_freeresult($result); + } + }*/ } break; diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 0d47f4995e..28f8b1c3b6 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -770,4 +770,15 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mp3'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm'); +# User Notification Options (for first user) +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('report', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('needs_approval', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_bookmark', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_pm', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_post', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_post', 0, 2, 'phpbb_notification_method_email'); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_quote', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_topic', 0, 2, ''); +INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_topic', 0, 2, 'phpbb_notification_method_email'); + # POSTGRES COMMIT # -- cgit v1.2.1 From e549b7663da47d7518b93074e513c7e1d034bf52 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 29 Oct 2012 18:09:20 -0500 Subject: [ticket/11103] Set basic notifications to be enabled by default Now, if there is no row for the user in the user_notifications table, the user will receive basic notifications. If the user wishes to not receive notifications, a row must be added with notify = 0. For other methods besides the basic (e.g. email, jabber) a row must still be added with notify = 1 for them to receive notifications PHPBB3-11103 --- phpBB/install/database_update.php | 46 ++----------------------------- phpBB/install/schemas/firebird_schema.sql | 4 ++- phpBB/install/schemas/mssql_schema.sql | 6 +++- phpBB/install/schemas/mysql_40_schema.sql | 4 ++- phpBB/install/schemas/mysql_41_schema.sql | 4 ++- phpBB/install/schemas/oracle_schema.sql | 3 ++ phpBB/install/schemas/postgres_schema.sql | 2 ++ phpBB/install/schemas/schema_data.sql | 5 ---- phpBB/install/schemas/sqlite_schema.sql | 2 ++ 9 files changed, 24 insertions(+), 52 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3e4edc0b8f..94a4749313 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1154,6 +1154,7 @@ function database_update_info() 'item_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'method' => array('VCHAR:255', ''), + 'notify' => array('BOOL', 1), ), 'PRIMARY_KEY' => array( 'item_type', @@ -1164,6 +1165,7 @@ function database_update_info() 'KEYS' => array( 'it' => array('INDEX', 'item_type'), 'uid' => array('INDEX', 'user_id'), + 'no' => array('INDEX', 'notify'), ), ), ), @@ -2755,7 +2757,7 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_text', ''); } - if (true)//!isset($config['load_notifications'])) + if (!isset($config['load_notifications'])) { $config->set('load_notifications', 1); @@ -2819,48 +2821,6 @@ function change_database_data(&$no_updates, $version) $db->sql_freeresult($result); } } -/* - // Add default notifications - $default_notifications = array( - array( - 'check' => ($config['allow_topic_notify']), - 'item_type' => 'phpbb_notification_type_post', - ), - array( - 'check' => ($config['allow_forum_notify']), - 'item_type' => 'phpbb_notification_type_topic', - ), - array( - 'check' => ($config['allow_bookmarks']), - 'item_type' => 'phpbb_notification_type_bookmark', - ), - array( - 'check' => ($config['allow_privmsg']), - 'item_type' => 'phpbb_notification_type_pm', - ), - ); - - foreach ($default_notifications as $convert_data) - { - if ($convert_data['check']) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_id <> ' . ANONYMOUS . ' - AND user_type <> ' . USER_IGNORE; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - _sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'item_type' => $convert_data['item_type'], - 'item_id' => 0, - 'user_id' => $row['user_id'], - 'method' => '', - )), $errored, $error_ary); - } - $db->sql_freeresult($result); - } - }*/ } break; diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 5e13f98f25..4364641fe4 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -1240,13 +1240,15 @@ CREATE TABLE phpbb_user_notifications ( item_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, item_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, - method VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL + method VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + notify INTEGER DEFAULT 1 NOT NULL );; ALTER TABLE phpbb_user_notifications ADD PRIMARY KEY (item_type, item_id, user_id, method);; CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications(item_type);; CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications(user_id);; +CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications(notify);; # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index d463afb17c..17786e27e2 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1526,7 +1526,8 @@ CREATE TABLE [phpbb_user_notifications] ( [item_type] [varchar] (255) DEFAULT ('') NOT NULL , [item_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , - [method] [varchar] (255) DEFAULT ('') NOT NULL + [method] [varchar] (255) DEFAULT ('') NOT NULL , + [notify] [int] DEFAULT (1) NOT NULL ) ON [PRIMARY] GO @@ -1546,6 +1547,9 @@ GO CREATE INDEX [uid] ON [phpbb_user_notifications]([user_id]) ON [PRIMARY] GO +CREATE INDEX [no] ON [phpbb_user_notifications]([notify]) ON [PRIMARY] +GO + /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 9272e18735..fb91d55e5f 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -877,9 +877,11 @@ CREATE TABLE phpbb_user_notifications ( item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varbinary(255) DEFAULT '' NOT NULL, + notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, PRIMARY KEY (item_type, item_id, user_id, method), KEY it (item_type), - KEY uid (user_id) + KEY uid (user_id), + KEY no (notify) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index a73fda41f5..3601f2a43c 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -877,9 +877,11 @@ CREATE TABLE phpbb_user_notifications ( item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varchar(255) DEFAULT '' NOT NULL, + notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, PRIMARY KEY (item_type, item_id, user_id, method), KEY it (item_type), - KEY uid (user_id) + KEY uid (user_id), + KEY no (notify) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 02be9566dc..15c3012e28 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1645,6 +1645,7 @@ CREATE TABLE phpbb_user_notifications ( item_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, method varchar2(255) DEFAULT '' , + notify number(1) DEFAULT '1' NOT NULL, CONSTRAINT pk_phpbb_user_notifications PRIMARY KEY (item_type, item_id, user_id, method) ) / @@ -1653,6 +1654,8 @@ CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type) / CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id) / +CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify) +/ /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 784e3c8c68..263a9884b7 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -1127,11 +1127,13 @@ CREATE TABLE phpbb_user_notifications ( item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), method varchar(255) DEFAULT '' NOT NULL, + notify INT2 DEFAULT '1' NOT NULL CHECK (notify >= 0), PRIMARY KEY (item_type, item_id, user_id, method) ); CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type); CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id); +CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify); /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 28f8b1c3b6..e100a1dc14 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -771,13 +771,8 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm'); # User Notification Options (for first user) -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('report', 0, 2, ''); -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('needs_approval', 0, 2, ''); -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_bookmark', 0, 2, ''); -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_pm', 0, 2, ''); INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_post', 0, 2, ''); INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_post', 0, 2, 'phpbb_notification_method_email'); -INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_quote', 0, 2, ''); INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_topic', 0, 2, ''); INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_topic', 0, 2, 'phpbb_notification_method_email'); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 2fdac43947..1ca904e3bd 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -850,11 +850,13 @@ CREATE TABLE phpbb_user_notifications ( item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', method varchar(255) NOT NULL DEFAULT '', + notify INTEGER UNSIGNED NOT NULL DEFAULT '1', PRIMARY KEY (item_type, item_id, user_id, method) ); CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type); CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id); +CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify); # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( -- cgit v1.2.1 From 6c8c54d4d2575cd40fe873cd2108b031ae5830a6 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 9 Nov 2012 08:48:41 -0600 Subject: [ticket/11103] Inject table prefix to notifications system instead of constants PHPBB3-11103 --- phpBB/install/database_update.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 94a4749313..9e884b0a37 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -110,14 +110,6 @@ if (!defined('EXT_TABLE')) { define('EXT_TABLE', $table_prefix . 'ext'); } -if (!defined('NOTIFICATIONS_TABLE')) -{ - define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); -} -if (!defined('USER_NOTIFICATIONS_TABLE')) -{ - define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications'); -} $phpbb_container = new ContainerBuilder(); $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); @@ -1125,7 +1117,7 @@ function database_update_info() 'ext_name' => array('UNIQUE', 'ext_name'), ), ), - NOTIFICATIONS_TABLE => array( + $table_prefix . 'notifications' => array( 'COLUMNS' => array( 'notification_id' => array('UINT', NULL, 'auto_increment'), 'item_type' => array('VCHAR:255', ''), @@ -1148,7 +1140,7 @@ function database_update_info() 'is_enabled' => array('INDEX', 'is_enabled'), ), ), - USER_NOTIFICATIONS_TABLE => array( + $table_prefix . 'user_notifications' => array( 'COLUMNS' => array( 'item_type' => array('VCHAR:255', ''), 'item_id' => array('UINT', 0), @@ -2791,7 +2783,7 @@ function change_database_data(&$no_updates, $version) $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - _sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + _sql('INSERT INTO ' . $table_prefix . 'user_notifications ' . $db->sql_build_array('INSERT', array( 'item_type' => $convert_data['item_type'], 'item_id' => 0, 'user_id' => $row['user_id'], @@ -2800,7 +2792,7 @@ function change_database_data(&$no_updates, $version) if ($row['user_notify_type'] == NOTIFY_EMAIL || $row['user_notify_type'] == NOTIFY_BOTH) { - _sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + _sql('INSERT INTO ' . $table_prefix . 'user_notifications ' . $db->sql_build_array('INSERT', array( 'item_type' => $convert_data['item_type'], 'item_id' => 0, 'user_id' => $row['user_id'], @@ -2810,7 +2802,7 @@ function change_database_data(&$no_updates, $version) if ($row['user_notify_type'] == NOTIFY_IM || $row['user_notify_type'] == NOTIFY_BOTH) { - _sql('INSERT INTO ' . USER_NOTIFICATIONS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + _sql('INSERT INTO ' . $table_prefix . 'user_notifications ' . $db->sql_build_array('INSERT', array( 'item_type' => $convert_data['item_type'], 'item_id' => 0, 'user_id' => $row['user_id'], -- cgit v1.2.1 From 2afb8b9df873c3f9572a32ab7a62ea8ba8d8a45b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 20 Nov 2012 18:14:48 -0600 Subject: [ticket/11103] Create user loader class, update for DIC Create a very basic user loader class to handle querying/storing user data in a centralized location. Use DIC collection service for notification types/methods. Cleanup unused dependencies. Fix some other issues. PHPBB3-11103 --- phpBB/install/database_update.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ab48da059d..768280ec7e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2814,19 +2814,19 @@ function change_database_data(&$no_updates, $version) $convert_notifications = array( array( 'check' => ($config['allow_topic_notify']), - 'item_type' => 'phpbb_notification_type_post', + 'item_type' => 'post', ), array( 'check' => ($config['allow_forum_notify']), - 'item_type' => 'phpbb_notification_type_topic', + 'item_type' => 'topic', ), array( 'check' => ($config['allow_bookmarks']), - 'item_type' => 'phpbb_notification_type_bookmark', + 'item_type' => 'bookmark', ), array( 'check' => ($config['allow_privmsg']), - 'item_type' => 'phpbb_notification_type_pm', + 'item_type' => 'pm', ), ); @@ -2853,7 +2853,7 @@ function change_database_data(&$no_updates, $version) 'item_type' => $convert_data['item_type'], 'item_id' => 0, 'user_id' => $row['user_id'], - 'method' => 'phpbb_notification_method_email', + 'method' => 'email', )), $errored, $error_ary); } @@ -2863,7 +2863,7 @@ function change_database_data(&$no_updates, $version) 'item_type' => $convert_data['item_type'], 'item_id' => 0, 'user_id' => $row['user_id'], - 'method' => 'phpbb_notification_method_jabber', + 'method' => 'jabber', )), $errored, $error_ary); } } -- cgit v1.2.1 From 0d6c8f46ffa1206e9d8d71fd30ef04e52f7cb2a8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 8 Dec 2012 14:12:25 -0600 Subject: [ticket/11103] Update indexes on notifications/user notifications tables PHPBB3-11103 --- phpBB/install/database_update.php | 14 ++------------ phpBB/install/schemas/firebird_schema.sql | 9 ++------- phpBB/install/schemas/mssql_schema.sql | 19 ++----------------- phpBB/install/schemas/mysql_40_schema.sql | 9 ++------- phpBB/install/schemas/mysql_41_schema.sql | 9 ++------- phpBB/install/schemas/oracle_schema.sql | 14 ++------------ phpBB/install/schemas/postgres_schema.sql | 9 ++------- phpBB/install/schemas/sqlite_schema.sql | 9 ++------- 8 files changed, 16 insertions(+), 76 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 33e8795327..a4739b7212 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1122,13 +1122,8 @@ function database_update_info() ), 'PRIMARY_KEY' => 'notification_id', 'KEYS' => array( - 'item_type' => array('INDEX', 'item_type'), - 'item_id' => array('INDEX', 'item_id'), - 'item_pid' => array('INDEX', 'item_parent_id'), - 'user_id' => array('INDEX', 'user_id'), - 'time' => array('INDEX', 'time'), - 'unread' => array('INDEX', 'unread'), - 'is_enabled' => array('INDEX', 'is_enabled'), + 'item_ident' => array('INDEX', array('item_type', 'item_id')), + 'user' => array('INDEX', array('user_id', 'unread')), ), ), $table_prefix . 'user_notifications' => array( @@ -1145,11 +1140,6 @@ function database_update_info() 'user_id', 'method', ), - 'KEYS' => array( - 'it' => array('INDEX', 'item_type'), - 'uid' => array('INDEX', 'user_id'), - 'no' => array('INDEX', 'notify'), - ), ), ), 'add_columns' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 8456958800..d3058fb0dd 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -633,13 +633,8 @@ CREATE TABLE phpbb_notifications ( ALTER TABLE phpbb_notifications ADD PRIMARY KEY (notification_id);; -CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications(item_type);; -CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications(item_id);; -CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications(item_parent_id);; -CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications(user_id);; -CREATE INDEX phpbb_notifications_time ON phpbb_notifications(time);; -CREATE INDEX phpbb_notifications_unread ON phpbb_notifications(unread);; -CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications(is_enabled);; +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications(item_type, item_id);; +CREATE INDEX phpbb_notifications_user ON phpbb_notifications(user_id, unread);; CREATE GENERATOR phpbb_notifications_gen;; SET GENERATOR phpbb_notifications_gen TO 0;; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index d0023aa411..377ff92620 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -774,25 +774,10 @@ ALTER TABLE [phpbb_notifications] WITH NOCHECK ADD ) ON [PRIMARY] GO -CREATE INDEX [item_type] ON [phpbb_notifications]([item_type]) ON [PRIMARY] +CREATE INDEX [item_ident] ON [phpbb_notifications]([item_type], [item_id]) ON [PRIMARY] GO -CREATE INDEX [item_id] ON [phpbb_notifications]([item_id]) ON [PRIMARY] -GO - -CREATE INDEX [item_pid] ON [phpbb_notifications]([item_parent_id]) ON [PRIMARY] -GO - -CREATE INDEX [user_id] ON [phpbb_notifications]([user_id]) ON [PRIMARY] -GO - -CREATE INDEX [time] ON [phpbb_notifications]([time]) ON [PRIMARY] -GO - -CREATE INDEX [unread] ON [phpbb_notifications]([unread]) ON [PRIMARY] -GO - -CREATE INDEX [is_enabled] ON [phpbb_notifications]([is_enabled]) ON [PRIMARY] +CREATE INDEX [user] ON [phpbb_notifications]([user_id], [unread]) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 07e529e833..4ceb664cd3 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -442,13 +442,8 @@ CREATE TABLE phpbb_notifications ( time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), - KEY item_type (item_type), - KEY item_id (item_id), - KEY item_pid (item_parent_id), - KEY user_id (user_id), - KEY time (time), - KEY unread (unread), - KEY is_enabled (is_enabled) + KEY item_ident (item_type, item_id), + KEY user (user_id, unread) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 361f53c313..423b97567a 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -442,13 +442,8 @@ CREATE TABLE phpbb_notifications ( time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), - KEY item_type (item_type), - KEY item_id (item_id), - KEY item_pid (item_parent_id), - KEY user_id (user_id), - KEY time (time), - KEY unread (unread), - KEY is_enabled (is_enabled) + KEY item_ident (item_type, item_id), + KEY user (user_id, unread) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index a2bb016dae..b3ea3c7d5e 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -857,19 +857,9 @@ CREATE TABLE phpbb_notifications ( ) / -CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type) +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id) / -CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id) -/ -CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id) -/ -CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id) -/ -CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time) -/ -CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread) -/ -CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled) +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread) / CREATE SEQUENCE phpbb_notifications_seq diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 94926d0b7a..e43b64468d 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -614,13 +614,8 @@ CREATE TABLE phpbb_notifications ( PRIMARY KEY (notification_id) ); -CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type); -CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id); -CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id); -CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); -CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); -CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); -CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled); +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread); /* Table: 'phpbb_poll_options' diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 43611ef70b..e3b556668d 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -430,13 +430,8 @@ CREATE TABLE phpbb_notifications ( data text(65535) NOT NULL DEFAULT '' ); -CREATE INDEX phpbb_notifications_item_type ON phpbb_notifications (item_type); -CREATE INDEX phpbb_notifications_item_id ON phpbb_notifications (item_id); -CREATE INDEX phpbb_notifications_item_pid ON phpbb_notifications (item_parent_id); -CREATE INDEX phpbb_notifications_user_id ON phpbb_notifications (user_id); -CREATE INDEX phpbb_notifications_time ON phpbb_notifications (time); -CREATE INDEX phpbb_notifications_unread ON phpbb_notifications (unread); -CREATE INDEX phpbb_notifications_is_enabled ON phpbb_notifications (is_enabled); +CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread); # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( -- cgit v1.2.1 From 1cdb0ecbf205b10a8297f1ec24fcebaea5bee9b2 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 13 Dec 2012 19:32:11 -0600 Subject: [ticket/11103] Add global $table_prefix I have no idea how this worked previously... PHPBB3-11103 --- phpBB/install/database_update.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 19d704511a..4adce77c33 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -886,6 +886,8 @@ function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permissio *****************************************************************************/ function database_update_info() { + global $table_prefix; + return array( // Changes from 3.0.0 to the next version '3.0.0' => array( -- cgit v1.2.1 From bec05a11f38cd57d7e7a6c7f64ecdb7351e24fc0 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 13 Dec 2012 19:56:39 -0600 Subject: [ticket/11103] Add constants for the tables PHPBB3-11103 --- phpBB/install/database_update.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4adce77c33..c605e0b0e9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -93,6 +93,14 @@ if (!defined('LOGIN_ATTEMPT_TABLE')) { define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); } +if (!defined('NOTIFICATIONS_TABLE')) +{ + define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); +} +if (!defined('USER_NOTIFICATIONS_TABLE')) +{ + define('USER_NOTIFICATIONS_TABLE', $table_prefix . 'user_notifications'); +} if (!defined('EXT_TABLE')) { define('EXT_TABLE', $table_prefix . 'ext'); @@ -886,8 +894,6 @@ function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permissio *****************************************************************************/ function database_update_info() { - global $table_prefix; - return array( // Changes from 3.0.0 to the next version '3.0.0' => array( @@ -1173,7 +1179,7 @@ function database_update_info() 'ext_name' => array('UNIQUE', 'ext_name'), ), ), - $table_prefix . 'notifications' => array( + NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( 'notification_id' => array('UINT', NULL, 'auto_increment'), 'item_type' => array('VCHAR:255', ''), @@ -1191,7 +1197,7 @@ function database_update_info() 'user' => array('INDEX', array('user_id', 'unread')), ), ), - $table_prefix . 'user_notifications' => array( + USER_NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( 'item_type' => array('VCHAR:255', ''), 'item_id' => array('UINT', 0), -- cgit v1.2.1 From 25895bd5c3dc0749c8f7e5f7560752e936e66df7 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 13 Dec 2012 23:19:10 -0600 Subject: [ticket/11103] Fix missing ), in database_update.php PHPBB3-11103 --- phpBB/install/database_update.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c605e0b0e9..0250b53a19 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2619,6 +2619,7 @@ function change_database_data(&$no_updates, $version) 'title' => 'UCP_NOTIFICATION_LIST', 'auth' => '', 'cat' => 'UCP_MAIN', + ), // To add a category, the mode and basename must be empty // The mode is taken from the array key '' => array( -- cgit v1.2.1 From f47e51d6dea9d59a36a6babf1f4033104c93a53d Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Dec 2012 19:18:26 -0600 Subject: [ticket/11103] Move is_enabled to a separate table for better performance PHPBB3-11103 --- phpBB/install/database_update.php | 11 +++++++++++ phpBB/install/schemas/firebird_schema.sql | 13 +++++++++---- phpBB/install/schemas/mssql_schema.sql | 28 ++++++++++++++++++---------- phpBB/install/schemas/mysql_40_schema.sql | 14 +++++++++----- phpBB/install/schemas/mysql_41_schema.sql | 14 +++++++++----- phpBB/install/schemas/oracle_schema.sql | 18 +++++++++++------- phpBB/install/schemas/postgres_schema.sql | 14 ++++++++++---- phpBB/install/schemas/sqlite_schema.sql | 12 ++++++++---- 8 files changed, 85 insertions(+), 39 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0250b53a19..ae810e1022 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -93,6 +93,10 @@ if (!defined('LOGIN_ATTEMPT_TABLE')) { define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); } +if (!defined('NOTIFICATION_TYPES_TABLE')) +{ + define('NOTIFICATION_TYPES_TABLE', $table_prefix . 'notification_types'); +} if (!defined('NOTIFICATIONS_TABLE')) { define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); @@ -1179,6 +1183,13 @@ function database_update_info() 'ext_name' => array('UNIQUE', 'ext_name'), ), ), + NOTIFICATION_TYPES_TABLE => array( + 'COLUMNS' => array( + 'notification_type' => array('VCHAR:255', ''), + 'notification_type_enabled' => array('BOOL', 1), + ), + 'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'), + ), NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( 'notification_id' => array('UINT', NULL, 'auto_increment'), diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index d3058fb0dd..5f7d23e411 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -618,6 +618,15 @@ BEGIN END;; +# Table: 'phpbb_notification_types' +CREATE TABLE phpbb_notification_types ( + notification_type VARCHAR(255) CHARACTER SET NONE DEFAULT '' NOT NULL, + notification_type_enabled INTEGER DEFAULT 1 NOT NULL +);; + +ALTER TABLE phpbb_notification_types ADD PRIMARY KEY (notification_type, notification_type_enabled);; + + # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id INTEGER NOT NULL, @@ -626,7 +635,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, unread INTEGER DEFAULT 1 NOT NULL, - is_enabled INTEGER DEFAULT 1 NOT NULL, time INTEGER DEFAULT 1 NOT NULL, data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; @@ -1243,9 +1251,6 @@ CREATE TABLE phpbb_user_notifications ( ALTER TABLE phpbb_user_notifications ADD PRIMARY KEY (item_type, item_id, user_id, method);; -CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications(item_type);; -CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications(user_id);; -CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications(notify);; # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 377ff92620..15529cde38 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -751,6 +751,24 @@ CREATE INDEX [class_left_id] ON [phpbb_modules]([module_class], [left_id]) ON [ GO +/* + Table: 'phpbb_notification_types' +*/ +CREATE TABLE [phpbb_notification_types] ( + [notification_type] [varchar] (255) DEFAULT ('') NOT NULL , + [notification_type_enabled] [int] DEFAULT (1) NOT NULL +) ON [PRIMARY] +GO + +ALTER TABLE [phpbb_notification_types] WITH NOCHECK ADD + CONSTRAINT [PK_phpbb_notification_types] PRIMARY KEY CLUSTERED + ( + [notification_type], + [notification_type_enabled] + ) ON [PRIMARY] +GO + + /* Table: 'phpbb_notifications' */ @@ -761,7 +779,6 @@ CREATE TABLE [phpbb_notifications] ( [item_parent_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , [unread] [int] DEFAULT (1) NOT NULL , - [is_enabled] [int] DEFAULT (1) NOT NULL , [time] [int] DEFAULT (1) NOT NULL , [data] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] @@ -1528,15 +1545,6 @@ ALTER TABLE [phpbb_user_notifications] WITH NOCHECK ADD ) ON [PRIMARY] GO -CREATE INDEX [it] ON [phpbb_user_notifications]([item_type]) ON [PRIMARY] -GO - -CREATE INDEX [uid] ON [phpbb_user_notifications]([user_id]) ON [PRIMARY] -GO - -CREATE INDEX [no] ON [phpbb_user_notifications]([notify]) ON [PRIMARY] -GO - /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 4ceb664cd3..f295664c64 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -430,6 +430,14 @@ CREATE TABLE phpbb_modules ( ); +# Table: 'phpbb_notification_types' +CREATE TABLE phpbb_notification_types ( + notification_type varbinary(255) DEFAULT '' NOT NULL, + notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + PRIMARY KEY (notification_type, notification_type_enabled) +); + + # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, @@ -438,7 +446,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), @@ -875,10 +882,7 @@ CREATE TABLE phpbb_user_notifications ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varbinary(255) DEFAULT '' NOT NULL, notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (item_type, item_id, user_id, method), - KEY it (item_type), - KEY uid (user_id), - KEY no (notify) + PRIMARY KEY (item_type, item_id, user_id, method) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 423b97567a..bfba8e5f64 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -430,6 +430,14 @@ CREATE TABLE phpbb_modules ( ) CHARACTER SET `utf8` COLLATE `utf8_bin`; +# Table: 'phpbb_notification_types' +CREATE TABLE phpbb_notification_types ( + notification_type varchar(255) DEFAULT '' NOT NULL, + notification_type_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + PRIMARY KEY (notification_type, notification_type_enabled) +) CHARACTER SET `utf8` COLLATE `utf8_bin`; + + # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id mediumint(8) UNSIGNED NOT NULL auto_increment, @@ -438,7 +446,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - is_enabled tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), @@ -875,10 +882,7 @@ CREATE TABLE phpbb_user_notifications ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varchar(255) DEFAULT '' NOT NULL, notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (item_type, item_id, user_id, method), - KEY it (item_type), - KEY uid (user_id), - KEY no (notify) + PRIMARY KEY (item_type, item_id, user_id, method) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index b3ea3c7d5e..aae49afd70 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -840,6 +840,17 @@ END; / +/* + Table: 'phpbb_notification_types' +*/ +CREATE TABLE phpbb_notification_types ( + notification_type varchar2(255) DEFAULT '' , + notification_type_enabled number(1) DEFAULT '1' NOT NULL, + CONSTRAINT pk_phpbb_notification_types PRIMARY KEY (notification_type, notification_type_enabled) +) +/ + + /* Table: 'phpbb_notifications' */ @@ -850,7 +861,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, unread number(1) DEFAULT '1' NOT NULL, - is_enabled number(1) DEFAULT '1' NOT NULL, time number(11) DEFAULT '1' NOT NULL, data clob DEFAULT '' , CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) @@ -1642,12 +1652,6 @@ CREATE TABLE phpbb_user_notifications ( ) / -CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type) -/ -CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id) -/ -CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify) -/ /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index e43b64468d..05533fc731 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -596,6 +596,16 @@ CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); +/* + Table: 'phpbb_notification_types' +*/ +CREATE TABLE phpbb_notification_types ( + notification_type varchar(255) DEFAULT '' NOT NULL, + notification_type_enabled INT2 DEFAULT '1' NOT NULL CHECK (notification_type_enabled >= 0), + PRIMARY KEY (notification_type, notification_type_enabled) +); + + /* Table: 'phpbb_notifications' */ @@ -608,7 +618,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0), - is_enabled INT2 DEFAULT '1' NOT NULL CHECK (is_enabled >= 0), time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0), data varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (notification_id) @@ -1128,9 +1137,6 @@ CREATE TABLE phpbb_user_notifications ( PRIMARY KEY (item_type, item_id, user_id, method) ); -CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type); -CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id); -CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify); /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index e3b556668d..fa61e4104f 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -417,6 +417,14 @@ CREATE INDEX phpbb_modules_left_right_id ON phpbb_modules (left_id, right_id); CREATE INDEX phpbb_modules_module_enabled ON phpbb_modules (module_enabled); CREATE INDEX phpbb_modules_class_left_id ON phpbb_modules (module_class, left_id); +# Table: 'phpbb_notification_types' +CREATE TABLE phpbb_notification_types ( + notification_type varchar(255) NOT NULL DEFAULT '', + notification_type_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1', + PRIMARY KEY (notification_type, notification_type_enabled) +); + + # Table: 'phpbb_notifications' CREATE TABLE phpbb_notifications ( notification_id INTEGER PRIMARY KEY NOT NULL , @@ -425,7 +433,6 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', unread INTEGER UNSIGNED NOT NULL DEFAULT '1', - is_enabled INTEGER UNSIGNED NOT NULL DEFAULT '1', time INTEGER UNSIGNED NOT NULL DEFAULT '1', data text(65535) NOT NULL DEFAULT '' ); @@ -851,9 +858,6 @@ CREATE TABLE phpbb_user_notifications ( PRIMARY KEY (item_type, item_id, user_id, method) ); -CREATE INDEX phpbb_user_notifications_it ON phpbb_user_notifications (item_type); -CREATE INDEX phpbb_user_notifications_uid ON phpbb_user_notifications (user_id); -CREATE INDEX phpbb_user_notifications_no ON phpbb_user_notifications (notify); # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( -- cgit v1.2.1 From 47bed3321634d888a51a611e6586c012a27eb1eb Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Dec 2012 21:02:28 -0600 Subject: [ticket/11103] time -> notification_time PHPBB3-11103 --- phpBB/install/database_update.php | 18 +++++++++--------- phpBB/install/schemas/firebird_schema.sql | 2 +- phpBB/install/schemas/mssql_schema.sql | 2 +- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/oracle_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ae810e1022..614f41f139 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1192,15 +1192,15 @@ function database_update_info() ), NOTIFICATIONS_TABLE => array( 'COLUMNS' => array( - 'notification_id' => array('UINT', NULL, 'auto_increment'), - 'item_type' => array('VCHAR:255', ''), - 'item_id' => array('UINT', 0), - 'item_parent_id' => array('UINT', 0), - 'user_id' => array('UINT', 0), - 'unread' => array('BOOL', 1), - 'is_enabled' => array('BOOL', 1), - 'time' => array('TIMESTAMP', 1), - 'data' => array('TEXT_UNI', ''), + 'notification_id' => array('UINT', NULL, 'auto_increment'), + 'item_type' => array('VCHAR:255', ''), + 'item_id' => array('UINT', 0), + 'item_parent_id' => array('UINT', 0), + 'user_id' => array('UINT', 0), + 'unread' => array('BOOL', 1), + 'is_enabled' => array('BOOL', 1), + 'notification_time' => array('TIMESTAMP', 1), + 'data' => array('TEXT_UNI', ''), ), 'PRIMARY_KEY' => 'notification_id', 'KEYS' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 5f7d23e411..8f45265c17 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -635,7 +635,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, unread INTEGER DEFAULT 1 NOT NULL, - time INTEGER DEFAULT 1 NOT NULL, + notification_time INTEGER DEFAULT 1 NOT NULL, data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 15529cde38..18f3dd3a04 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -779,7 +779,7 @@ CREATE TABLE [phpbb_notifications] ( [item_parent_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , [unread] [int] DEFAULT (1) NOT NULL , - [time] [int] DEFAULT (1) NOT NULL , + [notification_time] [int] DEFAULT (1) NOT NULL , [data] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index f295664c64..140cb354a7 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -446,7 +446,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - time int(11) UNSIGNED DEFAULT '1' NOT NULL, + notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), KEY item_ident (item_type, item_id), diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index bfba8e5f64..913968c174 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -446,7 +446,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - time int(11) UNSIGNED DEFAULT '1' NOT NULL, + notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), KEY item_ident (item_type, item_id), diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index aae49afd70..8a6e9fffc6 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -861,7 +861,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, unread number(1) DEFAULT '1' NOT NULL, - time number(11) DEFAULT '1' NOT NULL, + notification_time number(11) DEFAULT '1' NOT NULL, data clob DEFAULT '' , CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) ) diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 05533fc731..6d9a910912 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -618,7 +618,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0), - time INT4 DEFAULT '1' NOT NULL CHECK (time >= 0), + notification_time INT4 DEFAULT '1' NOT NULL CHECK (notification_time >= 0), data varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (notification_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index fa61e4104f..7f93aaf0c7 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -433,7 +433,7 @@ CREATE TABLE phpbb_notifications ( item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', unread INTEGER UNSIGNED NOT NULL DEFAULT '1', - time INTEGER UNSIGNED NOT NULL DEFAULT '1', + notification_time INTEGER UNSIGNED NOT NULL DEFAULT '1', data text(65535) NOT NULL DEFAULT '' ); -- cgit v1.2.1 From fad6bc5a7e58ddd370b88f73712de350b61bca29 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Dec 2012 21:08:26 -0600 Subject: [ticket/11103] unread -> notification_read PHPBB3-11103 --- phpBB/install/database_update.php | 4 ++-- phpBB/install/schemas/firebird_schema.sql | 4 ++-- phpBB/install/schemas/mssql_schema.sql | 4 ++-- phpBB/install/schemas/mysql_40_schema.sql | 4 ++-- phpBB/install/schemas/mysql_41_schema.sql | 4 ++-- phpBB/install/schemas/oracle_schema.sql | 4 ++-- phpBB/install/schemas/postgres_schema.sql | 4 ++-- phpBB/install/schemas/sqlite_schema.sql | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 614f41f139..364eca9267 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1197,7 +1197,7 @@ function database_update_info() 'item_id' => array('UINT', 0), 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), - 'unread' => array('BOOL', 1), + 'notification_read' => array('BOOL', 0), 'is_enabled' => array('BOOL', 1), 'notification_time' => array('TIMESTAMP', 1), 'data' => array('TEXT_UNI', ''), @@ -1205,7 +1205,7 @@ function database_update_info() 'PRIMARY_KEY' => 'notification_id', 'KEYS' => array( 'item_ident' => array('INDEX', array('item_type', 'item_id')), - 'user' => array('INDEX', array('user_id', 'unread')), + 'user' => array('INDEX', array('user_id', 'notification_read')), ), ), USER_NOTIFICATIONS_TABLE => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 8f45265c17..bb4e413ba1 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -634,7 +634,7 @@ CREATE TABLE phpbb_notifications ( item_id INTEGER DEFAULT 0 NOT NULL, item_parent_id INTEGER DEFAULT 0 NOT NULL, user_id INTEGER DEFAULT 0 NOT NULL, - unread INTEGER DEFAULT 1 NOT NULL, + notification_read INTEGER DEFAULT 0 NOT NULL, notification_time INTEGER DEFAULT 1 NOT NULL, data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; @@ -642,7 +642,7 @@ CREATE TABLE phpbb_notifications ( ALTER TABLE phpbb_notifications ADD PRIMARY KEY (notification_id);; CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications(item_type, item_id);; -CREATE INDEX phpbb_notifications_user ON phpbb_notifications(user_id, unread);; +CREATE INDEX phpbb_notifications_user ON phpbb_notifications(user_id, notification_read);; CREATE GENERATOR phpbb_notifications_gen;; SET GENERATOR phpbb_notifications_gen TO 0;; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 18f3dd3a04..1fa3616857 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -778,7 +778,7 @@ CREATE TABLE [phpbb_notifications] ( [item_id] [int] DEFAULT (0) NOT NULL , [item_parent_id] [int] DEFAULT (0) NOT NULL , [user_id] [int] DEFAULT (0) NOT NULL , - [unread] [int] DEFAULT (1) NOT NULL , + [notification_read] [int] DEFAULT (0) NOT NULL , [notification_time] [int] DEFAULT (1) NOT NULL , [data] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] @@ -794,7 +794,7 @@ GO CREATE INDEX [item_ident] ON [phpbb_notifications]([item_type], [item_id]) ON [PRIMARY] GO -CREATE INDEX [user] ON [phpbb_notifications]([user_id], [unread]) ON [PRIMARY] +CREATE INDEX [user] ON [phpbb_notifications]([user_id], [notification_read]) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 140cb354a7..8163b7a051 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -445,12 +445,12 @@ CREATE TABLE phpbb_notifications ( item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + notification_read tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL, data blob NOT NULL, PRIMARY KEY (notification_id), KEY item_ident (item_type, item_id), - KEY user (user_id, unread) + KEY user (user_id, notification_read) ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 913968c174..6654734ab8 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -445,12 +445,12 @@ CREATE TABLE phpbb_notifications ( item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, item_parent_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - unread tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + notification_read tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL, data text NOT NULL, PRIMARY KEY (notification_id), KEY item_ident (item_type, item_id), - KEY user (user_id, unread) + KEY user (user_id, notification_read) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 8a6e9fffc6..a65fe63167 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -860,7 +860,7 @@ CREATE TABLE phpbb_notifications ( item_id number(8) DEFAULT '0' NOT NULL, item_parent_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, - unread number(1) DEFAULT '1' NOT NULL, + notification_read number(1) DEFAULT '0' NOT NULL, notification_time number(11) DEFAULT '1' NOT NULL, data clob DEFAULT '' , CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) @@ -869,7 +869,7 @@ CREATE TABLE phpbb_notifications ( CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id) / -CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread) +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read) / CREATE SEQUENCE phpbb_notifications_seq diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 6d9a910912..504ffe8282 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -617,14 +617,14 @@ CREATE TABLE phpbb_notifications ( item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), item_parent_id INT4 DEFAULT '0' NOT NULL CHECK (item_parent_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), - unread INT2 DEFAULT '1' NOT NULL CHECK (unread >= 0), + notification_read INT2 DEFAULT '0' NOT NULL CHECK (notification_read >= 0), notification_time INT4 DEFAULT '1' NOT NULL CHECK (notification_time >= 0), data varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (notification_id) ); CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); -CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread); +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read); /* Table: 'phpbb_poll_options' diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 7f93aaf0c7..836d0a0bd0 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -432,13 +432,13 @@ CREATE TABLE phpbb_notifications ( item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', item_parent_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', - unread INTEGER UNSIGNED NOT NULL DEFAULT '1', + notification_read INTEGER UNSIGNED NOT NULL DEFAULT '0', notification_time INTEGER UNSIGNED NOT NULL DEFAULT '1', data text(65535) NOT NULL DEFAULT '' ); CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); -CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, unread); +CREATE INDEX phpbb_notifications_user ON phpbb_notifications (user_id, notification_read); # Table: 'phpbb_poll_options' CREATE TABLE phpbb_poll_options ( -- cgit v1.2.1 From eeb40181956b578ca98ed0106f3019d8c8299ed3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Dec 2012 21:17:05 -0600 Subject: [ticket/11103] data -> notification_data PHPBB3-11103 --- phpBB/install/database_update.php | 2 +- phpBB/install/schemas/firebird_schema.sql | 2 +- phpBB/install/schemas/mssql_schema.sql | 2 +- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/oracle_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 364eca9267..ed1c6ee847 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1200,7 +1200,7 @@ function database_update_info() 'notification_read' => array('BOOL', 0), 'is_enabled' => array('BOOL', 1), 'notification_time' => array('TIMESTAMP', 1), - 'data' => array('TEXT_UNI', ''), + 'notification_data' => array('TEXT_UNI', ''), ), 'PRIMARY_KEY' => 'notification_id', 'KEYS' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index bb4e413ba1..260b75947a 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -636,7 +636,7 @@ CREATE TABLE phpbb_notifications ( user_id INTEGER DEFAULT 0 NOT NULL, notification_read INTEGER DEFAULT 0 NOT NULL, notification_time INTEGER DEFAULT 1 NOT NULL, - data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL + notification_data BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; ALTER TABLE phpbb_notifications ADD PRIMARY KEY (notification_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 1fa3616857..aa9766f91f 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -780,7 +780,7 @@ CREATE TABLE [phpbb_notifications] ( [user_id] [int] DEFAULT (0) NOT NULL , [notification_read] [int] DEFAULT (0) NOT NULL , [notification_time] [int] DEFAULT (1) NOT NULL , - [data] [varchar] (4000) DEFAULT ('') NOT NULL + [notification_data] [varchar] (4000) DEFAULT ('') NOT NULL ) ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 8163b7a051..ebadc93f05 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -447,7 +447,7 @@ CREATE TABLE phpbb_notifications ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, notification_read tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL, - data blob NOT NULL, + notification_data blob NOT NULL, PRIMARY KEY (notification_id), KEY item_ident (item_type, item_id), KEY user (user_id, notification_read) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 6654734ab8..ff46c13fef 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -447,7 +447,7 @@ CREATE TABLE phpbb_notifications ( user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, notification_read tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, notification_time int(11) UNSIGNED DEFAULT '1' NOT NULL, - data text NOT NULL, + notification_data text NOT NULL, PRIMARY KEY (notification_id), KEY item_ident (item_type, item_id), KEY user (user_id, notification_read) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index a65fe63167..7a285c6d55 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -862,7 +862,7 @@ CREATE TABLE phpbb_notifications ( user_id number(8) DEFAULT '0' NOT NULL, notification_read number(1) DEFAULT '0' NOT NULL, notification_time number(11) DEFAULT '1' NOT NULL, - data clob DEFAULT '' , + notification_data clob DEFAULT '' , CONSTRAINT pk_phpbb_notifications PRIMARY KEY (notification_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 504ffe8282..1035dd1ce8 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -619,7 +619,7 @@ CREATE TABLE phpbb_notifications ( user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), notification_read INT2 DEFAULT '0' NOT NULL CHECK (notification_read >= 0), notification_time INT4 DEFAULT '1' NOT NULL CHECK (notification_time >= 0), - data varchar(4000) DEFAULT '' NOT NULL, + notification_data varchar(4000) DEFAULT '' NOT NULL, PRIMARY KEY (notification_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 836d0a0bd0..3586a9040d 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -434,7 +434,7 @@ CREATE TABLE phpbb_notifications ( user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', notification_read INTEGER UNSIGNED NOT NULL DEFAULT '0', notification_time INTEGER UNSIGNED NOT NULL DEFAULT '1', - data text(65535) NOT NULL DEFAULT '' + notification_data text(65535) NOT NULL DEFAULT '' ); CREATE INDEX phpbb_notifications_item_ident ON phpbb_notifications (item_type, item_id); -- cgit v1.2.1 From 8dc2f69e8a1900b4560c3a982fc9df60511055d8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Dec 2012 21:17:37 -0600 Subject: [ticket/11103] remove is_enabled PHPBB3-11103 --- phpBB/install/database_update.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ed1c6ee847..6a90c51109 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1198,7 +1198,6 @@ function database_update_info() 'item_parent_id' => array('UINT', 0), 'user_id' => array('UINT', 0), 'notification_read' => array('BOOL', 0), - 'is_enabled' => array('BOOL', 1), 'notification_time' => array('TIMESTAMP', 1), 'notification_data' => array('TEXT_UNI', ''), ), -- cgit v1.2.1 From 07282a30ae077825ea81a4e26839ac0473dc97b7 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Tue, 15 Jan 2013 12:10:07 -0600 Subject: [ticket/11103] Fix some various issues, better comments PHPBB3-11103 --- phpBB/install/database_update.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 59274f29ae..57a027cf2a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -101,6 +101,10 @@ if (!defined('NOTIFICATION_TYPES_TABLE')) { define('NOTIFICATION_TYPES_TABLE', $table_prefix . 'notification_types'); } +if (!defined('NOTIFICATIONS_TYPES_TABLE')) +{ + define('NOTIFICATIONS_TYPES_TABLE', $table_prefix . 'notifications_types'); +} if (!defined('NOTIFICATIONS_TABLE')) { define('NOTIFICATIONS_TABLE', $table_prefix . 'notifications'); -- cgit v1.2.1 From b567e0963099b911e0d1d7b262c777a6969aad1f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 31 Jan 2013 10:14:42 -0600 Subject: [ticket/11103] Remove Primary Key on user_notifications table PHPBB3-11103 --- phpBB/install/database_update.php | 6 ------ phpBB/install/schemas/firebird_schema.sql | 2 -- phpBB/install/schemas/mssql_schema.sql | 10 ---------- phpBB/install/schemas/mysql_40_schema.sql | 3 +-- phpBB/install/schemas/mysql_41_schema.sql | 3 +-- phpBB/install/schemas/oracle_schema.sql | 3 +-- phpBB/install/schemas/postgres_schema.sql | 3 +-- phpBB/install/schemas/sqlite_schema.sql | 3 +-- 8 files changed, 5 insertions(+), 28 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 57a027cf2a..45632a0c3a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1213,12 +1213,6 @@ function database_update_info() 'method' => array('VCHAR:255', ''), 'notify' => array('BOOL', 1), ), - 'PRIMARY_KEY' => array( - 'item_type', - 'item_id', - 'user_id', - 'method', - ), ), ), 'add_columns' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index d654193d7b..a1b4c4e0ee 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -1252,8 +1252,6 @@ CREATE TABLE phpbb_user_notifications ( notify INTEGER DEFAULT 1 NOT NULL );; -ALTER TABLE phpbb_user_notifications ADD PRIMARY KEY (item_type, item_id, user_id, method);; - # Table: 'phpbb_user_group' CREATE TABLE phpbb_user_group ( diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 30016e43b1..38e01504cb 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1538,16 +1538,6 @@ CREATE TABLE [phpbb_user_notifications] ( ) ON [PRIMARY] GO -ALTER TABLE [phpbb_user_notifications] WITH NOCHECK ADD - CONSTRAINT [PK_phpbb_user_notifications] PRIMARY KEY CLUSTERED - ( - [item_type], - [item_id], - [user_id], - [method] - ) ON [PRIMARY] -GO - /* Table: 'phpbb_user_group' diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index fef5357d2a..19df59f6f2 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -884,8 +884,7 @@ CREATE TABLE phpbb_user_notifications ( item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varbinary(255) DEFAULT '' NOT NULL, - notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (item_type, item_id, user_id, method) + notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL ); diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index a797c36c20..3fde7030a6 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -884,8 +884,7 @@ CREATE TABLE phpbb_user_notifications ( item_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, user_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, method varchar(255) DEFAULT '' NOT NULL, - notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, - PRIMARY KEY (item_type, item_id, user_id, method) + notify tinyint(1) UNSIGNED DEFAULT '1' NOT NULL ) CHARACTER SET `utf8` COLLATE `utf8_bin`; diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 8932f04820..0852524691 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1650,8 +1650,7 @@ CREATE TABLE phpbb_user_notifications ( item_id number(8) DEFAULT '0' NOT NULL, user_id number(8) DEFAULT '0' NOT NULL, method varchar2(255) DEFAULT '' , - notify number(1) DEFAULT '1' NOT NULL, - CONSTRAINT pk_phpbb_user_notifications PRIMARY KEY (item_type, item_id, user_id, method) + notify number(1) DEFAULT '1' NOT NULL ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 426f2decbf..8892357805 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -1136,8 +1136,7 @@ CREATE TABLE phpbb_user_notifications ( item_id INT4 DEFAULT '0' NOT NULL CHECK (item_id >= 0), user_id INT4 DEFAULT '0' NOT NULL CHECK (user_id >= 0), method varchar(255) DEFAULT '' NOT NULL, - notify INT2 DEFAULT '1' NOT NULL CHECK (notify >= 0), - PRIMARY KEY (item_type, item_id, user_id, method) + notify INT2 DEFAULT '1' NOT NULL CHECK (notify >= 0) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index fb6797deb6..6b3f4ac60b 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -857,8 +857,7 @@ CREATE TABLE phpbb_user_notifications ( item_id INTEGER UNSIGNED NOT NULL DEFAULT '0', user_id INTEGER UNSIGNED NOT NULL DEFAULT '0', method varchar(255) NOT NULL DEFAULT '', - notify INTEGER UNSIGNED NOT NULL DEFAULT '1', - PRIMARY KEY (item_type, item_id, user_id, method) + notify INTEGER UNSIGNED NOT NULL DEFAULT '1' ); -- cgit v1.2.1 From fb4f7470d481bd73dd505e7ce0522907f67773ef Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 15:34:03 -0600 Subject: [feature/migrations] Rebuilding migrations data on develop So this is easy to merge later. PHPBB3-9737 --- phpBB/install/database_update_migrations.php | 139 +++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 phpBB/install/database_update_migrations.php (limited to 'phpBB/install') diff --git a/phpBB/install/database_update_migrations.php b/phpBB/install/database_update_migrations.php new file mode 100644 index 0000000000..52682dc489 --- /dev/null +++ b/phpBB/install/database_update_migrations.php @@ -0,0 +1,139 @@ +register(); + +// Set up container +$container_extensions = array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), +); +$container_passes = array( + new phpbb_di_pass_collection_pass(), + //new phpbb_di_pass_kernel_pass(), +); +$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); + +// Compile the container +foreach ($container_passes as $pass) +{ + $phpbb_container->addCompilerPass($pass); +} +$phpbb_container->compile(); + +// set up caching +$cache = $phpbb_container->get('cache'); + +// Instantiate some basic classes +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); +$user = $phpbb_container->get('user'); +$auth = $phpbb_container->get('auth'); +$db = $phpbb_container->get('dbal.conn'); + +// make sure request_var uses this request instance +request_var('', 0, false, false, $request); // "dependency injection" for a function + +// Grab global variables, re-cache if necessary +$config = $phpbb_container->get('config'); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config); + +// End startup code + +$db_tools = $phpbb_container->get('dbal.tools'); +if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) +{ + $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); +} + +$migrator = $phpbb_container->get('migrator'); +$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); + +// What is a safe limit of execution time? Half the max execution time should be safe. +$safe_time_limit = (ini_get('max_execution_time') / 2); + +while (!$migrator->finished()) +{ + try + { + $migrator->update(); + } + catch (phpbb_db_migration_exception $e) + { + echo $e; + + garbage_collection(); + exit_handler(); + } + + echo $migrator->last_run_migration['name'] . '
'; + + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $update_start_time) >= $safe_time_limit) + { + //echo ''; + echo 'Update not yet completed.
'; + echo 'Continue'; + + garbage_collection(); + exit_handler(); + } +} + +echo 'Finished'; + +garbage_collection(); +exit_handler(); -- cgit v1.2.1 From bb99a2609d9fcdd3c20ea9c910ae6e05d9da56cd Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 16:00:58 -0600 Subject: [feature/migrations] Replace database_update.php with migrations updater PHPBB3-9737 --- phpBB/install/database_update.php | 2899 +------------------------- phpBB/install/database_update_migrations.php | 139 -- 2 files changed, 99 insertions(+), 2939 deletions(-) delete mode 100644 phpBB/install/database_update_migrations.php (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4e17a1429c..7431c96231 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1,39 +1,23 @@ INSTALL.html before attempting to update."); @@ -81,38 +57,36 @@ $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_ro require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/functions_container.' . $phpEx); -phpbb_require_updated('includes/functions_content.' . $phpEx, true); - -require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); -phpbb_require_updated('includes/db/db_tools.' . $phpEx); - -// new table constants are separately defined here in case the updater is run -// before the files are updated -if (!defined('LOGIN_ATTEMPT_TABLE')) -{ - define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); -} -if (!defined('EXT_TABLE')) -{ - define('EXT_TABLE', $table_prefix . 'ext'); -} +// Set PHP error handler to ours +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); $phpbb_class_loader->register(); -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); -$phpbb_class_loader_ext->register(); -// Set up container -$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); +// Set up container (must be done here because extensions table may not exist) +$container_extensions = array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), +); +$container_passes = array( + new phpbb_di_pass_collection_pass(), + //new phpbb_di_pass_kernel_pass(), +); +$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); -$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); -$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); +// Compile the container +foreach ($container_passes as $pass) +{ + $phpbb_container->addCompilerPass($pass); +} +$phpbb_container->compile(); // set up caching $cache = $phpbb_container->get('cache'); @@ -127,6 +101,16 @@ $db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function +// Grab global variables, re-cache if necessary +$config = $phpbb_container->get('config'); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config); +$orig_version = $config['version']; + +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/common.' . $phpEx); +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/acp/common.' . $phpEx); +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/install.' . $phpEx); + // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) { @@ -144,129 +128,7 @@ else $phpbb_hook = false; } -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); - -// We do not need this any longer, unset for safety purposes -unset($dbpasswd); - -$user->ip = ''; -if ($request->server('REMOTE_ADDR')) -{ - $user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($request->server('REMOTE_ADDR')) : $request->server('REMOTE_ADDR'); -} - -$sql = "SELECT config_value - FROM " . CONFIG_TABLE . " - WHERE config_name = 'default_lang'"; -$result = $db->sql_query($sql); -$row = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -$language = basename(request_var('language', '')); - -if (!$language) -{ - $language = $row['config_value']; -} - -if (!file_exists($phpbb_root_path . 'language/' . $language)) -{ - die('No language found!'); -} - -// And finally, load the relevant language files -include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); - -// Set PHP error handler to ours -//set_error_handler('msg_handler'); - -// Define some variables for the database update -$inline_update = (request_var('type', 0)) ? true : false; - -// To let set_config() calls succeed, we need to make the config array available globally -$config = new phpbb_config_db($db, $phpbb_container->get('cache.driver'), CONFIG_TABLE); -set_config(null, null, null, $config); -set_config_count(null, null, null, $config); - -// Update asset_version -if (isset($config['assets_version'])) -{ - set_config('assets_version', $config['assets_version'] + 1); -} - -// phpbb_db_tools will be taken from new files (under install/update/new) -// if possible, falling back to the board's copy. -$db_tools = new phpbb_db_tools($db, true); - -$database_update_info = database_update_info(); - -$error_ary = array(); -$errored = false; - -$sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - AND topic_type = ' . POST_GLOBAL; -$result = $db->sql_query_limit($sql, 1); -$has_global = (int) $db->sql_fetchfield('topic_id'); -$db->sql_freeresult($result); -$ga_forum_id = request_var('ga_forum_id', 0); - -if ($has_global && !$ga_forum_id) -{ - ?> - - - - - - <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> - - - - - - -
- - -
-
-
- -
-
- -

- -
- -
- - - - -
- @@ -280,2674 +142,111 @@ header('Content-type: text/html; charset=UTF-8'); -
- - -
-
-
- -
-
- -

- -
- -

:: sql_layer; ?>
-' . $config['version'] . '
'; -echo $lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . '

'; - -$current_version = str_replace('rc', 'RC', strtolower($config['version'])); -$latest_version = str_replace('rc', 'RC', strtolower($updates_to_version)); -$orig_version = $config['version']; - -// Fill DB version -if (empty($config['dbms_version'])) -{ - set_config('dbms_version', $db->sql_server_info(true)); -} +
+ -// Firebird update from Firebird 2.0 to 2.1+ required? -if ($db->sql_layer == 'firebird') -{ - // We do not trust any PHP5 function enabled, we will simply test for a function new in 2.1 - $db->sql_return_on_error(true); +
+
+
+ +
+
- $sql = 'SELECT 1 FROM RDB$DATABASE - WHERE BIN_AND(10, 1) = 0'; - $result = $db->sql_query($sql); +

- if (!$result || $db->sql_error_triggered) - { - echo '

'; - echo '

' . $lang['ERROR'] . '


'; +
- echo '

' . $lang['FIREBIRD_DBMS_UPDATE_REQUIRED'] . '

'; +

:: sql_layer; ?>
+ ::
- _print_footer(); +sql_freeresult($result); - $db->sql_return_on_error(false); -} +// End startup code -// MySQL update from MySQL 3.x/4.x to > 4.1.x required? -if ($db->sql_layer == 'mysql' || $db->sql_layer == 'mysql4' || $db->sql_layer == 'mysqli') +$db_tools = $phpbb_container->get('dbal.tools'); +if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) { - // Verify by fetching column... if the column type matches the new type we update dbms_version... - $sql = "SHOW COLUMNS FROM " . CONFIG_TABLE; - $result = $db->sql_query($sql); - - $column_type = ''; - while ($row = $db->sql_fetchrow($result)) - { - $field = strtolower($row['Field']); - - if ($field == 'config_value') - { - $column_type = strtolower($row['Type']); - break; - } - } - $db->sql_freeresult($result); - - // If column type is blob, but mysql version says we are on > 4.1.3, then the schema needs an update - if (strpos($column_type, 'blob') !== false && version_compare($db->sql_server_info(true), '4.1.3', '>=')) - { - echo '

'; - echo '

' . $lang['ERROR'] . '


'; - - echo '

' . sprintf($lang['MYSQL_SCHEMA_UPDATE_REQUIRED'], $config['dbms_version'], $db->sql_server_info(true)) . '

'; - - _print_footer(); - - exit_handler(); - exit; - } + $db_tools->sql_create_table(MIGRATIONS_TABLE, array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); } -// Now check if the user wants to update from a version we no longer support updates from -if (version_compare($current_version, $oldest_from_version, '<')) -{ - echo '

' . $lang['ERROR'] . '


'; - echo '

' . sprintf($lang['DB_UPDATE_NOT_SUPPORTED'], $oldest_from_version, $current_version) . '

'; +$migrator = $phpbb_container->get('migrator'); +$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); - _print_footer(); - exit_handler(); - exit; -} +// What is a safe limit of execution time? Half the max execution time should be safe. +$safe_time_limit = (ini_get('max_execution_time') / 2); -// If the latest version and the current version are 'unequal', we will update the version_update_from, else we do not update anything. -if ($inline_update) +while (!$migrator->finished()) { - if ($current_version !== $latest_version) + try { - set_config('version_update_from', $orig_version); + $migrator->update(); } -} -else -{ - // If not called from the update script, we will actually remove the traces - $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); -} - -// Schema updates -?> -

- -

- -
-

:: - -= as the version to be updated to next, we will skip the process - if (version_compare($version, $current_version, '<') && version_compare($current_version, $next_version, '>=')) + catch (phpbb_db_migration_exception $e) { - continue; - } + echo $e; - if (!sizeof($schema_changes)) - { - continue; + end_update($cache); } - $no_updates = false; + echo $migrator->last_run_migration['name'] . '
'; - // We run one index after the other... to be consistent with schema changes... - foreach ($schema_changes as $key => $changes) + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing + if ((time() - $update_start_time) >= $safe_time_limit) { - $statements = $db_tools->perform_schema_changes(array($key => $changes)); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - } -} - -_write_result($no_updates, $errored, $error_ary); - -// Data updates -$error_ary = array(); -$errored = $no_updates = false; - -?> - -

-

-
-

:: - -'; + echo 'Update not yet completed.
'; + echo 'Continue'; -// some code magic -for ($i = 0; $i < sizeof($versions); $i++) -{ - $version = $versions[$i]; - $next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version; - - // If the installed version to be updated to is < than the current version, and if the current version is >= as the version to be updated to next, we will skip the process - if (version_compare($version, $current_version, '<') && version_compare($current_version, $next_version, '>=')) - { - continue; + end_update($cache); } - - change_database_data($no_updates, $version); -} - -_write_result($no_updates, $errored, $error_ary); - -$error_ary = array(); -$errored = $no_updates = false; - -?> - -

-

-
-

:: - -sql_server_info(true)); - -/* Optimize/vacuum analyze the tables where appropriate -// this should be done for each version in future along with -// the version number update -switch ($db->sql_layer) +if ($orig_version != $config['version']) { - case 'mysql': - case 'mysqli': - case 'mysql4': - $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; - _sql($sql, $errored, $error_ary); - break; - - case 'postgresql': - _sql("VACUUM ANALYZE", $errored, $error_ary); - break; + add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); } -*/ - -_write_result($no_updates, $errored, $error_ary); -?> - -
-

+echo 'Finished'; -
- - - -

+ $cache->purge(); -

- - - -

- -

" class="button1">

- -get('cache.driver')->purge(); - -_print_footer(); - -garbage_collection(); - -if (function_exists('exit_handler')) -{ - exit_handler(); -} - -/** -* Print out footer -*/ -function _print_footer() -{ - echo << +

+
+
+
- +
-
-
- -
- -EOF; -} - -/** -* Function for triggering an sql statement -*/ -function _sql($sql, &$errored, &$error_ary, $echo_dot = true) -{ - global $db; - - if (defined('DEBUG')) - { - echo "
\n{$sql}\n
"; - } - - $db->sql_return_on_error(true); - - if ($sql === 'begin') - { - $result = $db->sql_transaction('begin'); - } - else if ($sql === 'commit') - { - $result = $db->sql_transaction('commit'); - } - else - { - $result = $db->sql_query($sql); - if ($db->sql_error_triggered) - { - $errored = true; - $error_ary['sql'][] = $db->sql_error_sql; - $error_ary['error_code'][] = $db->sql_error_returned; - } - } - - $db->sql_return_on_error(false); - - if ($echo_dot) - { - echo ". \n"; - flush(); - } - - return $result; -} - -function _write_result($no_updates, $errored, $error_ary) -{ - global $lang; - - if ($no_updates) - { - echo ' ' . $lang['NO_UPDATES_REQUIRED'] . '

'; - } - else - { - echo ' ' . $lang['DONE'] . '

' . $lang['RESULT'] . ' :: '; - - if ($errored) - { - echo ' ' . $lang['SOME_QUERIES_FAILED'] . '
    '; - - for ($i = 0; $i < sizeof($error_ary['sql']); $i++) - { - echo '
  • ' . $lang['ERROR'] . ' :: ' . htmlspecialchars($error_ary['error_code'][$i]['message']) . '
    '; - echo $lang['SQL'] . ' :: ' . htmlspecialchars($error_ary['sql'][$i]) . '

  • '; - } - - echo '


' . $lang['SQL_FAILURE_EXPLAIN'] . '

'; - } - else - { - echo '' . $lang['NO_ERRORS'] . '

'; - } - } -} - -function _add_modules($modules_to_install) -{ - global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config; - - // modules require an extension manager - if (empty($phpbb_extension_manager)) - { - $phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx"); - } - include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); - - $_module = new acp_modules(); - - foreach ($modules_to_install as $module_mode => $module_data) - { - $_module->module_class = $module_data['class']; - - // Determine parent id first - $sql = 'SELECT module_id - FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($module_data['class']) . "' - AND module_langname = '" . $db->sql_escape($module_data['cat']) . "' - AND module_mode = '' - AND module_basename = ''"; - $result = $db->sql_query($sql); - - // There may be more than one categories with the same name - $categories = array(); - while ($row = $db->sql_fetchrow($result)) - { - $categories[] = (int) $row['module_id']; - } - $db->sql_freeresult($result); - - if (!sizeof($categories)) - { - continue; - } - - // Add the module to all categories found - foreach ($categories as $parent_id) - { - // Check if the module already exists - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = '" . $db->sql_escape($module_data['base']) . "' - AND module_class = '" . $db->sql_escape($module_data['class']) . "' - AND module_langname = '" . $db->sql_escape($module_data['title']) . "' - AND module_mode = '" . $db->sql_escape($module_mode) . "' - AND module_auth = '" . $db->sql_escape($module_data['auth']) . "' - AND parent_id = {$parent_id}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // If it exists, we simply continue with the next category - if ($row) - { - continue; - } - - // Build the module sql row - $module_row = array( - 'module_basename' => $module_data['base'], - 'module_enabled' => (isset($module_data['enabled'])) ? (int) $module_data['enabled'] : 1, - 'module_display' => (isset($module_data['display'])) ? (int) $module_data['display'] : 1, - 'parent_id' => $parent_id, - 'module_class' => $module_data['class'], - 'module_langname' => $module_data['title'], - 'module_mode' => $module_mode, - 'module_auth' => $module_data['auth'], - ); - - $_module->update_module_data($module_row, true); +sql_escape($module_data['class']) . "' - AND module_basename = '" . $db->sql_escape($module_data['base']) . "' - AND module_langname = '" . $db->sql_escape($after_langname) . "' - AND module_mode = '" . $db->sql_escape($after_mode) . "' - AND parent_id = '{$parent_id}'"; - $result = $db->sql_query($sql); - $first_left_id = (int) $db->sql_fetchfield('left_id'); - $db->sql_freeresult($result); - - if (!$first_left_id) - { - continue; - } - - // Ok, count the number of modules between $after_mode and the added module - $sql = 'SELECT COUNT(module_id) as num_modules - FROM ' . MODULES_TABLE . " - WHERE module_class = '" . $db->sql_escape($module_data['class']) . "' - AND parent_id = {$parent_id} - AND left_id BETWEEN {$first_left_id} AND {$module_row['left_id']}"; - $result = $db->sql_query($sql); - $steps = (int) $db->sql_fetchfield('num_modules'); - $db->sql_freeresult($result); - - // We need to substract 2 - $steps -= 2; - - if ($steps <= 0) - { - continue; - } - - // Ok, move module up $num_modules times. ;) - $_module->move_module_by($module_row, 'move_up', $steps); - } - } - - $_module->remove_cache_file(); -} - -/** -* Add a new permission, optionally copy permission setting from another -* -* @param auth_admin $auth_admin auth_admin object -* @param phpbb_db_driver $db Database object -* @param string $permission_name Name of the permission to add -* @param bool $is_global True is global, false is local -* @param string $copy_from Optional permission name from which to copy -* @return bool true on success, false on failure -*/ -function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permission_name, $is_global = true, $copy_from = '') -{ - // Only add a permission that don't already exist - if (!empty($auth_admin->acl_options['id'][$permission_name])) - { - return true; - } - - $permission_scope = $is_global ? 'global' : 'local'; - - $result = $auth_admin->acl_add_option(array( - $permission_scope => array($permission_name), - )); - - if (!$result) - { - return $result; - } - - // The permission has been added, now we can copy it if needed - if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from])) - { - $old_id = $auth_admin->acl_options['id'][$copy_from]; - $new_id = $auth_admin->acl_options['id'][$permission_name]; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - $auth_admin->acl_clear_prefetch(); - } - - return true; -} - -/**************************************************************************** -* ADD YOUR DATABASE SCHEMA CHANGES HERE * -*****************************************************************************/ -function database_update_info() -{ - return array( - // Changes from 3.0.0 to the next version - '3.0.0' => array( - // Add the following columns - 'add_columns' => array( - FORUMS_TABLE => array( - 'display_subforum_list' => array('BOOL', 1), - ), - SESSIONS_TABLE => array( - 'session_forum_id' => array('UINT', 0), - ), - ), - 'drop_keys' => array( - GROUPS_TABLE => array('group_legend'), - ), - 'add_index' => array( - SESSIONS_TABLE => array( - 'session_forum_id' => array('session_forum_id'), - ), - GROUPS_TABLE => array( - 'group_legend_name' => array('group_legend', 'group_name'), - ), - ), - ), - // No changes from 3.0.1-RC1 to 3.0.1 - '3.0.1-RC1' => array(), - // No changes from 3.0.1 to 3.0.2-RC1 - '3.0.1' => array(), - // Changes from 3.0.2-RC1 to 3.0.2-RC2 - '3.0.2-RC1' => array( - 'change_columns' => array( - DRAFTS_TABLE => array( - 'draft_subject' => array('STEXT_UNI', ''), - ), - FORUMS_TABLE => array( - 'forum_last_post_subject' => array('STEXT_UNI', ''), - ), - POSTS_TABLE => array( - 'post_subject' => array('STEXT_UNI', '', 'true_sort'), - ), - PRIVMSGS_TABLE => array( - 'message_subject' => array('STEXT_UNI', ''), - ), - TOPICS_TABLE => array( - 'topic_title' => array('STEXT_UNI', '', 'true_sort'), - 'topic_last_post_subject' => array('STEXT_UNI', ''), - ), - ), - 'drop_keys' => array( - SESSIONS_TABLE => array('session_forum_id'), - ), - 'add_index' => array( - SESSIONS_TABLE => array( - 'session_fid' => array('session_forum_id'), - ), - ), - ), - // No changes from 3.0.2-RC2 to 3.0.2 - '3.0.2-RC2' => array(), - - // Changes from 3.0.2 to 3.0.3-RC1 - '3.0.2' => array( - // Add the following columns - 'add_columns' => array( - STYLES_TEMPLATE_TABLE => array( - 'template_inherits_id' => array('UINT:4', 0), - 'template_inherit_path' => array('VCHAR', ''), - ), - GROUPS_TABLE => array( - 'group_max_recipients' => array('UINT', 0), - ), - ), - ), - - // No changes from 3.0.3-RC1 to 3.0.3 - '3.0.3-RC1' => array(), - - // Changes from 3.0.3 to 3.0.4-RC1 - '3.0.3' => array( - 'add_columns' => array( - PROFILE_FIELDS_TABLE => array( - 'field_show_profile' => array('BOOL', 0), - ), - ), - 'change_columns' => array( - STYLES_TABLE => array( - 'style_id' => array('UINT', NULL, 'auto_increment'), - 'template_id' => array('UINT', 0), - 'theme_id' => array('UINT', 0), - 'imageset_id' => array('UINT', 0), - ), - STYLES_IMAGESET_TABLE => array( - 'imageset_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_IMAGESET_DATA_TABLE => array( - 'image_id' => array('UINT', NULL, 'auto_increment'), - 'imageset_id' => array('UINT', 0), - ), - STYLES_THEME_TABLE => array( - 'theme_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_TEMPLATE_TABLE => array( - 'template_id' => array('UINT', NULL, 'auto_increment'), - ), - STYLES_TEMPLATE_DATA_TABLE => array( - 'template_id' => array('UINT', 0), - ), - FORUMS_TABLE => array( - 'forum_style' => array('UINT', 0), - ), - USERS_TABLE => array( - 'user_style' => array('UINT', 0), - ), - ), - ), - - // Changes from 3.0.4-RC1 to 3.0.4 - '3.0.4-RC1' => array(), - - // Changes from 3.0.4 to 3.0.5-RC1 - '3.0.4' => array( - 'change_columns' => array( - FORUMS_TABLE => array( - 'forum_style' => array('UINT', 0), - ), - ), - ), - - // No changes from 3.0.5-RC1 to 3.0.5 - '3.0.5-RC1' => array(), - - // Changes from 3.0.5 to 3.0.6-RC1 - '3.0.5' => array( - 'add_columns' => array( - CONFIRM_TABLE => array( - 'attempts' => array('UINT', 0), - ), - USERS_TABLE => array( - 'user_new' => array('BOOL', 1), - 'user_reminded' => array('TINT:4', 0), - 'user_reminded_time'=> array('TIMESTAMP', 0), - ), - GROUPS_TABLE => array( - 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), - ), - PRIVMSGS_TABLE => array( - 'message_reported' => array('BOOL', 0), - ), - REPORTS_TABLE => array( - 'pm_id' => array('UINT', 0), - ), - PROFILE_FIELDS_TABLE => array( - 'field_show_on_vt' => array('BOOL', 0), - ), - FORUMS_TABLE => array( - 'forum_options' => array('UINT:20', 0), - ), - ), - 'change_columns' => array( - USERS_TABLE => array( - 'user_options' => array('UINT:11', 230271), - ), - ), - 'add_index' => array( - REPORTS_TABLE => array( - 'post_id' => array('post_id'), - 'pm_id' => array('pm_id'), - ), - POSTS_TABLE => array( - 'post_username' => array('post_username:255'), - ), - ), - ), - - // No changes from 3.0.6-RC1 to 3.0.6-RC2 - '3.0.6-RC1' => array(), - // No changes from 3.0.6-RC2 to 3.0.6-RC3 - '3.0.6-RC2' => array(), - // No changes from 3.0.6-RC3 to 3.0.6-RC4 - '3.0.6-RC3' => array(), - // No changes from 3.0.6-RC4 to 3.0.6 - '3.0.6-RC4' => array(), - - // Changes from 3.0.6 to 3.0.7-RC1 - '3.0.6' => array( - 'drop_keys' => array( - LOG_TABLE => array('log_time'), - ), - 'add_index' => array( - TOPICS_TRACK_TABLE => array( - 'topic_id' => array('topic_id'), - ), - ), - ), - - // No changes from 3.0.7-RC1 to 3.0.7-RC2 - '3.0.7-RC1' => array(), - // No changes from 3.0.7-RC2 to 3.0.7 - '3.0.7-RC2' => array(), - // No changes from 3.0.7 to 3.0.7-PL1 - '3.0.7' => array(), - // No changes from 3.0.7-PL1 to 3.0.8-RC1 - '3.0.7-PL1' => array(), - // No changes from 3.0.8-RC1 to 3.0.8 - '3.0.8-RC1' => array(), - // Changes from 3.0.8 to 3.0.9-RC1 - '3.0.8' => array( - 'add_tables' => array( - LOGIN_ATTEMPT_TABLE => array( - 'COLUMNS' => array( - // 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.12 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', ''), - 'attempt_time' => array('TIMESTAMP', 0), - 'user_id' => array('UINT', 0), - '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')), - 'att_time' => array('INDEX', array('attempt_time')), - 'user_id' => array('INDEX', 'user_id'), - ), - ), - ), - 'change_columns' => array( - BBCODES_TABLE => array( - 'bbcode_id' => array('USINT', 0), - ), - ), - ), - // No changes from 3.0.9-RC1 to 3.0.9-RC2 - '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(), - // No changes from 3.0.9-RC4 to 3.0.9 - '3.0.9-RC4' => array(), - // No changes from 3.0.9 to 3.0.10-RC1 - '3.0.9' => array(), - // No changes from 3.0.10-RC1 to 3.0.10-RC2 - '3.0.10-RC1' => array(), - // No changes from 3.0.10-RC2 to 3.0.10-RC3 - '3.0.10-RC2' => array(), - // No changes from 3.0.10-RC3 to 3.0.10 - '3.0.10-RC3' => array(), - // No changes from 3.0.10 to 3.0.11-RC1 - '3.0.10' => array(), - // Changes from 3.0.11-RC1 to 3.0.11-RC2 - '3.0.11-RC1' => array( - 'add_columns' => array( - PROFILE_FIELDS_TABLE => array( - 'field_show_novalue' => array('BOOL', 0), - ), - ), - ), - // No changes from 3.0.11-RC2 to 3.0.11 - '3.0.11-RC2' => array(), - // No changes from 3.0.11 to 3.0.12-RC1 - '3.0.11' => array(), - - /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */ - - // Changes from 3.1.0-dev to 3.1.0-A1 - '3.1.0-dev' => array( - 'add_tables' => array( - EXT_TABLE => array( - 'COLUMNS' => array( - 'ext_name' => array('VCHAR', ''), - 'ext_active' => array('BOOL', 0), - 'ext_state' => array('TEXT', ''), - ), - 'KEYS' => array( - 'ext_name' => array('UNIQUE', 'ext_name'), - ), - ), - ), - 'add_columns' => array( - GROUPS_TABLE => array( - 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), - ), - PROFILE_FIELDS_TABLE => array( - 'field_show_on_pm' => array('BOOL', 0), - ), - STYLES_TABLE => array( - 'style_path' => array('VCHAR:100', ''), - 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), - 'style_parent_id' => array('UINT:4', 0), - 'style_parent_tree' => array('TEXT', ''), - ), - REPORTS_TABLE => array( - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), - 'reported_post_enable_bbcode' => array('BOOL', 1), - 'reported_post_enable_smilies' => array('BOOL', 1), - 'reported_post_enable_magic_url' => array('BOOL', 1), - ), - ), - 'change_columns' => array( - GROUPS_TABLE => array( - 'group_legend' => array('UINT', 0), - ), - USERS_TABLE => array( - 'user_timezone' => array('VCHAR:100', ''), - ), - ), - ), - ); -} - -/**************************************************************************** -* ADD YOUR DATABASE DATA CHANGES HERE * -* REMEMBER: You NEED to enter a schema array above and a data array here, * -* even if both or one of them are empty. * -*****************************************************************************/ -function change_database_data(&$no_updates, $version) -{ - global $db, $db_tools, $errored, $error_ary, $config, $table_prefix, $phpbb_root_path, $phpEx; - - $update_helpers = new phpbb_update_helpers(); - - switch ($version) - { - case '3.0.0': - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_last_view_time = topic_last_post_time - WHERE topic_last_view_time = 0"; - _sql($sql, $errored, $error_ary); - - // Update smiley sizes - $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); - - foreach ($smileys as $smiley) - { - if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley)) - { - list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley); - - $sql = 'UPDATE ' . SMILIES_TABLE . ' - SET smiley_width = ' . $width . ', smiley_height = ' . $height . " - WHERE smiley_url = '" . $db->sql_escape($smiley) . "'"; - - _sql($sql, $errored, $error_ary); - } - } - - $no_updates = false; - break; - - // No changes from 3.0.1-RC1 to 3.0.1 - case '3.0.1-RC1': - break; - - // changes from 3.0.1 to 3.0.2-RC1 - case '3.0.1': - - set_config('referer_validation', '1'); - set_config('check_attachment_content', '1'); - set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title'); - - $no_updates = false; - break; - - // No changes from 3.0.2-RC1 to 3.0.2-RC2 - case '3.0.2-RC1': - break; - - // No changes from 3.0.2-RC2 to 3.0.2 - case '3.0.2-RC2': - break; - - // Changes from 3.0.2 to 3.0.3-RC1 - case '3.0.2': - set_config('enable_queue_trigger', '0'); - set_config('queue_trigger_posts', '3'); - - set_config('pm_max_recipients', '0'); - - // Set maximum number of recipients for the registered users, bots, guests group - $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 - WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); - _sql($sql, $errored, $error_ary); - - // Not prefilling yet - set_config('dbms_version', ''); - - // Add new permission u_masspm_group and duplicate settings from u_masspm - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - - // Only add the new permission if it does not already exist - if (empty($auth_admin->acl_options['id']['u_masspm_group'])) - { - $auth_admin->acl_add_option(array('global' => array('u_masspm_group'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['u_masspm']; - $new_id = $auth_admin->acl_options['id']['u_masspm_group']; - - $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); - - foreach ($tables as $table) - { - $sql = 'SELECT * - FROM ' . $table . ' - WHERE auth_option_id = ' . $old_id; - $result = _sql($sql, $errored, $error_ary); - - $sql_ary = array(); - while ($row = $db->sql_fetchrow($result)) - { - $row['auth_option_id'] = $new_id; - $sql_ary[] = $row; - } - $db->sql_freeresult($result); - - if (sizeof($sql_ary)) - { - $db->sql_multi_insert($table, $sql_ary); - } - } - - // Remove any old permission entries - $auth_admin->acl_clear_prefetch(); - } - - /** - * Do not resync post counts here. An admin may do this later from the ACP - $start = 0; - $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0'; - _sql($sql, $errored, $error_ary); - - do - { - $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id - FROM ' . POSTS_TABLE . ' - WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' - AND post_postcount = 1 AND post_approved = 1 - GROUP BY poster_id'; - $result = _sql($sql, $errored, $error_ary); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; - _sql($sql, $errored, $error_ary); - } - while ($row = $db->sql_fetchrow($result)); - - $start += $step; - } - else - { - $start = 0; - } - $db->sql_freeresult($result); - } - while ($start); - */ - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_a_email && cfg_email_enable\' - WHERE module_class = \'acp\' - AND module_basename = \'email\''; - _sql($sql, $errored, $error_ary); - - $no_updates = false; - break; - - // Changes from 3.0.3-RC1 to 3.0.3 - case '3.0.3-RC1': - if ($db->sql_layer == 'oracle') - { - // log_operation is CLOB - but we can change this later - $sql = 'UPDATE ' . LOG_TABLE . " - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation LIKE 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); - } - else - { - $sql = 'UPDATE ' . LOG_TABLE . " - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation = 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - break; - - // Changes from 3.0.3 to 3.0.4-RC1 - case '3.0.3': - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide - FROM ' . PROFILE_FIELDS_TABLE; - $result = _sql($sql, $errored, $error_ary); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array( - 'field_required' => 0, - 'field_show_on_reg' => 0, - 'field_hide' => 0, - 'field_show_profile'=> 0, - ); - - if ($row['field_required']) - { - $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_show_on_reg']) - { - $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; - } - else if ($row['field_hide']) - { - // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module - $sql_ary['field_hide'] = 1; - } - else - { - // equivelant to "none", which is the "Display in user control panel" option - $sql_ary['field_show_profile'] = 1; - } - - _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); - } - $no_updates = false; - - break; - - // Changes from 3.0.4-RC1 to 3.0.4 - case '3.0.4-RC1': - break; - - // Changes from 3.0.4 to 3.0.5-RC1 - case '3.0.4': - - // Captcha config variables - set_config('captcha_gd_wave', 0); - set_config('captcha_gd_3d_noise', 1); - set_config('captcha_gd_fonts', 1); - set_config('confirm_refresh', 1); - - // Maximum number of keywords - set_config('max_num_search_keywords', 10); - - // Remove static config var and put it back as dynamic variable - $sql = 'UPDATE ' . CONFIG_TABLE . " - SET is_dynamic = 1 - WHERE config_name = 'search_indexing_state'"; - _sql($sql, $errored, $error_ary); - - // Hash old MD5 passwords - $sql = 'SELECT user_id, user_password - FROM ' . USERS_TABLE . ' - WHERE user_pass_convert = 1'; - $result = _sql($sql, $errored, $error_ary); - - while ($row = $db->sql_fetchrow($result)) - { - if (strlen($row['user_password']) == 32) - { - $sql_ary = array( - 'user_password' => phpbb_hash($row['user_password']), - ); - - _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary); - } - } - $db->sql_freeresult($result); - - // Adjust bot entry - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = 'ichiro/' - WHERE bot_agent = 'ichiro/2'"; - _sql($sql, $errored, $error_ary); - - - // Before we are able to add a unique key to auth_option, we need to remove duplicate entries - - // We get duplicate entries first - $sql = 'SELECT auth_option - FROM ' . ACL_OPTIONS_TABLE . ' - GROUP BY auth_option - HAVING COUNT(*) >= 2'; - $result = $db->sql_query($sql); - - $auth_options = array(); - while ($row = $db->sql_fetchrow($result)) - { - $auth_options[] = $row['auth_option']; - } - $db->sql_freeresult($result); - - // Remove specific auth options - if (!empty($auth_options)) - { - foreach ($auth_options as $option) - { - // Select auth_option_ids... the largest id will be preserved - $sql = 'SELECT auth_option_id - FROM ' . ACL_OPTIONS_TABLE . " - WHERE auth_option = '" . $db->sql_escape($option) . "' - ORDER BY auth_option_id DESC"; - // sql_query_limit not possible here, due to bug in postgresql layer - $result = $db->sql_query($sql); - - // Skip first row, this is our original auth option we want to preserve - $row = $db->sql_fetchrow($result); - - while ($row = $db->sql_fetchrow($result)) - { - // Ok, remove this auth option... - _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); - } - $db->sql_freeresult($result); - } - } - - // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one. - $changes = array( - 'drop_keys' => array( - ACL_OPTIONS_TABLE => array('auth_option'), - ), - ); - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - $changes = array( - 'add_unique_index' => array( - ACL_OPTIONS_TABLE => array( - 'auth_option' => array('auth_option'), - ), - ), - ); - - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - - break; - - // No changes from 3.0.5-RC1 to 3.0.5 - case '3.0.5-RC1': - break; - - // Changes from 3.0.5 to 3.0.6-RC1 - case '3.0.5': - // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled... - if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) - { - set_config('captcha_plugin', 'phpbb_captcha_gd'); - } - else if (!isset($config['captcha_plugin'])) - { - set_config('captcha_plugin', 'phpbb_captcha_nogd'); - } - - // Entries for the Feed Feature - set_config('feed_enable', '0'); - set_config('feed_limit', '10'); - - set_config('feed_overall_forums', '1'); - set_config('feed_overall_forums_limit', '15'); - - set_config('feed_overall_topics', '0'); - set_config('feed_overall_topics_limit', '15'); - - set_config('feed_forum', '1'); - set_config('feed_topic', '1'); - set_config('feed_item_statistics', '1'); - - // Entries for smiley pagination - set_config('smilies_per_page', '50'); - - // Entry for reporting PMs - set_config('allow_pm_report', '1'); - - // Install modules - $modules_to_install = array( - 'feed' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_FEED_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_BOARD_CONFIGURATION', - 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') - ), - 'warnings' => array( - 'base' => 'users', - 'class' => 'acp', - 'title' => 'ACP_USER_WARNINGS', - 'auth' => 'acl_a_user', - 'display' => 0, - 'cat' => 'ACP_CAT_USERS', - 'after' => array('feedback', 'ACP_USER_FEEDBACK') - ), - 'send_statistics' => array( - 'base' => 'send_statistics', - 'class' => 'acp', - 'title' => 'ACP_SEND_STATISTICS', - 'auth' => 'acl_a_server', - 'cat' => 'ACP_SERVER_CONFIGURATION' - ), - 'setting_forum_copy' => array( - 'base' => 'permissions', - 'class' => 'acp', - 'title' => 'ACP_FORUM_PERMISSIONS_COPY', - 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', - 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', - 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') - ), - 'pm_reports' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_OPEN', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - 'pm_reports_closed' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORTS_CLOSED', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - 'pm_report_details' => array( - 'base' => 'pm_reports', - 'class' => 'mcp', - 'title' => 'MCP_PM_REPORT_DETAILS', - 'auth' => 'aclf_m_report', - 'cat' => 'MCP_REPORTS' - ), - ); - - _add_modules($modules_to_install); - - // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'NEWLY_REGISTERED'"; - $result = $db->sql_query($sql); - $group_id = (int) $db->sql_fetchfield('group_id'); - $db->sql_freeresult($result); - - if (!$group_id) - { - $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; - _sql($sql, $errored, $error_ary); - - $group_id = $db->sql_nextid(); - } - - // Insert new user role... at the end of the chain - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_USER_NEW_MEMBER' - AND role_type = 'u_'"; - $result = $db->sql_query($sql); - $u_role = (int) $db->sql_fetchfield('role_id'); - $db->sql_freeresult($result); - - if (!$u_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'u_'"; - $result = $db->sql_query($sql); - $next_order_id = (int) $db->sql_fetchfield('max_order_id'); - $db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; - _sql($sql, $errored, $error_ary); - $u_role = $db->sql_nextid(); - - if (!$errored) - { - // Now add the correct data to the roles... - // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; - _sql($sql, $errored, $error_ary); - - // Add user role to group - $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; - _sql($sql, $errored, $error_ary); - } - } - - // Insert new forum role - $sql = 'SELECT role_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' - AND role_type = 'f_'"; - $result = $db->sql_query($sql); - $f_role = (int) $db->sql_fetchfield('role_id'); - $db->sql_freeresult($result); - - if (!$f_role) - { - $sql = 'SELECT MAX(role_order) as max_order_id - FROM ' . ACL_ROLES_TABLE . " - WHERE role_type = 'f_'"; - $result = $db->sql_query($sql); - $next_order_id = (int) $db->sql_fetchfield('max_order_id'); - $db->sql_freeresult($result); - - $next_order_id++; - - $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; - _sql($sql, $errored, $error_ary); - $f_role = $db->sql_nextid(); - - if (!$errored) - { - $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; - _sql($sql, $errored, $error_ary); - } - } - - // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) - $sql = 'SELECT 1 - FROM ' . USERS_TABLE . ' - WHERE user_new = 0'; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; - _sql($sql, $errored, $error_ary); - } - - // Newly registered users limit - if (!isset($config['new_member_post_limit'])) - { - set_config('new_member_post_limit', (!empty($config['enable_queue_trigger'])) ? $config['queue_trigger_posts'] : 0); - } - - if (!isset($config['new_member_group_default'])) - { - set_config('new_member_group_default', 0); - } - - // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... - // Check if the role is already assigned... - $sql = 'SELECT forum_id - FROM ' . ACL_GROUPS_TABLE . ' - WHERE group_id = ' . $group_id . ' - AND auth_role_id = ' . $f_role; - $result = $db->sql_query($sql); - $is_options = (int) $db->sql_fetchfield('forum_id'); - $db->sql_freeresult($result); - - // Not assigned at all... :/ - if (!$is_options) - { - // Get postable forums - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . ' - WHERE forum_type != ' . FORUM_LINK; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary); - } - $db->sql_freeresult($result); - } - - // Clear permissions... - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - $auth_admin->acl_clear_prefetch(); - - if (!isset($config['allow_avatar'])) - { - if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) - { - set_config('allow_avatar', '1'); - } - else - { - set_config('allow_avatar', '0'); - } - } - - if (!isset($config['allow_avatar_remote_upload'])) - { - if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) - { - set_config('allow_avatar_remote_upload', '1'); - } - else - { - set_config('allow_avatar_remote_upload', '0'); - } - } - - // Minimum number of characters - if (!isset($config['min_post_chars'])) - { - set_config('min_post_chars', '1'); - } - - if (!isset($config['allow_quick_reply'])) - { - set_config('allow_quick_reply', '1'); - } - - // Set every members user_options column to enable - // bbcode, smilies and URLs for signatures by default - $sql = 'SELECT user_options - FROM ' . USERS_TABLE . ' - WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; - $result = $db->sql_query_limit($sql, 1); - $user_option = (int) $db->sql_fetchfield('user_options'); - $db->sql_freeresult($result); - - // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option - if (!($user_option & 1 << 15)) - { - // 229376 is the added value to enable all three signature options - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; - _sql($sql, $errored, $error_ary); - } - - if (!isset($config['delete_time'])) - { - set_config('delete_time', $config['edit_time']); - } - - $no_updates = false; - break; - - // No changes from 3.0.6-RC1 to 3.0.6-RC2 - case '3.0.6-RC1': - break; - - // Changes from 3.0.6-RC2 to 3.0.6-RC3 - case '3.0.6-RC2': - - // Update the Custom Profile Fields based on previous settings to the new format - $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' - SET field_show_on_vt = 1 - WHERE field_hide = 0 - AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; - _sql($sql, $errored, $error_ary); - $no_updates = false; - - break; - - // No changes from 3.0.6-RC3 to 3.0.6-RC4 - case '3.0.6-RC3': - break; - - // No changes from 3.0.6-RC4 to 3.0.6 - case '3.0.6-RC4': - break; - - // Changes from 3.0.6 to 3.0.7-RC1 - case '3.0.6': - - // ATOM Feeds - set_config('feed_overall', '1'); - set_config('feed_http_auth', '0'); - set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15)); - set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10)); - set_config('feed_topics_new', (!empty($config['feed_overall_topics']) ? '1' : '0')); - set_config('feed_topics_active', (!empty($config['feed_overall_topics']) ? '1' : '0')); - - // Delete all text-templates from the template_data - $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . ' - WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt'); - _sql($sql, $errored, $error_ary); - - $no_updates = false; - break; - - // Changes from 3.0.7-RC1 to 3.0.7-RC2 - case '3.0.7-RC1': - - $sql = 'SELECT user_id, user_email, user_email_hash - FROM ' . USERS_TABLE . ' - WHERE user_type <> ' . USER_IGNORE . " - AND user_email <> ''"; - $result = $db->sql_query($sql); - - $i = 0; - while ($row = $db->sql_fetchrow($result)) - { - // Snapshot of the phpbb_email_hash() function - // We cannot call it directly because the auto updater updates the DB first. :/ - $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']); - - if ($user_email_hash != $row['user_email_hash']) - { - $sql_ary = array( - 'user_email_hash' => $user_email_hash, - ); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE user_id = ' . (int) $row['user_id']; - _sql($sql, $errored, $error_ary, ($i % 100 == 0)); - - ++$i; - } - } - $db->sql_freeresult($result); - - $no_updates = false; - - break; - - // No changes from 3.0.7-RC2 to 3.0.7 - case '3.0.7-RC2': - break; - - // No changes from 3.0.7 to 3.0.7-PL1 - case '3.0.7': - break; - - // Changes from 3.0.7-PL1 to 3.0.8-RC1 - case '3.0.7-PL1': - // Update file extension group names to use language strings. - $sql = 'SELECT lang_dir - FROM ' . LANG_TABLE; - $result = $db->sql_query($sql); - - $extension_groups_updated = array(); - while ($lang_dir = $db->sql_fetchfield('lang_dir')) - { - $lang_dir = basename($lang_dir); - - // The language strings we need are either in language/.../acp/attachments.php - // in the update package if we're updating to 3.0.8-RC1 or later, - // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. - // On an already updated board, they can also already be in language/.../acp/attachments.php - // in the board root. - $lang_files = array( - "{$phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$phpEx", - "{$phpbb_root_path}language/$lang_dir/install.$phpEx", - "{$phpbb_root_path}language/$lang_dir/acp/attachments.$phpEx", - ); - - foreach ($lang_files as $lang_file) - { - if (!file_exists($lang_file)) - { - continue; - } - - $lang = array(); - include($lang_file); - - foreach($lang as $lang_key => $lang_val) - { - if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) - { - continue; - } - - $sql_ary = array( - 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; - _sql($sql, $errored, $error_ary); - - $extension_groups_updated[$lang_key] = true; - } - } - } - $db->sql_freeresult($result); - - // Install modules - $modules_to_install = array( - 'post' => array( - 'base' => 'board', - 'class' => 'acp', - 'title' => 'ACP_POST_SETTINGS', - 'auth' => 'acl_a_board', - 'cat' => 'ACP_MESSAGES', - 'after' => array('message', 'ACP_MESSAGE_SETTINGS') - ), - ); - - _add_modules($modules_to_install); - - // update - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'avatar\''; - _sql($sql, $errored, $error_ary); - - // add Bing Bot - $bot_name = 'Bing [Bot]'; - $bot_name_clean = utf8_clean_string($bot_name); - - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . " - WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; - $result = $db->sql_query($sql); - $bing_already_added = (bool) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); - - if (!$bing_already_added) - { - $bot_agent = 'bingbot/'; - $bot_ip = ''; - $sql = 'SELECT group_id, group_colour - FROM ' . GROUPS_TABLE . " - WHERE group_name = 'BOTS'"; - $result = $db->sql_query($sql); - $group_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$group_row) - { - // default fallback, should never get here - $group_row['group_id'] = 6; - $group_row['group_colour'] = '9E8DA7'; - } - - if (!function_exists('user_add')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $user_row = array( - 'user_type' => USER_IGNORE, - 'group_id' => $group_row['group_id'], - 'username' => $bot_name, - 'user_regdate' => time(), - 'user_password' => '', - 'user_colour' => $group_row['group_colour'], - 'user_email' => '', - 'user_lang' => $config['default_lang'], - 'user_style' => $config['default_style'], - 'user_timezone' => 'UTC', - 'user_dateformat' => $config['default_dateformat'], - 'user_allow_massemail' => 0, - ); - - $user_id = user_add($user_row); - - $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'bot_active' => 1, - 'bot_name' => (string) $bot_name, - 'user_id' => (int) $user_id, - 'bot_agent' => (string) $bot_agent, - 'bot_ip' => (string) $bot_ip, - )); - - _sql($sql, $errored, $error_ary); - } - // end Bing Bot addition - - // Delete shadow topics pointing to not existing topics - $batch_size = 500; - - // Set of affected forums we have to resync - $sync_forum_ids = array(); - - do - { - $sql_array = array( - 'SELECT' => 't1.topic_id, t1.forum_id', - 'FROM' => array( - TOPICS_TABLE => 't1', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(TOPICS_TABLE => 't2'), - 'ON' => 't1.topic_moved_id = t2.topic_id', - ), - ), - 'WHERE' => 't1.topic_moved_id <> 0 - AND t2.topic_id IS NULL', - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query_limit($sql, $batch_size); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = (int) $row['topic_id']; - - $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; - } - $db->sql_freeresult($result); - - if (!empty($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - } - while (sizeof($topic_ids) == $batch_size); - - // Sync the forums we have deleted shadow topics from. - sync('forum', 'forum_id', $sync_forum_ids, true, true); - - // Unread posts search load switch - set_config('load_unreads_search', '1'); - - // Reduce queue interval to 60 seconds, email package size to 20 - if ($config['queue_interval'] == 600) - { - set_config('queue_interval', '60'); - } - - if ($config['email_package_size'] == 50) - { - set_config('email_package_size', '20'); - } - - $no_updates = false; - break; - - // No changes from 3.0.8-RC1 to 3.0.8 - case '3.0.8-RC1': - break; - - // Changes from 3.0.8 to 3.0.9-RC1 - case '3.0.8': - set_config('ip_login_limit_max', '50'); - set_config('ip_login_limit_time', '21600'); - set_config('ip_login_limit_use_forwarded', '0'); - - // Update file extension group names to use language strings, again. - $sql = 'SELECT group_id, group_name - FROM ' . EXTENSION_GROUPS_TABLE . ' - WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char); - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql_ary = array( - 'group_name' => substr($row['group_name'], 10), // Strip off 'EXT_GROUP_' - ); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' - WHERE group_id = ' . $row['group_id']; - _sql($sql, $errored, $error_ary); - } - $db->sql_freeresult($result); - - /* - * Due to a bug, vanilla phpbb could not create captcha tables - * in 3.0.8 on firebird. It was possible for board administrators - * to adjust the code to work. If code was manually adjusted by - * board administrators, index names would not be the same as - * what 3.0.9 and newer expect. This code fragment drops captcha - * tables, destroying all entered Q&A captcha configuration, such - * that when Q&A is configured next the respective tables will be - * created with correct index names. - * - * If you wish to preserve your Q&A captcha configuration, you can - * manually rename indexes to the currently expected name: - * phpbb_captcha_questions_lang_iso => phpbb_captcha_questions_lang - * phpbb_captcha_answers_question_id => phpbb_captcha_answers_qid - * - * Again, this needs to be done only if a board was manually modified - * to fix broken captcha code. - * - if ($db_tools->sql_layer == 'firebird') - { - $changes = array( - 'drop_tables' => array( - $table_prefix . 'captcha_questions', - $table_prefix . 'captcha_answers', - $table_prefix . 'qa_confirm', - ), - ); - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - } - */ - - $no_updates = false; - break; - - // No changes from 3.0.9-RC1 to 3.0.9-RC2 - case '3.0.9-RC1': - break; - - // 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; - - // No changes from 3.0.9-RC4 to 3.0.9 - case '3.0.9-RC4': - break; - - // Changes from 3.0.9 to 3.0.10-RC1 - case '3.0.9': - if (!isset($config['email_max_chunk_size'])) - { - set_config('email_max_chunk_size', '50'); - } - - $no_updates = false; - break; - - // No changes from 3.0.10-RC1 to 3.0.10-RC2 - case '3.0.10-RC1': - break; - - // No changes from 3.0.10-RC2 to 3.0.10-RC3 - case '3.0.10-RC2': - break; - - // No changes from 3.0.10-RC3 to 3.0.10 - case '3.0.10-RC3': - break; - - // Changes from 3.0.10 to 3.0.11-RC1 - case '3.0.10': - // Updates users having current style a deactivated one - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . ' - WHERE style_active = 0'; - $result = $db->sql_query($sql); - - $deactivated_style_ids = array(); - while ($style_id = $db->sql_fetchfield('style_id', false, $result)) - { - $deactivated_style_ids[] = (int) $style_id; - } - $db->sql_freeresult($result); - - if (!empty($deactivated_style_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . (int) $config['default_style'] .' - WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids); - _sql($sql, $errored, $error_ary); - } - - // Delete orphan private messages - $batch_size = 500; - - $sql_array = array( - 'SELECT' => 'p.msg_id', - 'FROM' => array( - PRIVMSGS_TABLE => 'p', - ), - 'LEFT_JOIN' => array( - array( - 'FROM' => array(PRIVMSGS_TO_TABLE => 't'), - 'ON' => 'p.msg_id = t.msg_id', - ), - ), - 'WHERE' => 't.user_id IS NULL', - ); - $sql = $db->sql_build_query('SELECT', $sql_array); - - do - { - $result = $db->sql_query_limit($sql, $batch_size); - - $delete_pms = array(); - while ($row = $db->sql_fetchrow($result)) - { - $delete_pms[] = (int) $row['msg_id']; - } - $db->sql_freeresult($result); - - if (!empty($delete_pms)) - { - $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . ' - WHERE ' . $db->sql_in_set('msg_id', $delete_pms); - _sql($sql, $errored, $error_ary); - } - } - while (sizeof($delete_pms) == $batch_size); - - $no_updates = false; - break; - - // No changes from 3.0.11-RC1 to 3.0.11-RC2 - case '3.0.11-RC1': - break; - - // No changes from 3.0.11-RC2 to 3.0.11 - case '3.0.11-RC2': - break; - - // Changes from 3.0.11 to 3.0.12-RC1 - case '3.0.11': - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_auth = \'acl_u_sig\' - WHERE module_class = \'ucp\' - AND module_basename = \'profile\' - AND module_mode = \'signature\''; - _sql($sql, $errored, $error_ary); - - // Update bots - if (!function_exists('user_delete')) - { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - - $bots_updates = array( - // Bot Deletions - 'NG-Search [Bot]' => false, - 'Nutch/CVS [Bot]' => false, - 'OmniExplorer [Bot]' => false, - 'Seekport [Bot]' => false, - 'Synoo [Bot]' => false, - 'WiseNut [Bot]' => false, - - // Bot Updates - // Bot name to bot user agent map - 'Baidu [Spider]' => 'Baiduspider', - 'Exabot [Bot]' => 'Exabot', - 'Voyager [Bot]' => 'voyager/', - 'W3C [Validator]' => 'W3C_Validator', - ); - - foreach ($bots_updates as $bot_name => $bot_agent) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE user_type = ' . USER_IGNORE . " - AND username_clean = '" . $db->sql_escape(utf8_clean_string($bot_name)) . "'"; - $result = $db->sql_query($sql); - $bot_user_id = (int) $db->sql_fetchfield('user_id'); - $db->sql_freeresult($result); - - if ($bot_user_id) - { - if ($bot_agent === false) - { - $sql = 'DELETE FROM ' . BOTS_TABLE . " - WHERE user_id = $bot_user_id"; - _sql($sql, $errored, $error_ary); - - user_delete('remove', $bot_user_id); - } - else - { - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = '" . $db->sql_escape($bot_agent) . "' - WHERE user_id = $bot_user_id"; - _sql($sql, $errored, $error_ary); - } - } - } - - // Disable receiving pms for bots - $sql = 'SELECT user_id - FROM ' . BOTS_TABLE; - $result = $db->sql_query($sql); - - $bot_user_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $bot_user_ids[] = (int) $row['user_id']; - } - $db->sql_freeresult($result); - - if (!empty($bot_user_ids)) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_allow_pm = 0 - WHERE ' . $db->sql_in_set('user_id', $bot_user_ids); - _sql($sql, $errored, $error_ary); - } - - $no_updates = false; - break; - - // Changes from 3.1.0-dev to 3.1.0-A1 - case '3.1.0-dev': - - // rename all module basenames to full classname - $sql = 'SELECT module_id, module_basename, module_class - FROM ' . MODULES_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $module_id = (int) $row['module_id']; - unset($row['module_id']); - - if (!empty($row['module_basename']) && !empty($row['module_class'])) - { - // all the class names start with class name or with phpbb_ for auto loading - if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && - strpos($row['module_basename'], 'phpbb_') !== 0) - { - $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; - - $sql_update = $db->sql_build_array('UPDATE', $row); - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET ' . $sql_update . ' - WHERE module_id = ' . $module_id; - _sql($sql, $errored, $error_ary); - } - } - } - - $db->sql_freeresult($result); - - if (substr($config['search_type'], 0, 6) !== 'phpbb_') - { - // try to guess the new auto loaded search class name - // works for native and mysql fulltext - set_config('search_type', 'phpbb_search_' . $config['search_type']); - } - - if (!isset($config['fulltext_postgres_ts_name'])) - { - set_config('fulltext_postgres_ts_name', 'simple'); - } - - if (!isset($config['fulltext_postgres_min_word_len'])) - { - set_config('fulltext_postgres_min_word_len', 4); - } - - if (!isset($config['fulltext_postgres_max_word_len'])) - { - set_config('fulltext_postgres_max_word_len', 254); - } - - if (!isset($config['fulltext_sphinx_stopwords'])) - { - set_config('fulltext_sphinx_stopwords', 0); - } - - if (!isset($config['fulltext_sphinx_indexer_mem_limit'])) - { - set_config('fulltext_sphinx_indexer_mem_limit', 512); - } - - if (!isset($config['load_jquery_cdn'])) - { - set_config('load_jquery_cdn', 0); - set_config('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); - } - - if (!isset($config['use_system_cron'])) - { - set_config('use_system_cron', 0); - } - - $sql = 'SELECT group_teampage - FROM ' . GROUPS_TABLE . ' - WHERE group_teampage > 0'; - $result = $db->sql_query_limit($sql, 1); - $added_groups_teampage = (bool) $db->sql_fetchfield('group_teampage'); - $db->sql_freeresult($result); - - if (!$added_groups_teampage) - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 1 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'ADMINISTRATORS'"; - _sql($sql, $errored, $error_ary); - - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 2 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'GLOBAL_MODERATORS'"; - _sql($sql, $errored, $error_ary); - } - - if (!isset($config['legend_sort_groupname'])) - { - set_config('legend_sort_groupname', '0'); - set_config('teampage_forums', '1'); - } - - $sql = 'SELECT group_legend - FROM ' . GROUPS_TABLE . ' - WHERE group_teampage > 1'; - $result = $db->sql_query_limit($sql, 1); - $updated_group_legend = (bool) $db->sql_fetchfield('group_teampage'); - $db->sql_freeresult($result); - - if (!$updated_group_legend) - { - $sql = 'SELECT group_id - FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; - $result = $db->sql_query($sql); - - $next_legend = 1; - while ($row = $db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_legend = ' . $next_legend . ' - WHERE group_id = ' . (int) $row['group_id']; - _sql($sql, $errored, $error_ary); - - $next_legend++; - } - $db->sql_freeresult($result); - unset($next_legend); - } - - // Rename styles module to Customise - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_langname = 'ACP_CAT_CUSTOMISE' - WHERE module_langname = 'ACP_CAT_STYLES'"; - _sql($sql, $errored, $error_ary); - - // Install modules - $modules_to_install = array( - 'position' => array( - 'base' => 'acp_groups', - 'class' => 'acp', - 'title' => 'ACP_GROUPS_POSITION', - 'auth' => 'acl_a_group', - 'cat' => 'ACP_GROUPS', - ), - 'manage' => array( - 'base' => 'acp_attachments', - 'class' => 'acp', - 'title' => 'ACP_MANAGE_ATTACHMENTS', - 'auth' => 'acl_a_attach', - 'cat' => 'ACP_ATTACHMENTS', - ), - 'install' => array( - 'base' => 'acp_styles', - 'class' => 'acp', - 'title' => 'ACP_STYLES_INSTALL', - 'auth' => 'acl_a_styles', - 'cat' => 'ACP_STYLE_MANAGEMENT', - ), - 'cache' => array( - 'base' => 'acp_styles', - 'class' => 'acp', - 'title' => 'ACP_STYLES_CACHE', - 'auth' => 'acl_a_styles', - 'cat' => 'ACP_STYLE_MANAGEMENT', - ), - 'autologin_keys' => array( - 'base' => 'ucp_profile', - 'class' => 'ucp', - 'title' => 'UCP_PROFILE_AUTOLOGIN_KEYS', - 'auth' => '', - 'cat' => 'UCP_PROFILE', - ), - // To add a category, the mode and basename must be empty - // The mode is taken from the array key - '' => array( - 'base' => '', - 'class' => 'acp', - 'title' => 'ACP_EXTENSION_MANAGEMENT', - 'auth' => 'acl_a_extensions', - 'cat' => 'ACP_CAT_CUSTOMISE', - ), - 'extensions' => array( - 'base' => 'acp_extensions', - 'class' => 'acp', - 'title' => 'ACP_EXTENSIONS', - 'auth' => 'acl_a_extensions', - 'cat' => 'ACP_EXTENSION_MANAGEMENT', - ), - ); - - _add_modules($modules_to_install); - - // We need a separate array for the new language sub heading - // because it requires another empty key - $modules_to_install = array( - '' => array( - 'base' => '', - 'class' => 'acp', - 'title' => 'ACP_LANGUAGE', - 'auth' => 'acl_a_language', - 'cat' => 'ACP_CAT_CUSTOMISE', - ), - ); - - _add_modules($modules_to_install); - - // Move language management to new location in the Customise tab - // First get language module id - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'acp_language'"; - $result = $db->sql_query($sql); - $language_module_id = $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - // Next get language management module id of the one just created - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_LANGUAGE'"; - $result = $db->sql_query($sql); - $language_management_module_id = $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - if (!class_exists('acp_modules')) - { - include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); - } - // acp_modules calls adm_back_link, which is undefined at this point - if (!function_exists('adm_back_link')) - { - include($phpbb_root_path . 'includes/functions_acp.' . $phpEx); - } - $module_manager = new acp_modules(); - $module_manager->module_class = 'acp'; - $module_manager->move_module($language_module_id, $language_management_module_id); - - $sql = 'DELETE FROM ' . MODULES_TABLE . " - WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; - _sql($sql, $errored, $error_ary); - - // Localise Global Announcements - $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - AND topic_type = ' . POST_GLOBAL; - $result = $db->sql_query($sql); - - $global_announcements = $update_lastpost_data = array(); - $update_lastpost_data['forum_last_post_time'] = 0; - $update_forum_data = array( - 'forum_posts' => 0, - 'forum_topics' => 0, - 'forum_topics_real' => 0, - ); - - while ($row = $db->sql_fetchrow($result)) - { - $global_announcements[] = (int) $row['topic_id']; - - $update_forum_data['forum_posts'] += (int) $row['topic_posts']; - $update_forum_data['forum_topics_real']++; - if ($row['topic_approved']) - { - $update_forum_data['forum_topics']++; - } - - if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) - { - $update_lastpost_data = array( - 'forum_last_post_id' => (int) $row['topic_last_post_id'], - 'forum_last_post_subject' => $row['topic_last_post_subject'], - 'forum_last_post_time' => (int) $row['topic_last_post_time'], - 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], - 'forum_last_poster_name' => $row['topic_last_poster_name'], - 'forum_last_poster_colour' => $row['topic_last_poster_colour'], - ); - } - } - $db->sql_freeresult($result); - - if (!empty($global_announcements)) - { - // Update the post/topic-count for the forum and the last-post if needed - $ga_forum_id = request_var('ga_forum_id', 0); - - $sql = 'SELECT forum_last_post_time - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $ga_forum_id; - $result = $db->sql_query($sql); - $lastpost = (int) $db->sql_fetchfield('forum_last_post_time'); - $db->sql_freeresult($result); - - $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; - $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; - $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; - if ($lastpost < $update_lastpost_data['forum_last_post_time']) - { - $sql_update .= ', ' . $db->sql_build_array('UPDATE', $update_lastpost_data); - } - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $sql_update . ' - WHERE forum_id = ' . $ga_forum_id; - _sql($sql, $errored, $error_ary); - - // Update some forum_ids - $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $ga_forum_id - WHERE " . $db->sql_in_set('topic_id', $global_announcements); - _sql($sql, $errored, $error_ary); - } - unset($table_ary); - } - - // Allow custom profile fields in pm templates - if (!isset($config['load_cpf_pm'])) - { - set_config('load_cpf_pm', '0'); - } - - if (!isset($config['teampage_memberships'])) - { - set_config('teampage_memberships', '1'); - } - - // Check if styles table was already updated - if ($db_tools->sql_table_exists(STYLES_THEME_TABLE)) - { - // Get list of valid 3.1 styles - $available_styles = array('prosilver'); - - $iterator = new DirectoryIterator($phpbb_root_path . 'styles'); - $skip_dirs = array('.', '..', 'prosilver'); - foreach ($iterator as $fileinfo) - { - if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) - { - $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); - if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) - { - // 3.1 style - $available_styles[] = $fileinfo->getFilename(); - } - } - } - - // Get all installed styles - if ($db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) - { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i - WHERE t.template_id = s.template_id - AND c.theme_id = s.theme_id - AND i.imageset_id = s.imageset_id"; - } - else - { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id - FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c - WHERE t.template_id = s.template_id - AND c.theme_id = s.theme_id"; - } - $result = $db->sql_query($sql); - - $styles = array(); - while ($row = $db->sql_fetchrow($result)) - { - $styles[] = $row; - } - $db->sql_freeresult($result); - - // Decide which styles to keep, all others will be deleted - $valid_styles = array(); - foreach ($styles as $style_row) - { - if ( - // Delete styles with parent style (not supported yet) - $style_row['template_inherits_id'] == 0 && - // Check if components match - $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && - // Check if components are valid - in_array($style_row['template_path'], $available_styles) - ) - { - // Valid style. Keep it - $sql_ary = array( - 'style_path' => $style_row['template_path'], - 'bbcode_bitfield' => $style_row['bbcode_bitfield'], - 'style_parent_id' => 0, - 'style_parent_tree' => '', - ); - _sql('UPDATE ' . STYLES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE style_id = ' . $style_row['style_id'], $errored, $error_ary); - $valid_styles[] = (int) $style_row['style_id']; - } - } - - // Remove old styles tables - $changes = array( - 'drop_columns' => array( - STYLES_TABLE => array( - 'imageset_id', - 'template_id', - 'theme_id', - ), - ), - - 'drop_tables' => array( - STYLES_IMAGESET_TABLE, - STYLES_IMAGESET_DATA_TABLE, - STYLES_TEMPLATE_TABLE, - STYLES_TEMPLATE_DATA_TABLE, - STYLES_THEME_TABLE, - ) - ); - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - - // Remove old entries from styles table - if (!sizeof($valid_styles)) - { - // No valid styles: remove everything and add prosilver - _sql('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); - - $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; - _sql($sql, $errored, $error_ary); - - $sql = 'SELECT style_id - FROM ' . $table . " - WHERE style_name = 'prosilver'"; - $result = _sql($sql, $errored, $error_ary); - $default_style = $db->sql_fetchfield($result); - $db->sql_freeresult($result); - - set_config('default_style', $default_style); - - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; - _sql($sql, $errored, $error_ary); - } - else - { - // There are valid styles in styles table. Remove styles that are outdated - _sql('DELETE FROM ' . STYLES_TABLE . ' WHERE ' . $db->sql_in_set('style_id', $valid_styles, true), $errored, $error_ary); - - // Change default style - if (!in_array($config['default_style'], $valid_styles)) - { - set_config('default_style', $valid_styles[0]); - } - - // Reset styles for users - _sql('UPDATE ' . USERS_TABLE . ' SET user_style = 0 WHERE ' . $db->sql_in_set('user_style', $valid_styles, true), $errored, $error_ary); - } - } - - // Create config value for displaying last subject on forum list - if (!isset($config['display_last_subject'])) - { - $config->set('display_last_subject', '1'); - } - - if (!isset($config['assets_version'])) - { - $config->set('assets_version', '1'); - } - - // If the column exists, we did not yet update the users timezone - if ($db_tools->sql_column_exists(USERS_TABLE, 'user_dst')) - { - // Update user timezones - $sql = 'SELECT user_dst, user_timezone - FROM ' . USERS_TABLE . ' - GROUP BY user_timezone, user_dst'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_timezone = '" . $db->sql_escape($update_helpers->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' - WHERE user_timezone = '" . $db->sql_escape($row['user_timezone']) . "' - AND user_dst = " . (int) $row['user_dst']; - _sql($sql, $errored, $error_ary); - } - $db->sql_freeresult($result); - - // Update board default timezone - set_config('board_timezone', $update_helpers->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst'])); - - // After we have calculated the timezones we can delete user_dst column from user table. - $statements = $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - } - - if (!isset($config['site_home_url'])) - { - $config->set('site_home_url', ''); - $config->set('site_home_text', ''); - } - - // PHPBB3-10601: Make inbox default. Add basename to ucp's pm category - - // Get the category wanted while checking, at the same time, if this has already been applied - $sql = 'SELECT module_id, module_basename - FROM ' . MODULES_TABLE . " - WHERE module_basename <> 'ucp_pm' AND - module_langname='UCP_PM' - "; - $result = $db->sql_query_limit($sql, 1); - - if ($row = $db->sql_fetchrow($result)) - { - // This update is still not applied. Applying it - - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_basename = 'ucp_pm' - WHERE module_id = " . (int) $row['module_id']; - - _sql($sql, $errored, $error_ary); - } - $db->sql_freeresult($result); - - - // Add new permissions - include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); - $auth_admin = new auth_admin(); - - _add_permission($auth_admin, $db, 'u_chgprofileinfo', true, 'u_sig'); - _add_permission($auth_admin, $db, 'a_extensions', true, 'a_styles'); - - // Update the auth setting for the module - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_auth = 'acl_u_chgprofileinfo' - WHERE module_class = 'ucp' - AND module_basename = 'ucp_profile' - AND module_mode = 'profile_info'"; - _sql($sql, $errored, $error_ary); - - $no_updates = false; - - break; - } + garbage_collection(); + exit_handler(); } diff --git a/phpBB/install/database_update_migrations.php b/phpBB/install/database_update_migrations.php deleted file mode 100644 index 52682dc489..0000000000 --- a/phpBB/install/database_update_migrations.php +++ /dev/null @@ -1,139 +0,0 @@ -register(); - -// Set up container -$container_extensions = array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), -); -$container_passes = array( - new phpbb_di_pass_collection_pass(), - //new phpbb_di_pass_kernel_pass(), -); -$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); - -// Compile the container -foreach ($container_passes as $pass) -{ - $phpbb_container->addCompilerPass($pass); -} -$phpbb_container->compile(); - -// set up caching -$cache = $phpbb_container->get('cache'); - -// Instantiate some basic classes -$phpbb_dispatcher = $phpbb_container->get('dispatcher'); -$request = $phpbb_container->get('request'); -$user = $phpbb_container->get('user'); -$auth = $phpbb_container->get('auth'); -$db = $phpbb_container->get('dbal.conn'); - -// make sure request_var uses this request instance -request_var('', 0, false, false, $request); // "dependency injection" for a function - -// Grab global variables, re-cache if necessary -$config = $phpbb_container->get('config'); -set_config(null, null, null, $config); -set_config_count(null, null, null, $config); - -// End startup code - -$db_tools = $phpbb_container->get('dbal.tools'); -if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) -{ - $db_tools->sql_create_table(MIGRATIONS_TABLE, array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); -} - -$migrator = $phpbb_container->get('migrator'); -$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); - -// What is a safe limit of execution time? Half the max execution time should be safe. -$safe_time_limit = (ini_get('max_execution_time') / 2); - -while (!$migrator->finished()) -{ - try - { - $migrator->update(); - } - catch (phpbb_db_migration_exception $e) - { - echo $e; - - garbage_collection(); - exit_handler(); - } - - echo $migrator->last_run_migration['name'] . '
'; - - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing - if ((time() - $update_start_time) >= $safe_time_limit) - { - //echo ''; - echo 'Update not yet completed.
'; - echo 'Continue'; - - garbage_collection(); - exit_handler(); - } -} - -echo 'Finished'; - -garbage_collection(); -exit_handler(); -- cgit v1.2.1 From babdb92aa998728b58eec1e3f2c036b5f2342492 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 17:25:53 -0600 Subject: [feature/migrations] Remove hardcoded language, use lang instead. PHPBB3-9737 --- phpBB/install/database_update.php | 54 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7431c96231..cd43f6065b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -21,26 +21,6 @@ define('IN_INSTALL', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); -if (!function_exists('phpbb_require_updated')) -{ - function phpbb_require_updated($path, $optional = false) - { - global $phpbb_root_path; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - require($new_path); - } - else if (!$optional || file_exists($old_path)) - { - require($old_path); - } - } -} - phpbb_require_updated('includes/startup.' . $phpEx); include($phpbb_root_path . 'config.' . $phpEx); @@ -200,7 +180,7 @@ while (!$migrator->finished()) { echo $e; - end_update($cache); + phpbb_end_update($cache); } echo $migrator->last_run_migration['name'] . '
'; @@ -209,10 +189,10 @@ while (!$migrator->finished()) if ((time() - $update_start_time) >= $safe_time_limit) { //echo ''; - echo 'Update not yet completed.
'; - echo 'Continue'; + echo $lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; + echo '' . $lang['DATABASE_UPDATE_CONTINUE'] . ''; - end_update($cache); + phpbb_end_update($cache); } } @@ -221,11 +201,31 @@ if ($orig_version != $config['version']) add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); } -echo 'Finished'; +echo $lang['DATABASE_UPDATE_COMPLETE']; -end_update($cache); +phpbb_end_update($cache); + +if (!function_exists('phpbb_require_updated')) +{ + function phpbb_require_updated($path, $optional = false) + { + global $phpbb_root_path; + + $new_path = $phpbb_root_path . 'install/update/new/' . $path; + $old_path = $phpbb_root_path . $path; + + if (file_exists($new_path)) + { + require($new_path); + } + else if (!$optional || file_exists($old_path)) + { + require($old_path); + } + } +} -function end_update($cache) +function phpbb_end_update($cache) { $cache->purge(); -- cgit v1.2.1 From 74f4397451dae0ab83d977d97d96ed9549bf3ab9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 22:28:48 -0600 Subject: [feature/migrations] Make depends_on static to call it without dependencies Move installing migrations to migration/install.php and handle figuring out what migrations have been installed based on phpBB version. PHPBB3-11318 --- phpBB/install/database_update.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cd43f6065b..74aa072d22 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -147,21 +147,13 @@ header('Content-type: text/html; charset=UTF-8'); // End startup code +// Make sure migrations have been installed. If not, install migrations and guess what migrations have been installed $db_tools = $phpbb_container->get('dbal.tools'); if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) { - $db_tools->sql_create_table(MIGRATIONS_TABLE, array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); + $migrations_installer = new phpbb_db_migration_install(); + $migrations_installer->install($db, $db_tools, $table_prefix, $config['version']); + unset($migrations_installer); } $migrator = $phpbb_container->get('migrator'); -- cgit v1.2.1 From 8baceacc36f06c2c14d4a4c08cecb3c80b3c76d3 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 22:45:26 -0600 Subject: [feature/migrations] Fix migrations installer, schema for schema_data.sql PHPBB3-11318 --- phpBB/install/database_update.php | 94 +++++++++++++++++------------------ phpBB/install/schemas/schema_data.sql | 43 ++++++++++++++++ 2 files changed, 90 insertions(+), 47 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 74aa072d22..f220a1f684 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -21,6 +21,52 @@ define('IN_INSTALL', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); +if (!function_exists('phpbb_require_updated')) +{ + function phpbb_require_updated($path, $optional = false) + { + global $phpbb_root_path; + + $new_path = $phpbb_root_path . 'install/update/new/' . $path; + $old_path = $phpbb_root_path . $path; + + if (file_exists($new_path)) + { + require($new_path); + } + else if (!$optional || file_exists($old_path)) + { + require($old_path); + } + } +} + +function phpbb_end_update($cache) +{ + $cache->purge(); + +?> +

+
+
+ +
+
+
+ + +
+ + + +get('dbal.tools'); -if (!$db_tools->sql_table_exists(MIGRATIONS_TABLE)) +if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) { $migrations_installer = new phpbb_db_migration_install(); $migrations_installer->install($db, $db_tools, $table_prefix, $config['version']); @@ -196,49 +242,3 @@ if ($orig_version != $config['version']) echo $lang['DATABASE_UPDATE_COMPLETE']; phpbb_end_update($cache); - -if (!function_exists('phpbb_require_updated')) -{ - function phpbb_require_updated($path, $optional = false) - { - global $phpbb_root_path; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - require($new_path); - } - else if (!$optional || file_exists($old_path)) - { - require($old_path); - } - } -} - -function phpbb_end_update($cache) -{ - $cache->purge(); - -?> -

-
-
- -
-
- - - - - - - - Date: Fri, 11 Jan 2013 10:48:46 -0600 Subject: [feature/migrations] Order the migrations schema in schema_data.sql PHPBB3-11318 --- phpBB/install/schemas/schema_data.sql | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index d9e5c46e55..53ff90119e 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -613,14 +613,6 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, # Migrations INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_1_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_9";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc3', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_10";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_12_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1_rc1', 'a:0:{}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_2_rc2";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_1";}', 1, 1, '', 0, 0); @@ -648,12 +640,20 @@ INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_sc INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc1";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc2";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_1_0_dev', 'a:4:{i:0;s:30:"phpbb_db_migration_data_3_0_11";i:1;s:34:"phpbb_db_migration_data_extensions";i:2;s:39:"phpbb_db_migration_data_style_update_p2";i:3;s:35:"phpbb_db_migration_data_timezone_p2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc3";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_9";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc3', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc2";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_10";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc1";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_12_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_extensions', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p2', 'a:1:{i:0;s:39:"phpbb_db_migration_data_style_update_p1";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone_p2', 'a:1:{i:0;s:32:"phpbb_db_migration_data_timezone";}', 1, 1, '', 0, 0); +INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_1_0_dev', 'a:4:{i:0;s:30:"phpbb_db_migration_data_3_0_11";i:1;s:34:"phpbb_db_migration_data_extensions";i:2;s:39:"phpbb_db_migration_data_style_update_p2";i:3;s:35:"phpbb_db_migration_data_timezone_p2";}', 1, 1, '', 0, 0); # -- Demo Topic INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, ''); -- cgit v1.2.1 From 5e69e1a7612a4dbe24620cc5cad33720cb0c2885 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 13 Jan 2013 13:23:02 -0600 Subject: [feature/migrations] effectively installed check for migration data PHPBB3-9737 --- phpBB/install/database_update.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f220a1f684..459839f393 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -193,13 +193,22 @@ header('Content-type: text/html; charset=UTF-8'); // End startup code -// Make sure migrations have been installed. If not, install migrations and guess what migrations have been installed +// Make sure migrations have been installed. $db_tools = $phpbb_container->get('dbal.tools'); if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) { - $migrations_installer = new phpbb_db_migration_install(); - $migrations_installer->install($db, $db_tools, $table_prefix, $config['version']); - unset($migrations_installer); + $db_tools->sql_create_table($table_prefix . 'migrations', array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); } $migrator = $phpbb_container->get('migrator'); -- cgit v1.2.1 From d30a9cb4971f261e33a4814cc94c8fd218afda91 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 13 Jan 2013 13:23:42 -0600 Subject: [feature/migrations] Automatically populate migrations table on install PHPBB3-9737 --- phpBB/install/install_install.php | 7 ++++++ phpBB/install/schemas/schema_data.sql | 44 ----------------------------------- 2 files changed, 7 insertions(+), 44 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 1ab9caee0a..e0eb9e4472 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -114,6 +114,7 @@ class install_install extends module $this->add_bots($mode, $sub); $this->email_admin($mode, $sub); $this->disable_avatars_if_unwritable(); + $this->populate_migrations($phpbb_container, $phpbb_root_path); // Remove the lock file @unlink($phpbb_root_path . 'cache/install_lock'); @@ -1880,6 +1881,12 @@ class install_install extends module } } + function populate_migrations($container, $phpbb_root_path) + { + $migrator = $container->get('migrator'); + $migrator->populate_migrations_from_directory($phpbb_root_path . 'includes/db/migration/data/'); + } + /** * Generate a list of available mail server authentication methods */ diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 53ff90119e..4e4d70ced3 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -611,50 +611,6 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, # NEW MEMBERS on the queue INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0); -# Migrations -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_1_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_1_rc1', 'a:0:{}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_2_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_2_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_2_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_3_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_3_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_4_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_4_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5', 'a:1:{i:0;s:38:"phpbb_db_migration_data_3_0_5_rc1part2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_4";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_5_rc1part2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_5_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc4";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_5";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_6_rc4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_6_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_pl1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_7";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_6";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_7_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_8', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_8_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_8_rc1', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_7_pl1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc4";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_8";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc2', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc3', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_9_rc4', 'a:1:{i:0;s:33:"phpbb_db_migration_data_3_0_9_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc3";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc1', 'a:1:{i:0;s:29:"phpbb_db_migration_data_3_0_9";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_10_rc3', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_10_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc2";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_10";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_11_rc2', 'a:1:{i:0;s:34:"phpbb_db_migration_data_3_0_11_rc1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_0_12_rc1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_extensions', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p1', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_style_update_p2', 'a:1:{i:0;s:39:"phpbb_db_migration_data_style_update_p1";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone', 'a:1:{i:0;s:30:"phpbb_db_migration_data_3_0_11";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_timezone_p2', 'a:1:{i:0;s:32:"phpbb_db_migration_data_timezone";}', 1, 1, '', 0, 0); -INSERT INTO phpbb_migrations (migration_name, migration_depends_on, migration_schema_done, migration_data_done, migration_data_state, migration_start_time, migration_end_time) VALUES('phpbb_db_migration_data_3_1_0_dev', 'a:4:{i:0;s:30:"phpbb_db_migration_data_3_0_11";i:1;s:34:"phpbb_db_migration_data_extensions";i:2;s:39:"phpbb_db_migration_data_style_update_p2";i:3;s:35:"phpbb_db_migration_data_timezone_p2";}', 1, 1, '', 0, 0); - # -- Demo Topic INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, ''); -- cgit v1.2.1 From c31935abda37b1d8f4f7ebbce33012a95e7b4b69 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 23 Feb 2013 15:08:28 -0600 Subject: [feature/migrations] Revert unrelated change to schema_data.sql PHBB3-9737 --- phpBB/install/schemas/schema_data.sql | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/install') diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 4e4d70ced3..7c1a7d40f5 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -611,6 +611,7 @@ INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, # NEW MEMBERS on the queue INSERT INTO phpbb_acl_groups (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (7, 2, 0, 24, 0); + # -- Demo Topic INSERT INTO phpbb_topics (topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_replies_real, forum_id, topic_status, topic_type, topic_first_post_id, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_subject, topic_last_post_time, topic_last_view_time, poll_title) VALUES ('{L_TOPICS_TOPIC_TITLE}', 2, 972086460, 0, 0, 0, 2, 0, 0, 1, 'Admin', 'AA0000', 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, 972086460, ''); -- cgit v1.2.1 From f6a894f07700627b675c2b16aab4714df5819a23 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 23 Feb 2013 16:12:24 -0600 Subject: [feature/migrations] Use the user class for language handling Also localise error messages from the migrator PHBB3-9737 --- phpBB/install/database_update.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 459839f393..4938ef0f87 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -133,9 +133,7 @@ set_config(null, null, null, $config); set_config_count(null, null, null, $config); $orig_version = $config['version']; -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/install.' . $phpEx); +$user->add_lang(array('common', 'acp/common', 'install', 'migrator')); // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) @@ -157,11 +155,11 @@ else header('Content-type: text/html; charset=UTF-8'); ?> - + -<?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> +<?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?> @@ -178,12 +176,12 @@ header('Content-type: text/html; charset=UTF-8');
-

+

lang['UPDATING_TO_LATEST_STABLE']; ?>


-

:: sql_layer; ?>
- ::
+

lang['DATABASE_TYPE']; ?> :: sql_layer; ?>
+ lang['PREVIOUS_VERSION']; ?> ::
finished()) } catch (phpbb_db_migration_exception $e) { - echo $e; + echo $e->getLocalisedMessage($user); phpbb_end_update($cache); } @@ -236,8 +234,8 @@ while (!$migrator->finished()) if ((time() - $update_start_time) >= $safe_time_limit) { //echo ''; - echo $lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; - echo '' . $lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache); } @@ -248,6 +246,6 @@ if ($orig_version != $config['version']) add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); } -echo $lang['DATABASE_UPDATE_COMPLETE']; +echo $user->lang['DATABASE_UPDATE_COMPLETE']; phpbb_end_update($cache); -- cgit v1.2.1 From 7a8ae493009eac3d4f5c97279f0be6e10c588002 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 25 Feb 2013 13:12:32 -0600 Subject: [feature/migrations] Inject migrator rather than the container. Some docblocks PHBB3-9737 --- phpBB/install/install_install.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'phpBB/install') diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index e0eb9e4472..a99de9bec9 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -114,7 +114,7 @@ class install_install extends module $this->add_bots($mode, $sub); $this->email_admin($mode, $sub); $this->disable_avatars_if_unwritable(); - $this->populate_migrations($phpbb_container, $phpbb_root_path); + $this->populate_migrations($phpbb_container->get('migrator'), $phpbb_root_path); // Remove the lock file @unlink($phpbb_root_path . 'cache/install_lock'); @@ -1881,9 +1881,18 @@ class install_install extends module } } - function populate_migrations($container, $phpbb_root_path) + /** + * Populate migrations for the installation + * + * This "installs" all migrations from (root path)/includes/db/migrations/data. + * "installs" means it adds all migrations to the migrations table, but does not + * perform any of the actions in the migrations. + * + * @param phpbb_db_migrator $migrator + * @param string $phpbb_root_path + */ + function populate_migrations($migrator, $phpbb_root_path) { - $migrator = $container->get('migrator'); $migrator->populate_migrations_from_directory($phpbb_root_path . 'includes/db/migration/data/'); } -- cgit v1.2.1