From 12a9e001837da139a9ea07b8dd52019ee071d9bd Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 6 Jan 2008 17:00:09 +0000 Subject: - Do not split topic list for topics being promoted to announcements after been moved to another forum (Bug #18635) - Allow editing usernames within database_update on username cleanup (Bug #18415) - Fixing wrong sync() calls if moving all posts by a member in ACP (Bug #18385) - Check entered imagemagick path for trailing slash (Bug #18205) - Use proper title on index for new/unread posts (Bug #13101) - patch provided by Pyramide - Allow calls to $user->set_cookie() define no cookie time for setting session cookies (Bug #18025) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8310 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fc9ce65dac..990591e8a4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -616,6 +616,9 @@ if (version_compare($current_version, '3.0.RC8', '<=')) $modify_users = request_var('modify_users', array(0 => '')); $new_usernames = request_var('new_usernames', array(0 => ''), true); + // We need this file if someone wants to edit usernames. + include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); + if (!class_exists('utf_new_normalizer')) { if (!file_exists($phpbb_root_path . 'install/data/new_normalizer.' . $phpEx)) -- cgit v1.2.1 From cc24876726854e2e799651b1d7e40e54a2c0375b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 3 Feb 2008 22:55:10 +0000 Subject: merging r8373 into 3.0 branch: adding a new option to hide the entire list of subforums on listforums git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8374 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 990591e8a4..a4d6c46695 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -10,7 +10,7 @@ $updates_to_version = '3.0.0'; -// Return if we "just include it" to find out for which version the database update is responsuble for +// Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) { return; @@ -473,6 +473,15 @@ $database_update_info = 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), + ), + ), + ), ); // Determine mapping database type -- cgit v1.2.1 From d7c5f502b4e0ef87a1d4a8d9a4fc16c79b3a5dc1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 13 Feb 2008 16:28:37 +0000 Subject: Fixing converter bugs. #21215 #18575 #18435 #16565 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8379 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a4d6c46695..899384fb41 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1559,6 +1559,16 @@ if (version_compare($current_version, '3.0.RC5', '<=')) $no_updates = false; } + +if (version_compare($current_version, '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); + + // TODO: remove all form token min times +} _write_result($no_updates, $errored, $error_ary); $error_ary = array(); -- cgit v1.2.1 From 9e55e1738874a0ab352f91a15012b33fe1c3e9f9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 15 Feb 2008 19:10:02 +0000 Subject: revamp how we query permissions. This is half-experimental actually, needs a bit of testing. Should fix the bug with low max_join_size values, but may give problems for those on very low memory settings. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8384 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 899384fb41..7eeca7dbb8 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.0'; +$updates_to_version = '3.0.1-dev'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) -- cgit v1.2.1 From a7ad9b5ae2e145a88d2acb0917162a3973337530 Mon Sep 17 00:00:00 2001 From: Vic D'Elfant Date: Sun, 24 Feb 2008 14:38:35 +0000 Subject: #22035 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8395 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7eeca7dbb8..73e4ad548c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1567,7 +1567,25 @@ if (version_compare($current_version, '3.0.0', '<=')) WHERE topic_last_view_time = 0"; _sql($sql, $errored, $error_ary); + // Update smiley sizes + $smileys = array('icon_e_surprised.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); + } + } + // TODO: remove all form token min times + + $no_updates = false; } _write_result($no_updates, $errored, $error_ary); -- cgit v1.2.1 From dfa5cd59eba5def37cba02437da08fea162a9bcc Mon Sep 17 00:00:00 2001 From: Vic D'Elfant Date: Thu, 28 Feb 2008 07:42:06 +0000 Subject: #22285 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8417 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 73e4ad548c..85627b9327 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1568,7 +1568,7 @@ if (version_compare($current_version, '3.0.0', '<=')) _sql($sql, $errored, $error_ary); // Update smiley sizes - $smileys = array('icon_e_surprised.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'); + $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)) -- cgit v1.2.1 From b7ef95ed091580df66da23fc1bca403758645fc3 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 17 Mar 2008 16:25:07 +0000 Subject: This should get rid of the filesorts and temp tables on index (with topic read tracking as exception). Updater still needs testing. Not yet merged to 3.1 #22715 - thanks HoL git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8436 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 85627b9327..39e0d8131e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -480,6 +480,20 @@ $database_update_info = array( FORUMS_TABLE => array( 'display_subforum_list' => array('BOOL', 1), ), + SESSIONS_TABLE => array( + 'session_forum_id' => array('UINT', 0), + ), + ), + 'add_index' => array( + SESSIONS_TABLE => array( + 'session_forum_id' => 'session_forum_id', + ), + GROUP_TABLE => array( + 'group_legend_name' => array('group_legend', 'group_name'), + ), + ), + 'drop_keys' => array( + GROUP_TABLE => array('group_legend'), ), ), ); -- cgit v1.2.1 From 221001a6dc86c7cd9246b6614adb24c1d88c0067 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 18 Mar 2008 10:14:37 +0000 Subject: - some changes to the recent session change - display errors on inserting sessions - fix database updater git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8438 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 39e0d8131e..856640b58b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -486,14 +486,14 @@ $database_update_info = array( ), 'add_index' => array( SESSIONS_TABLE => array( - 'session_forum_id' => 'session_forum_id', + 'session_forum_id' => array('session_forum_id'), ), - GROUP_TABLE => array( + GROUPS_TABLE => array( 'group_legend_name' => array('group_legend', 'group_name'), ), ), 'drop_keys' => array( - GROUP_TABLE => array('group_legend'), + GROUPS_TABLE => array('group_legend'), ), ), ); -- cgit v1.2.1 From 45673658a10cb8493801b96ceecab3acccda3e5d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 23 Mar 2008 18:40:06 +0000 Subject: up the version number - RC1 is most likely due tomorrow git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8461 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 856640b58b..d87b0fa459 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.1-dev'; +$updates_to_version = '3.0.1-RC1'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) -- cgit v1.2.1 From b2521b83b1a5c35c4c5df9c90515eb3d90cdab4d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 27 Mar 2008 16:17:54 +0000 Subject: some corrections to let the update work flawlessly. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8475 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d87b0fa459..8a38122130 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1625,7 +1625,8 @@ _sql($sql, $errored, $error_ary); // Reset permissions $sql = 'UPDATE ' . USERS_TABLE . " - SET user_permissions = ''"; + SET user_permissions = '', + user_perm_from = 0"; _sql($sql, $errored, $error_ary); /* Optimize/vacuum analyze the tables where appropriate @@ -1659,6 +1660,8 @@ _write_result($no_updates, $errored, $error_ary); if (!$inline_update) { + // Purge the cache... + $cache->purge(); ?>

-- cgit v1.2.1 From daa2afbe3681c5413daa6e6c9c069f90efd0baf9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 31 Mar 2008 14:48:54 +0000 Subject: allow correct updates from *-dev versions something i have seen there, there is an open TODO for the form token (min time) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8483 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 815 ++++++++++++++++++++------------------ 1 file changed, 422 insertions(+), 393 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8a38122130..605470dca4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1082,16 +1082,23 @@ if ($exit) flush(); // We go through the schema changes from the lowest to the highest version -// We skip those versions older than the current version +// We try to also include versions 'in-between'... $no_updates = true; -foreach ($database_update_info as $version => $schema_changes) +$versions = array_keys($database_update_info); +for ($i = 0; $i < sizeof($versions); $i++) { - if (version_compare($version, $current_version, '<')) + $version = $versions[$i]; + $schema_changes = $database_update_info[$version]; + + $next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version; + + if (!sizeof($schema_changes)) { continue; } - if (!sizeof($schema_changes)) + // 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; } @@ -1203,404 +1210,26 @@ flush(); $no_updates = true; -// some code magic -if (version_compare($current_version, '3.0.RC2', '<=')) -{ - $smileys = array(); - $sql = 'SELECT smiley_id, code - FROM ' . SMILIES_TABLE; - - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $smileys[$row['smiley_id']] = $row['code']; - } - $db->sql_freeresult($result); - - foreach ($smileys as $id => $code) - { - // 2.0 only entitized lt and gt; We need to do something about double quotes. - if (strchr($code, '"') === false) - { - continue; - } - - $new_code = str_replace('&', '&', $code); - $new_code = str_replace('<', '<', $new_code); - $new_code = str_replace('>', '>', $new_code); - $new_code = utf8_htmlspecialchars($new_code); - - $sql = 'UPDATE ' . SMILIES_TABLE . ' - SET code = \'' . $db->sql_escape($new_code) . '\' - WHERE smiley_id = ' . (int) $id; - $db->sql_query($sql); - } - - $index_list = sql_list_index($map_dbms, ACL_ROLES_DATA_TABLE); - - if (in_array('ath_opt_id', $index_list)) - { - sql_index_drop($map_dbms, 'ath_opt_id', ACL_ROLES_DATA_TABLE); - sql_create_index($map_dbms, 'ath_op_id', ACL_ROLES_DATA_TABLE, array('auth_option_id')); - } - - $no_updates = false; -} - -if (version_compare($current_version, '3.0.RC3', '<=')) -{ - if ($map_dbms === 'postgres') - { - $sql = "SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));'; - _sql($sql, $errored, $error_ary); - } - - // we check for: - // ath_opt_id - // ath_op_id - // ACL_ROLES_DATA_TABLE_ath_opt_id - // we want ACL_ROLES_DATA_TABLE_ath_op_id - - $table_index_fix = array( - ACL_ROLES_DATA_TABLE => array( - 'ath_opt_id' => 'ath_op_id', - 'ath_op_id' => 'ath_op_id', - ACL_ROLES_DATA_TABLE . '_ath_opt_id' => 'ath_op_id' - ), - STYLES_IMAGESET_DATA_TABLE => array( - 'i_id' => 'i_d', - 'i_d' => 'i_d', - STYLES_IMAGESET_DATA_TABLE . '_i_id' => 'i_d' - ) - ); - - // we need to create some indicies... - $needed_creation = array(); - - foreach ($table_index_fix as $table_name => $index_info) - { - $index_list = sql_list_fake($map_dbms, $table_name); - foreach ($index_info as $bad_index => $good_index) - { - if (in_array($bad_index, $index_list)) - { - // mysql is actually OK, it won't get a hand in this crud - switch ($map_dbms) - { - // last version, mssql had issues with index removal - case 'mssql': - $sql = 'DROP INDEX ' . $table_name . '.' . $bad_index; - _sql($sql, $errored, $error_ary); - break; - - // last version, firebird, oracle, postgresql and sqlite all got bad index names - // we got kinda lucky, tho: they all support the same syntax - case 'firebird': - case 'oracle': - case 'postgres': - case 'sqlite': - $sql = 'DROP INDEX ' . $bad_index; - _sql($sql, $errored, $error_ary); - break; - } - - // If the good index already exist we do not need to create it again... - if (($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41') && $bad_index == $good_index) - { - } - else - { - $needed_creation[$table_name][$good_index] = 1; - } - } - } - } - - $new_index_defs = array('ath_op_id' => array('auth_option_id'), 'i_d' => array('imageset_id')); - - foreach ($needed_creation as $bad_table => $index_repair_list) - { - foreach ($index_repair_list as $new_index => $garbage) - { - sql_create_index($map_dbms, $new_index, $bad_table, $new_index_defs[$new_index]); - $no_updates = false; - } - } - - // Make sure empty smiley codes do not exist - $sql = 'DELETE FROM ' . SMILIES_TABLE . " - WHERE code = ''"; - _sql($sql, $errored, $error_ary); - - set_config('allow_birthdays', '1'); - set_config('cron_lock', '0', true); - - $no_updates = false; -} +$versions = array( + '3.0.RC2', '3.0.RC3', '3.0.RC4', '3.0.RC5', '3.0.0' +); -if (version_compare($current_version, '3.0.RC4', '<=')) +// some code magic +for ($i = 0; $i < sizeof($versions); $i++) { - $update_auto_increment = array( - STYLES_TABLE => 'style_id', - STYLES_TEMPLATE_TABLE => 'template_id', - STYLES_THEME_TABLE => 'theme_id', - STYLES_IMAGESET_TABLE => 'imageset_id' - ); - - $sql = 'SELECT * - FROM ' . STYLES_TABLE . ' - WHERE style_id = 0'; - $result = _sql($sql, $errored, $error_ary); - $bad_style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $version = $versions[$i]; + $next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version; - if ($bad_style_row) + // 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, '>=')) { - $sql = 'SELECT MAX(style_id) as max_id - FROM ' . STYLES_TABLE; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $proper_id = $row['max_id'] + 1; - - _sql('UPDATE ' . STYLES_TABLE . " SET style_id = $proper_id WHERE style_id = 0", $errored, $error_ary); - _sql('UPDATE ' . FORUMS_TABLE . " SET forum_style = $proper_id WHERE forum_style = 0", $errored, $error_ary); - _sql('UPDATE ' . USERS_TABLE . " SET user_style = $proper_id WHERE user_style = 0", $errored, $error_ary); - - $sql = 'SELECT config_value - FROM ' . CONFIG_TABLE . " - WHERE config_name = 'default_style'"; - $result = _sql($sql, $errored, $error_ary); - $style_config = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($style_config['config_value'] === '0') - { - set_config('default_style', (string) $proper_id); - } - } - - $sql = 'SELECT * - FROM ' . STYLES_TEMPLATE_TABLE . ' - WHERE template_id = 0'; - $result = _sql($sql, $errored, $error_ary); - $bad_style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($bad_style_row) - { - $sql = 'SELECT MAX(template_id) as max_id - FROM ' . STYLES_TEMPLATE_TABLE; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $proper_id = $row['max_id'] + 1; - - _sql('UPDATE ' . STYLES_TABLE . " SET template_id = $proper_id WHERE template_id = 0", $errored, $error_ary); - } - - $sql = 'SELECT * - FROM ' . STYLES_THEME_TABLE . ' - WHERE theme_id = 0'; - $result = _sql($sql, $errored, $error_ary); - $bad_style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($bad_style_row) - { - $sql = 'SELECT MAX(theme_id) as max_id - FROM ' . STYLES_THEME_TABLE; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $proper_id = $row['max_id'] + 1; - - _sql('UPDATE ' . STYLES_TABLE . " SET theme_id = $proper_id WHERE theme_id = 0", $errored, $error_ary); - } - - $sql = 'SELECT * - FROM ' . STYLES_IMAGESET_TABLE . ' - WHERE imageset_id = 0'; - $result = _sql($sql, $errored, $error_ary); - $bad_style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($bad_style_row) - { - $sql = 'SELECT MAX(imageset_id) as max_id - FROM ' . STYLES_IMAGESET_TABLE; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $proper_id = $row['max_id'] + 1; - - _sql('UPDATE ' . STYLES_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary); - _sql('UPDATE ' . STYLES_IMAGESET_DATA_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary); - } - - if ($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41') - { - foreach ($update_auto_increment as $auto_table_name => $auto_column_name) - { - $sql = "SELECT MAX({$auto_column_name}) as max_id - FROM {$auto_table_name}"; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $max_id = ((int) $row['max_id']) + 1; - _sql("ALTER TABLE {$auto_table_name} AUTO_INCREMENT = {$max_id}", $errored, $error_ary); - } - - $no_updates = false; - } - else if ($map_dbms == 'postgres') - { - foreach ($update_auto_increment as $auto_table_name => $auto_column_name) - { - $sql = "SELECT SETVAL('" . $auto_table_name . "_seq',(select case when max({$auto_column_name})>0 then max({$auto_column_name})+1 else 1 end from " . $auto_table_name . '));'; - _sql($sql, $errored, $error_ary); - } - - $sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq'; - _sql($sql, $errored, $error_ary); - } - else if ($map_dbms == 'firebird') - { - $sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE; - _sql($sql, $errored, $error_ary); - - $sql = 'DROP GENERATOR ' . STYLES_TEMPLATE_DATA_TABLE . '_gen'; - _sql($sql, $errored, $error_ary); - } - else if ($map_dbms == 'oracle') - { - $sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE; - _sql($sql, $errored, $error_ary); - - $sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq'; - _sql($sql, $errored, $error_ary); - } - else if ($map_dbms == 'mssql') - { - // we use transactions because we need to have a working DB at the end of all of this - $db->sql_transaction('begin'); - - $sql = 'SELECT * - FROM ' . STYLES_TEMPLATE_DATA_TABLE; - $result = _sql($sql, $errored, $error_ary); - $old_style_rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $old_style_rows[] = $row; - } - $db->sql_freeresult($result); - - // death to the table, it is evil! - $sql = 'DROP TABLE ' . STYLES_TEMPLATE_DATA_TABLE; - _sql($sql, $errored, $error_ary); - - // the table of awesomeness, praise be to it (or something) - $sql = 'CREATE TABLE [' . STYLES_TEMPLATE_DATA_TABLE . "] ( - [template_id] [int] DEFAULT (0) NOT NULL , - [template_filename] [varchar] (100) DEFAULT ('') NOT NULL , - [template_included] [varchar] (8000) DEFAULT ('') NOT NULL , - [template_mtime] [int] DEFAULT (0) NOT NULL , - [template_data] [text] DEFAULT ('') NOT NULL - ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]"; - _sql($sql, $errored, $error_ary); - - // index? index - $sql = 'CREATE INDEX [tid] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_id]) ON [PRIMARY]'; - _sql($sql, $errored, $error_ary); - - // yet another index - $sql = 'CREATE INDEX [tfn] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_filename]) ON [PRIMARY]'; - _sql($sql, $errored, $error_ary); - - foreach ($old_style_rows as $return_row) - { - _sql('INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $return_row), $errored, $error_ary); - } - - $db->sql_transaction('commit'); + continue; } - // Setting this here again because new installations may not have it... - set_config('cron_lock', '0', true); - set_config('ldap_port', ''); - set_config('ldap_user_filter', ''); - $no_updates = false; + change_database_data($version); } -if (version_compare($current_version, '3.0.RC5', '<=')) -{ - // In case the user is having the bot mediapartner google "as is", adjust it. - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = '" . $db->sql_escape('Mediapartners-Google') . "' - WHERE bot_agent = '" . $db->sql_escape('Mediapartners-Google/') . "'"; - _sql($sql, $errored, $error_ary); - - set_config('form_token_lifetime', '7200'); - set_config('form_token_mintime', '0'); - set_config('min_time_reg', '5'); - set_config('min_time_terms', '2'); - set_config('form_token_sid_guests', '1'); - - $db->sql_transaction('begin'); - - $sql = 'SELECT forum_id, forum_password - FROM ' . FORUMS_TABLE; - $result = _sql($sql, $errored, $error_ary); - - while ($row = $db->sql_fetchrow($result)) - { - if (!empty($row['forum_password'])) - { - _sql('UPDATE ' . FORUMS_TABLE . " SET forum_password = '" . md5($row['forum_password']) . "' WHERE forum_id = {$row['forum_id']}", $errored, $error_ary); - } - } - $db->sql_freeresult($result); - - $db->sql_transaction('commit'); - - $no_updates = false; -} - - -if (version_compare($current_version, '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); - } - } - - // TODO: remove all form token min times - - $no_updates = false; -} _write_result($no_updates, $errored, $error_ary); $error_ary = array(); @@ -1713,6 +1342,406 @@ if (function_exists('exit_handler')) exit_handler(); } +/** +* Function where all data changes are executed +*/ +function change_database_data($version) +{ + global $db, $map_dbms, $errored, $error_ary, $config, $phpbb_root_path; + + switch ($version) + { + case '3.0.RC2': + + $smileys = array(); + + $sql = 'SELECT smiley_id, code + FROM ' . SMILIES_TABLE; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $smileys[$row['smiley_id']] = $row['code']; + } + $db->sql_freeresult($result); + + foreach ($smileys as $id => $code) + { + // 2.0 only entitized lt and gt; We need to do something about double quotes. + if (strchr($code, '"') === false) + { + continue; + } + + $new_code = str_replace('&', '&', $code); + $new_code = str_replace('<', '<', $new_code); + $new_code = str_replace('>', '>', $new_code); + $new_code = utf8_htmlspecialchars($new_code); + + $sql = 'UPDATE ' . SMILIES_TABLE . ' + SET code = \'' . $db->sql_escape($new_code) . '\' + WHERE smiley_id = ' . (int) $id; + $db->sql_query($sql); + } + + $index_list = sql_list_index($map_dbms, ACL_ROLES_DATA_TABLE); + + if (in_array('ath_opt_id', $index_list)) + { + sql_index_drop($map_dbms, 'ath_opt_id', ACL_ROLES_DATA_TABLE); + sql_create_index($map_dbms, 'ath_op_id', ACL_ROLES_DATA_TABLE, array('auth_option_id')); + } + + break; + + case '3.0.RC3': + + if ($map_dbms === 'postgres') + { + $sql = "SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));'; + _sql($sql, $errored, $error_ary); + } + + // we check for: + // ath_opt_id + // ath_op_id + // ACL_ROLES_DATA_TABLE_ath_opt_id + // we want ACL_ROLES_DATA_TABLE_ath_op_id + + $table_index_fix = array( + ACL_ROLES_DATA_TABLE => array( + 'ath_opt_id' => 'ath_op_id', + 'ath_op_id' => 'ath_op_id', + ACL_ROLES_DATA_TABLE . '_ath_opt_id' => 'ath_op_id' + ), + STYLES_IMAGESET_DATA_TABLE => array( + 'i_id' => 'i_d', + 'i_d' => 'i_d', + STYLES_IMAGESET_DATA_TABLE . '_i_id' => 'i_d' + ) + ); + + // we need to create some indicies... + $needed_creation = array(); + + foreach ($table_index_fix as $table_name => $index_info) + { + $index_list = sql_list_fake($map_dbms, $table_name); + foreach ($index_info as $bad_index => $good_index) + { + if (in_array($bad_index, $index_list)) + { + // mysql is actually OK, it won't get a hand in this crud + switch ($map_dbms) + { + // last version, mssql had issues with index removal + case 'mssql': + $sql = 'DROP INDEX ' . $table_name . '.' . $bad_index; + _sql($sql, $errored, $error_ary); + break; + + // last version, firebird, oracle, postgresql and sqlite all got bad index names + // we got kinda lucky, tho: they all support the same syntax + case 'firebird': + case 'oracle': + case 'postgres': + case 'sqlite': + $sql = 'DROP INDEX ' . $bad_index; + _sql($sql, $errored, $error_ary); + break; + } + + // If the good index already exist we do not need to create it again... + if (($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41') && $bad_index == $good_index) + { + } + else + { + $needed_creation[$table_name][$good_index] = 1; + } + } + } + } + + $new_index_defs = array('ath_op_id' => array('auth_option_id'), 'i_d' => array('imageset_id')); + + foreach ($needed_creation as $bad_table => $index_repair_list) + { + foreach ($index_repair_list as $new_index => $garbage) + { + sql_create_index($map_dbms, $new_index, $bad_table, $new_index_defs[$new_index]); + } + } + + // Make sure empty smiley codes do not exist + $sql = 'DELETE FROM ' . SMILIES_TABLE . " + WHERE code = ''"; + _sql($sql, $errored, $error_ary); + + set_config('allow_birthdays', '1'); + set_config('cron_lock', '0', true); + + break; + + case '3.0.RC4': + + $update_auto_increment = array( + STYLES_TABLE => 'style_id', + STYLES_TEMPLATE_TABLE => 'template_id', + STYLES_THEME_TABLE => 'theme_id', + STYLES_IMAGESET_TABLE => 'imageset_id' + ); + + $sql = 'SELECT * + FROM ' . STYLES_TABLE . ' + WHERE style_id = 0'; + $result = _sql($sql, $errored, $error_ary); + $bad_style_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($bad_style_row) + { + $sql = 'SELECT MAX(style_id) as max_id + FROM ' . STYLES_TABLE; + $result = _sql($sql, $errored, $error_ary); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $proper_id = $row['max_id'] + 1; + + _sql('UPDATE ' . STYLES_TABLE . " SET style_id = $proper_id WHERE style_id = 0", $errored, $error_ary); + _sql('UPDATE ' . FORUMS_TABLE . " SET forum_style = $proper_id WHERE forum_style = 0", $errored, $error_ary); + _sql('UPDATE ' . USERS_TABLE . " SET user_style = $proper_id WHERE user_style = 0", $errored, $error_ary); + + $sql = 'SELECT config_value + FROM ' . CONFIG_TABLE . " + WHERE config_name = 'default_style'"; + $result = _sql($sql, $errored, $error_ary); + $style_config = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($style_config['config_value'] === '0') + { + set_config('default_style', (string) $proper_id); + } + } + + $sql = 'SELECT * + FROM ' . STYLES_TEMPLATE_TABLE . ' + WHERE template_id = 0'; + $result = _sql($sql, $errored, $error_ary); + $bad_style_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($bad_style_row) + { + $sql = 'SELECT MAX(template_id) as max_id + FROM ' . STYLES_TEMPLATE_TABLE; + $result = _sql($sql, $errored, $error_ary); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $proper_id = $row['max_id'] + 1; + + _sql('UPDATE ' . STYLES_TABLE . " SET template_id = $proper_id WHERE template_id = 0", $errored, $error_ary); + } + + $sql = 'SELECT * + FROM ' . STYLES_THEME_TABLE . ' + WHERE theme_id = 0'; + $result = _sql($sql, $errored, $error_ary); + $bad_style_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($bad_style_row) + { + $sql = 'SELECT MAX(theme_id) as max_id + FROM ' . STYLES_THEME_TABLE; + $result = _sql($sql, $errored, $error_ary); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $proper_id = $row['max_id'] + 1; + + _sql('UPDATE ' . STYLES_TABLE . " SET theme_id = $proper_id WHERE theme_id = 0", $errored, $error_ary); + } + + $sql = 'SELECT * + FROM ' . STYLES_IMAGESET_TABLE . ' + WHERE imageset_id = 0'; + $result = _sql($sql, $errored, $error_ary); + $bad_style_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($bad_style_row) + { + $sql = 'SELECT MAX(imageset_id) as max_id + FROM ' . STYLES_IMAGESET_TABLE; + $result = _sql($sql, $errored, $error_ary); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $proper_id = $row['max_id'] + 1; + + _sql('UPDATE ' . STYLES_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary); + _sql('UPDATE ' . STYLES_IMAGESET_DATA_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary); + } + + if ($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41') + { + foreach ($update_auto_increment as $auto_table_name => $auto_column_name) + { + $sql = "SELECT MAX({$auto_column_name}) as max_id + FROM {$auto_table_name}"; + $result = _sql($sql, $errored, $error_ary); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $max_id = ((int) $row['max_id']) + 1; + _sql("ALTER TABLE {$auto_table_name} AUTO_INCREMENT = {$max_id}", $errored, $error_ary); + } + } + else if ($map_dbms == 'postgres') + { + foreach ($update_auto_increment as $auto_table_name => $auto_column_name) + { + $sql = "SELECT SETVAL('" . $auto_table_name . "_seq',(select case when max({$auto_column_name})>0 then max({$auto_column_name})+1 else 1 end from " . $auto_table_name . '));'; + _sql($sql, $errored, $error_ary); + } + + $sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq'; + _sql($sql, $errored, $error_ary); + } + else if ($map_dbms == 'firebird') + { + $sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE; + _sql($sql, $errored, $error_ary); + + $sql = 'DROP GENERATOR ' . STYLES_TEMPLATE_DATA_TABLE . '_gen'; + _sql($sql, $errored, $error_ary); + } + else if ($map_dbms == 'oracle') + { + $sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE; + _sql($sql, $errored, $error_ary); + + $sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq'; + _sql($sql, $errored, $error_ary); + } + else if ($map_dbms == 'mssql') + { + // we use transactions because we need to have a working DB at the end of all of this + $db->sql_transaction('begin'); + + $sql = 'SELECT * + FROM ' . STYLES_TEMPLATE_DATA_TABLE; + $result = _sql($sql, $errored, $error_ary); + $old_style_rows = array(); + while ($row = $db->sql_fetchrow($result)) + { + $old_style_rows[] = $row; + } + $db->sql_freeresult($result); + + // death to the table, it is evil! + $sql = 'DROP TABLE ' . STYLES_TEMPLATE_DATA_TABLE; + _sql($sql, $errored, $error_ary); + + // the table of awesomeness, praise be to it (or something) + $sql = 'CREATE TABLE [' . STYLES_TEMPLATE_DATA_TABLE . "] ( + [template_id] [int] DEFAULT (0) NOT NULL , + [template_filename] [varchar] (100) DEFAULT ('') NOT NULL , + [template_included] [varchar] (8000) DEFAULT ('') NOT NULL , + [template_mtime] [int] DEFAULT (0) NOT NULL , + [template_data] [text] DEFAULT ('') NOT NULL + ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]"; + _sql($sql, $errored, $error_ary); + + // index? index + $sql = 'CREATE INDEX [tid] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_id]) ON [PRIMARY]'; + _sql($sql, $errored, $error_ary); + + // yet another index + $sql = 'CREATE INDEX [tfn] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_filename]) ON [PRIMARY]'; + _sql($sql, $errored, $error_ary); + + foreach ($old_style_rows as $return_row) + { + _sql('INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $return_row), $errored, $error_ary); + } + + $db->sql_transaction('commit'); + } + + // Setting this here again because new installations may not have it... + set_config('cron_lock', '0', true); + set_config('ldap_port', ''); + set_config('ldap_user_filter', ''); + + break; + + case '3.0.RC5': + + // In case the user is having the bot mediapartner google "as is", adjust it. + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = '" . $db->sql_escape('Mediapartners-Google') . "' + WHERE bot_agent = '" . $db->sql_escape('Mediapartners-Google/') . "'"; + _sql($sql, $errored, $error_ary); + + set_config('form_token_lifetime', '7200'); + set_config('form_token_mintime', '0'); + set_config('min_time_reg', '5'); + set_config('min_time_terms', '2'); + set_config('form_token_sid_guests', '1'); + + $db->sql_transaction('begin'); + + $sql = 'SELECT forum_id, forum_password + FROM ' . FORUMS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + if (!empty($row['forum_password'])) + { + _sql('UPDATE ' . FORUMS_TABLE . " SET forum_password = '" . md5($row['forum_password']) . "' WHERE forum_id = {$row['forum_id']}", $errored, $error_ary); + } + } + $db->sql_freeresult($result); + + $db->sql_transaction('commit'); + + break; + + 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); + } + } + + // TODO: remove all form token min times + + break; + } +} /** * Function for triggering an sql statement -- cgit v1.2.1 From c508c3e44e139a24af8e4b0dbc291fa467bfd757 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 7 Apr 2008 13:08:42 +0000 Subject: version update git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8492 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 605470dca4..211bbec8d1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.1-RC1'; +$updates_to_version = '3.0.1'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) -- cgit v1.2.1 From 9413af5e1a59a9bfc01fb5d3896a2fb5d34055f4 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 15 May 2008 13:29:14 +0000 Subject: So, tighten things up a little further. QA Team, please check this. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8554 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 211bbec8d1..bead1cad93 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1740,6 +1740,10 @@ function change_database_data($version) // TODO: remove all form token min times break; + + case '3.0.1': + + set_config('referer_validation', '1'); } } -- cgit v1.2.1 From fc12c0021961f369090a3ea9fdcd62ef4d51505e Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 15 May 2008 14:10:11 +0000 Subject: And more new features for reasonable paranoia. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8555 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index bead1cad93..94ccf75ecd 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1736,14 +1736,15 @@ function change_database_data($version) _sql($sql, $errored, $error_ary); } } - - // TODO: remove all form token min times break; - - case '3.0.1': + 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'); + } } -- cgit v1.2.1 From 459db0eb1bb72dbe258a56edec851d8664886d7f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 3 Jun 2008 14:50:41 +0000 Subject: some changes to database_update to circumvent doubled updates for RC's git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8582 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 94ccf75ecd..e79a69d173 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.1'; +$updates_to_version = '3.0.1'; //'3.0.2-RC1'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -33,7 +33,7 @@ error_reporting(E_ALL); // Include essential scripts include($phpbb_root_path . 'config.' . $phpEx); -if (!isset($dbms)) +if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) { die("Please read: INSTALL.html before attempting to update."); } @@ -496,6 +496,10 @@ $database_update_info = array( GROUPS_TABLE => array('group_legend'), ), ), + // No changes from 3.0.0 to 3.0.1-RC1 + '3.0.1-RC1' => array(), + // No changes from 3.0.1-RC1 to 3.0.1 + '3.0.1' => array(), ); // Determine mapping database type @@ -932,7 +936,7 @@ if (version_compare($current_version, '3.0.RC8', '<=')) foreach ($user_ids as $i => $user_id) { $row = $users[$user_id]; - + $rank_title = $rank_img = ''; get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src); @@ -1211,7 +1215,7 @@ flush(); $no_updates = true; $versions = array( - '3.0.RC2', '3.0.RC3', '3.0.RC4', '3.0.RC5', '3.0.0' + '3.0.RC2', '3.0.RC3', '3.0.RC4', '3.0.RC5', '3.0.0', '3.0.1-RC1' ); // some code magic @@ -1324,7 +1328,7 @@ $cache->purge(); - + @@ -1364,7 +1368,7 @@ function change_database_data($version) $smileys[$row['smiley_id']] = $row['code']; } $db->sql_freeresult($result); - + foreach ($smileys as $id => $code) { // 2.0 only entitized lt and gt; We need to do something about double quotes. @@ -1699,7 +1703,7 @@ function change_database_data($version) $sql = 'SELECT forum_id, forum_password FROM ' . FORUMS_TABLE; $result = _sql($sql, $errored, $error_ary); - + while ($row = $db->sql_fetchrow($result)) { if (!empty($row['forum_password'])) @@ -1708,7 +1712,7 @@ function change_database_data($version) } } $db->sql_freeresult($result); - + $db->sql_transaction('commit'); break; @@ -1719,7 +1723,7 @@ function change_database_data($version) 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'); @@ -1728,23 +1732,25 @@ function change_database_data($version) 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); } } break; - case '3.0.1': - + case '3.0.1-RC1': + 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'); + break; + } } -- cgit v1.2.1 From d48af67b0e48b8450ad1c78f0f63e74f6023faf8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 11 Jun 2008 16:52:11 +0000 Subject: - some version changes - apply database updates sequentially git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8648 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 56 +++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 14 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e79a69d173..43d8c06a27 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.1'; //'3.0.2-RC1'; +$updates_to_version = '3.0.2-RC1'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -496,10 +496,12 @@ $database_update_info = array( GROUPS_TABLE => array('group_legend'), ), ), - // No changes from 3.0.0 to 3.0.1-RC1 - '3.0.1-RC1' => array(), // 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(), +// uncomment once RC1 out - no changes from 3.0.2-RC1 to 3.0.2 +// '3.0.2-RC1' => array(), ); // Determine mapping database type @@ -585,6 +587,11 @@ while ($row = $db->sql_fetchrow($result)) } $db->sql_freeresult($result); +/*if ($debug_from_version !== false) +{ + $config['version'] = $debug_from_version; +}*/ + echo $lang['PREVIOUS_VERSION'] . ' :: ' . $config['version'] . '
'; echo $lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . '

'; @@ -608,7 +615,7 @@ else // Checks/Operations that have to be completed prior to starting the update itself $exit = false; -if (version_compare($current_version, '3.0.RC8', '<=')) +if (version_compare($current_version, '3.0.RC8', '<=')) /* && $debug_from_version === false) */ { // Define missing language entries... if (!isset($lang['CLEANING_USERNAMES'])) @@ -1096,13 +1103,20 @@ for ($i = 0; $i < sizeof($versions); $i++) $next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version; - if (!sizeof($schema_changes)) + // 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; } - // 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, '>=')) +/* if ($debug_from_version !== false) + { + // Applying update schema for version array with key '$version' + // for version '$version' to '$next_version' + continue; + }*/ + + if (!sizeof($schema_changes)) { continue; } @@ -1213,10 +1227,7 @@ $errored = $no_updates = false; flush(); $no_updates = true; - -$versions = array( - '3.0.RC2', '3.0.RC3', '3.0.RC4', '3.0.RC5', '3.0.0', '3.0.1-RC1' -); +$versions = array_keys($database_update_info); // some code magic for ($i = 0; $i < sizeof($versions); $i++) @@ -1230,8 +1241,14 @@ for ($i = 0; $i < sizeof($versions); $i++) continue; } - $no_updates = false; - change_database_data($version); +/* if ($debug_from_version !== false) + { + // Applying update schema for version array with key '$version' + // for version '$version' to '$next_version' + continue; + }*/ + + change_database_data($no_updates, $version); } _write_result($no_updates, $errored, $error_ary); @@ -1250,6 +1267,9 @@ $errored = $no_updates = false; flush(); +//if ($debug_from_version === false) +// { + // update the version $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '$updates_to_version' @@ -1262,6 +1282,8 @@ $sql = 'UPDATE ' . USERS_TABLE . " user_perm_from = 0"; _sql($sql, $errored, $error_ary); +// } + /* Optimize/vacuum analyze the tables where appropriate // this should be done for each version in future along with // the version number update @@ -1349,7 +1371,7 @@ if (function_exists('exit_handler')) /** * Function where all data changes are executed */ -function change_database_data($version) +function change_database_data(&$no_updates, $version) { global $db, $map_dbms, $errored, $error_ary, $config, $phpbb_root_path; @@ -1396,6 +1418,7 @@ function change_database_data($version) sql_create_index($map_dbms, 'ath_op_id', ACL_ROLES_DATA_TABLE, array('auth_option_id')); } + $no_updates = false; break; case '3.0.RC3': @@ -1485,6 +1508,7 @@ function change_database_data($version) set_config('allow_birthdays', '1'); set_config('cron_lock', '0', true); + $no_updates = false; break; case '3.0.RC4': @@ -1682,6 +1706,7 @@ function change_database_data($version) set_config('ldap_port', ''); set_config('ldap_user_filter', ''); + $no_updates = false; break; case '3.0.RC5': @@ -1715,6 +1740,7 @@ function change_database_data($version) $db->sql_transaction('commit'); + $no_updates = false; break; case '3.0.0': @@ -1741,6 +1767,7 @@ function change_database_data($version) } } + $no_updates = false; break; case '3.0.1-RC1': @@ -1749,6 +1776,7 @@ function change_database_data($version) 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; } -- cgit v1.2.1 From 008cccbefc574108d0d550ba10b740c188a86f4f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 21 Jun 2008 14:30:56 +0000 Subject: fix 3.0.1 to 3.0.2-RC1 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8662 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 43d8c06a27..184331976b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1770,7 +1770,12 @@ function change_database_data(&$no_updates, $version) $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'); @@ -1779,6 +1784,9 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + // uncomment once RC1 out - no changes from 3.0.2-RC1 to 3.0.2 +// case '3.0.2-RC1': +// break; } } -- cgit v1.2.1 From b8647dc952b8992e3a09d31f27a5f3834fb4e8b5 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 21 Jun 2008 16:04:13 +0000 Subject: change subject/title column length git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8666 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 43 ++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 184331976b..0805a2b273 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.2-RC1'; +$updates_to_version = '3.0.2-RC2'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -500,8 +500,37 @@ $database_update_info = array( '3.0.1-RC1' => array(), // No changes from 3.0.1 to 3.0.2-RC1 '3.0.1' => array(), -// uncomment once RC1 out - no changes from 3.0.2-RC1 to 3.0.2 -// '3.0.2-RC1' => 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'), + ), + ), + ), + // uncomment once RC2 out - no changes from 3.0.2-RC2 to 3.0.2 +// '3.0.2-RC2' => array(), ); // Determine mapping database type @@ -1784,8 +1813,12 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; - // uncomment once RC1 out - no changes from 3.0.2-RC1 to 3.0.2 -// case '3.0.2-RC1': + // No changes from 3.0.2-RC1 to 3.0.2-RC2 + case '3.0.2-RC1': + break; + + // uncomment once RC2 out - no changes from 3.0.2-RC2 to 3.0.2 +// case '3.0.2-RC2': // break; } } -- cgit v1.2.1 From 04814560c89eac2a0aaf83277b8fd4511e7adcf7 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 6 Jul 2008 16:35:41 +0000 Subject: up the version number git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8678 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0805a2b273..fb287299e5 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.2-RC2'; +$updates_to_version = '3.0.2'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -529,8 +529,8 @@ $database_update_info = array( ), ), ), - // uncomment once RC2 out - no changes from 3.0.2-RC2 to 3.0.2 -// '3.0.2-RC2' => array(), + // No changes from 3.0.2-RC2 to 3.0.2 + '3.0.2-RC2' => array(), ); // Determine mapping database type @@ -1817,9 +1817,9 @@ function change_database_data(&$no_updates, $version) case '3.0.2-RC1': break; - // uncomment once RC2 out - no changes from 3.0.2-RC2 to 3.0.2 -// case '3.0.2-RC2': -// break; + // No changes from 3.0.2-RC2 to 3.0.2 + case '3.0.2-RC2': + break; } } -- cgit v1.2.1 From eda1d40861fb5a2b74e7e5ade618cc9fa83cafd1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 28 Jul 2008 14:24:37 +0000 Subject: Okay. Frozen, we never said anything about it being permafrost. Also, this is not 100% tested, expect troubel with store_db (I'm waiting for the bug reports) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8697 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fb287299e5..296731c5f9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -531,6 +531,17 @@ $database_update_info = array( ), // No changes from 3.0.2-RC2 to 3.0.2 '3.0.2-RC2' => array(), + + // Changes from 3.0.2 to the next version + '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', NULL), + ), + ), + ), ); // Determine mapping database type -- cgit v1.2.1 From b3cff3489012d0ac17348c70986e0dd8d96d80c9 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 29 Jul 2008 23:10:07 +0000 Subject: weird - schemas later git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8731 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 296731c5f9..af631d09fc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -538,7 +538,7 @@ $database_update_info = array( 'add_columns' => array( STYLES_TEMPLATE_TABLE => array( 'template_inherits_id' => array('UINT:4', 0), - 'template_inherit_path' => array('VCHAR', NULL), + 'template_inherit_path' => array('VCHAR', ''), ), ), ), -- cgit v1.2.1 From 7f813a9ef65fbf3dd24565e3e199ab67b38df70c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 2 Sep 2008 06:34:27 +0000 Subject: settings and data for the new queued posts feature ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8804 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index af631d09fc..88ad142013 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -532,7 +532,7 @@ $database_update_info = array( // No changes from 3.0.2-RC2 to 3.0.2 '3.0.2-RC2' => array(), - // Changes from 3.0.2 to the next version + // Changes from 3.0.2 to 3.0.3-RC1 '3.0.2' => array( // Add the following columns 'add_columns' => array( @@ -1831,6 +1831,28 @@ function change_database_data(&$no_updates, $version) // 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.3': + set_config('enable_queue_trigger', '0'); + set_config('queue_trigger_posts', '3'); + + // Resync post counts + $sql = 'SELECT COUNT(p.post_id) AS num_posts, u.user_id + FROM ' . USERS_TABLE . ' u + LEFT JOIN ' . POSTS_TABLE . ' p ON (u.user_id = p.poster_id AND p.post_postcount = 1 AND p.post_approved = 1) + GROUP BY u.user_id'; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['user_id']}"; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + $no_updates = false; + break; } } -- cgit v1.2.1 From 46dac33b82198ee459ccdfb7bb5514a7d480bb05 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 2 Sep 2008 08:52:53 +0000 Subject: 3.0.2 instead of 3.0.3. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8806 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 88ad142013..53d22462c0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1833,7 +1833,7 @@ function change_database_data(&$no_updates, $version) break; // Changes from 3.0.2 to 3.0.3-RC1 - case '3.0.3': + case '3.0.2': set_config('enable_queue_trigger', '0'); set_config('queue_trigger_posts', '3'); -- cgit v1.2.1 From 2fcd96ca72741bdfb36c24a0af9dd8230b5a828f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 4 Sep 2008 12:01:47 +0000 Subject: Ok, story real database server info, as well as caching it Store it on installation too - allows us to check the db version used on installation and used currently to warn the user about incompatibilities git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8814 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 53d22462c0..c9ced1dbcb 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -552,7 +552,7 @@ switch ($db->sql_layer) break; case 'mysql4': - if (version_compare($db->mysql_version, '4.1.3', '>=')) + if (version_compare($db->sql_server_info(true), '4.1.3', '>=')) { $map_dbms = 'mysql_41'; } @@ -1837,6 +1837,9 @@ function change_database_data(&$no_updates, $version) set_config('enable_queue_trigger', '0'); set_config('queue_trigger_posts', '3'); + // Not prefilling yet + set_config('dbms_version', ''); + // Resync post counts $sql = 'SELECT COUNT(p.post_id) AS num_posts, u.user_id FROM ' . USERS_TABLE . ' u -- cgit v1.2.1 From 4a3db854b7d0ce56f3a3033f1dcc9f5baa0af8f9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 23 Sep 2008 13:03:33 +0000 Subject: - Added 'max_recipients' setting for private messages. This setting allows admins to define the maximum number of recipients per private message with a board-wide setting and a group-specific setting. - Added new permission setting for sending private messages to groups. Now there are two permissions to define sending private messages to multiple recipients and private messages to groups. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8911 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 97 ++++++++++++++++++++++++++++++++++----- 1 file changed, 86 insertions(+), 11 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c9ced1dbcb..81db58cf21 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -540,6 +540,9 @@ $database_update_info = array( 'template_inherits_id' => array('UINT:4', 0), 'template_inherit_path' => array('VCHAR', ''), ), + GROUPS_TABLE => array( + 'group_max_recipients' => array('UINT', 0), + ), ), ), ); @@ -1413,7 +1416,7 @@ if (function_exists('exit_handler')) */ function change_database_data(&$no_updates, $version) { - global $db, $map_dbms, $errored, $error_ary, $config, $phpbb_root_path; + global $db, $map_dbms, $errored, $error_ary, $config, $phpbb_root_path, $phpEx; switch ($version) { @@ -1837,22 +1840,94 @@ function change_database_data(&$no_updates, $version) 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', ''); - // Resync post counts - $sql = 'SELECT COUNT(p.post_id) AS num_posts, u.user_id - FROM ' . USERS_TABLE . ' u - LEFT JOIN ' . POSTS_TABLE . ' p ON (u.user_id = p.poster_id AND p.post_postcount = 1 AND p.post_approved = 1) - GROUP BY u.user_id'; - $result = _sql($sql, $errored, $error_ary); + // 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(); - while ($row = $db->sql_fetchrow($result)) + // Only add the new permission if it does not already exist + if (empty($auth_admin->acl_options['id']['u_masspm_group'])) { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['user_id']}"; - _sql($sql, $errored, $error_ary); + $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(); } - $db->sql_freeresult($result); + + /** + * Do not resync post counts here. An admin may later do this from the ACP + $start = 0; + + do + { + @flush(); + + $sql = 'SELECT COUNT(p.post_id) AS num_posts, u.user_id + FROM ' . USERS_TABLE . ' u + LEFT JOIN ' . POSTS_TABLE . ' p ON (u.user_id = p.poster_id AND p.post_postcount = 1 AND p.post_approved = 1) + GROUP BY u.user_id + ORDER BY u.user_id ASC'; + $result = $db->sql_query_limit($sql, 200, $start); + + if ($row = $db->sql_fetchrow($result)) + { + $i = 0; + + do + { + $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['user_id']}"; + _sql($sql, $errored, $error_ary); + + $i++; + } + while ($row = $db->sql_fetchrow($result)); + + $start = ($i < 200) ? 0 : $start + 200; + } + else + { + $start = 0; + } + $db->sql_freeresult($result); + } + while ($start); + */ $no_updates = false; break; -- cgit v1.2.1 From 936f7d43f0635b59b4eb7fcdff4d04b37ea03c21 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 24 Sep 2008 13:57:13 +0000 Subject: better query for syncing post counts. Thanks to BartVB for this. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8932 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 81db58cf21..3e733e6b22 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1893,32 +1893,30 @@ function change_database_data(&$no_updates, $version) /** * Do not resync post counts here. An admin may later do this 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 { - @flush(); - - $sql = 'SELECT COUNT(p.post_id) AS num_posts, u.user_id - FROM ' . USERS_TABLE . ' u - LEFT JOIN ' . POSTS_TABLE . ' p ON (u.user_id = p.poster_id AND p.post_postcount = 1 AND p.post_approved = 1) - GROUP BY u.user_id - ORDER BY u.user_id ASC'; - $result = $db->sql_query_limit($sql, 200, $start); + $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)) { - $i = 0; - do { - $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['user_id']}"; + $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; _sql($sql, $errored, $error_ary); - - $i++; } while ($row = $db->sql_fetchrow($result)); - $start = ($i < 200) ? 0 : $start + 200; + $start += $step; } else { -- cgit v1.2.1 From 36983da764695bb516645a176156bbc8187ef41a Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 13 Oct 2008 18:45:24 +0000 Subject: Disable mass e-mail when e-mail is disabled. #27385 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9011 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3e733e6b22..aba05722a1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1927,6 +1927,12 @@ function change_database_data(&$no_updates, $version) 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; } -- cgit v1.2.1 From fe4a53b76e7e55eafce56d502737ad3f5dcf2423 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 25 Oct 2008 14:12:13 +0000 Subject: Help the user if FTP update fails. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9035 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index aba05722a1..dd8f2d9704 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.2'; +$updates_to_version = '3.0.3-RC1'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) -- cgit v1.2.1 From 5d9306c5128f45cfc9a448ce888b725bbc4408b8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 25 Oct 2008 14:16:17 +0000 Subject: up the version number git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9036 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index dd8f2d9704..e84d63a950 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1891,7 +1891,7 @@ function change_database_data(&$no_updates, $version) } /** - * Do not resync post counts here. An admin may later do this from the ACP + * 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; -- cgit v1.2.1 From 538acb3db5e91f983849cd70fa754bb29ee364a0 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Wed, 5 Nov 2008 22:03:16 +0000 Subject: Remove deprecated language key and update any references in the database to the correct one. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9049 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e84d63a950..a6abc21508 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1935,6 +1935,16 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // Changes from 3.0.3-RC1 to 3.0.3-RC2 + case '3.0.3-RC1': + $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; } } -- cgit v1.2.1 From c185c3b64bcba881f723eb2ea9fee35afe9c29ec Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 8 Nov 2008 20:02:22 +0000 Subject: Fix Bug #36535 (PHP 5.3 compatibility) + version number updates (if RC2 will be released we will change it again. ;)) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9050 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a6abc21508..5fe9c19964 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -78,7 +78,7 @@ if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) } else { - set_magic_quotes_runtime(0); + @set_magic_quotes_runtime(0); define('STRIP', (get_magic_quotes_gpc()) ? true : false); } @@ -545,6 +545,9 @@ $database_update_info = array( ), ), ), + + // No changes from 3.0.3-RC1 to 3.0.3 + '3.0.3-RC1' => array(), ); // Determine mapping database type @@ -1936,7 +1939,7 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; - // Changes from 3.0.3-RC1 to 3.0.3-RC2 + // Changes from 3.0.3-RC1 to 3.0.3 case '3.0.3-RC1': $sql = 'UPDATE ' . LOG_TABLE . " SET log_operation = 'LOG_DELETE_TOPIC' -- cgit v1.2.1 From 40fa01b9f0cdd061967d929be0967599107ef2dc Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 12 Nov 2008 20:26:36 +0000 Subject: gah, forgot this tiny little thing... git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9058 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 5fe9c19964..48fd4e3ad2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.3-RC1'; +$updates_to_version = '3.0.3'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) -- cgit v1.2.1 From fb77cdd0513994dca478c06a3c9ac5912da07872 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 26 Nov 2008 19:58:35 +0000 Subject: Better handling and finer control for custom profile fields visibility options. (Patch by Highway of Life) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9127 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 52 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 48fd4e3ad2..b5839f517a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -548,6 +548,15 @@ $database_update_info = array( // 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), + ), + ), + ), ); // Determine mapping database type @@ -1948,6 +1957,47 @@ function change_database_data(&$no_updates, $version) $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; } } @@ -3082,4 +3132,4 @@ function utf8_new_clean_string($text) return trim($text); } -?> \ No newline at end of file +?> -- cgit v1.2.1 From 481e5c193fa21bd2cb8d7086fcdccd3d6964604d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 27 Nov 2008 13:44:24 +0000 Subject: extend the style columns (style_id, template_id, imageset_id, image_id...) No, not only because of possible style demos. :o git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9129 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b5839f517a..a0627a917f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.3'; +$updates_to_version = '3.0.4-RC1'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -556,6 +556,36 @@ $database_update_info = 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('USINT', 0), + ), + USERS_TABLE => array( + 'user_style' => array('UINT', 0), + ), + ), ), ); -- cgit v1.2.1 From 0481a574cedad6b0f09cb2d137e74da8f01bec47 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 12 Dec 2008 14:47:03 +0000 Subject: Change version number from 3.0.4-RC1 to 3.0.4 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9187 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a0627a917f..fb37b62203 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.4-RC1'; +$updates_to_version = '3.0.4'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -587,6 +587,9 @@ $database_update_info = array( ), ), ), + + // Changes from 3.0.4-RC1 to 3.0.4 + '3.0.4-RC1' => array(), ); // Determine mapping database type @@ -2028,6 +2031,10 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // Changes from 3.0.4-RC1 to 3.0.4 + case '3.0.4-RC1': + break; } } -- cgit v1.2.1 From 71039008474e678959a432db1868faf5d6a3cb71 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 21 Jan 2009 13:37:50 +0000 Subject: New option for the GD VC. Parameters need some more tweaking git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9283 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fb37b62203..54f7320e9e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2035,6 +2035,11 @@ function change_database_data(&$no_updates, $version) // Changes from 3.0.4-RC1 to 3.0.4 case '3.0.4-RC1': break; + + // Changes from 3.0.4 to 3.0.4dev + case '3.0.4': + set_config('captcha_gd_wave', 0); + break; } } -- cgit v1.2.1 From e5f0824e4b1f4215c0126edccc162aa1a7c6787d Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 6 Feb 2009 14:51:26 +0000 Subject: As proposed by marshalrusty: re-hash plain MD5s left in the database git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9312 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 54f7320e9e..ff6579d2ed 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.4'; +$updates_to_version = '3.0.5-dev'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -590,6 +590,9 @@ $database_update_info = array( // Changes from 3.0.4-RC1 to 3.0.4 '3.0.4-RC1' => array(), + + // Changes from 3.0.4 to 3.0.5-dev + '3.0.4' => array(), ); // Determine mapping database type @@ -2028,17 +2031,38 @@ function change_database_data(&$no_updates, $version) _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.4dev + // Changes from 3.0.4 to 3.0.5-dev case '3.0.4': + set_config('captcha_gd_wave', 0); + + $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); + } + } + + $no_updates = false; + break; } } -- cgit v1.2.1 From 6f486b0499258d1a236837acae120274bb1832d1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Sun, 8 Feb 2009 14:15:49 +0000 Subject: and another CAPTCHA setting - add new noise shapes to the noise array for more variations. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9320 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ff6579d2ed..18a94b3219 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2043,6 +2043,8 @@ function change_database_data(&$no_updates, $version) case '3.0.4': set_config('captcha_gd_wave', 0); + set_config('captcha_gd_3d_noise', 1); + $sql = 'SELECT user_id, user_password FROM ' . USERS_TABLE . ' -- cgit v1.2.1 From bfa4e6038e1e15bab8c19a6a0caa9607933b972b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 28 Feb 2009 19:20:29 +0000 Subject: refactor the database updater: - no longer support versions prior 3.0.0 - more apparent place for adding schema/data changes - use db_tools - added check for wrong schema (MySQL 3x/4x schema on MySQL > 4.0) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9350 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2924 ++++--------------------------------- 1 file changed, 321 insertions(+), 2603 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 18a94b3219..4f96966a81 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -10,6 +10,9 @@ $updates_to_version = '3.0.5-dev'; +// Enter any version to update from to test updates. The version within the db will not be updated. +$debug_from_version = false; + // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) { @@ -140,492 +143,25 @@ include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); // Define some variables for the database update $inline_update = (request_var('type', 0)) ? true : false; -// Database column types mapping -$dbms_type_map = array( - 'mysql_41' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT' => 'text', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT' => 'text', - 'TEXT_UNI' => 'text', - 'MTEXT' => 'mediumtext', - 'MTEXT_UNI' => 'mediumtext', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'varbinary(255)', - ), - - 'mysql_40' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'mediumint(8) UNSIGNED', - 'UINT:' => 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'smallint(4) UNSIGNED', - 'BOOL' => 'tinyint(1) UNSIGNED', - 'VCHAR' => 'varbinary(255)', - 'VCHAR:' => 'varbinary(%d)', - 'CHAR:' => 'binary(%d)', - 'XSTEXT' => 'blob', - 'XSTEXT_UNI'=> 'blob', - 'STEXT' => 'blob', - 'STEXT_UNI' => 'blob', - 'TEXT' => 'blob', - 'TEXT_UNI' => 'blob', - 'MTEXT' => 'mediumblob', - 'MTEXT_UNI' => 'mediumblob', - 'TIMESTAMP' => 'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'VCHAR_UNI' => 'blob', - 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), - 'VCHAR_CI' => 'blob', - 'VARBINARY' => 'varbinary(255)', - ), - - 'firebird' => array( - 'INT:' => 'INTEGER', - 'BINT' => 'DOUBLE PRECISION', - 'UINT' => 'INTEGER', - 'UINT:' => 'INTEGER', - 'TINT:' => 'INTEGER', - 'USINT' => 'INTEGER', - 'BOOL' => 'INTEGER', - 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE', - 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE', - 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE', - 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', - 'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8', - 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', - 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', - 'TIMESTAMP' => 'INTEGER', - 'DECIMAL' => 'DOUBLE PRECISION', - 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8', - 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8', - 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE', - ), - - 'mssql' => array( - 'INT:' => '[int]', - 'BINT' => '[float]', - 'UINT' => '[int]', - 'UINT:' => '[int]', - 'TINT:' => '[int]', - 'USINT' => '[int]', - 'BOOL' => '[int]', - 'VCHAR' => '[varchar] (255)', - 'VCHAR:' => '[varchar] (%d)', - 'CHAR:' => '[char] (%d)', - 'XSTEXT' => '[varchar] (1000)', - 'STEXT' => '[varchar] (3000)', - 'TEXT' => '[varchar] (8000)', - 'MTEXT' => '[text]', - 'XSTEXT_UNI'=> '[varchar] (100)', - 'STEXT_UNI' => '[varchar] (255)', - 'TEXT_UNI' => '[varchar] (4000)', - 'MTEXT_UNI' => '[text]', - 'TIMESTAMP' => '[int]', - 'DECIMAL' => '[float]', - 'VCHAR_UNI' => '[varchar] (255)', - 'VCHAR_UNI:'=> '[varchar] (%d)', - 'VCHAR_CI' => '[varchar] (255)', - 'VARBINARY' => '[varchar] (255)', - ), - - 'oracle' => array( - 'INT:' => 'number(%d)', - 'BINT' => 'number(20)', - 'UINT' => 'number(8)', - 'UINT:' => 'number(%d)', - 'TINT:' => 'number(%d)', - 'USINT' => 'number(4)', - 'BOOL' => 'number(1)', - 'VCHAR' => 'varchar2(255)', - 'VCHAR:' => 'varchar2(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar2(1000)', - 'STEXT' => 'varchar2(3000)', - 'TEXT' => 'clob', - 'MTEXT' => 'clob', - 'XSTEXT_UNI'=> 'varchar2(300)', - 'STEXT_UNI' => 'varchar2(765)', - 'TEXT_UNI' => 'clob', - 'MTEXT_UNI' => 'clob', - 'TIMESTAMP' => 'number(11)', - 'DECIMAL' => 'number(5, 2)', - 'VCHAR_UNI' => 'varchar2(765)', - 'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), - 'VCHAR_CI' => 'varchar2(255)', - 'VARBINARY' => 'raw(255)', - ), - - 'sqlite' => array( - 'INT:' => 'int(%d)', - 'BINT' => 'bigint(20)', - 'UINT' => 'INTEGER UNSIGNED', //'mediumint(8) UNSIGNED', - 'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED', - 'TINT:' => 'tinyint(%d)', - 'USINT' => 'INTEGER UNSIGNED', //'mediumint(4) UNSIGNED', - 'BOOL' => 'INTEGER UNSIGNED', //'tinyint(1) UNSIGNED', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'text(65535)', - 'STEXT' => 'text(65535)', - 'TEXT' => 'text(65535)', - 'MTEXT' => 'mediumtext(16777215)', - 'XSTEXT_UNI'=> 'text(65535)', - 'STEXT_UNI' => 'text(65535)', - 'TEXT_UNI' => 'text(65535)', - 'MTEXT_UNI' => 'mediumtext(16777215)', - 'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED', - 'DECIMAL' => 'decimal(5,2)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'blob', - ), - - 'postgres' => array( - 'INT:' => 'INT4', - 'BINT' => 'INT8', - 'UINT' => 'INT4', // unsigned - 'UINT:' => 'INT4', // unsigned - 'USINT' => 'INT2', // unsigned - 'BOOL' => 'INT2', // unsigned - 'TINT:' => 'INT2', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar(1000)', - 'STEXT' => 'varchar(3000)', - 'TEXT' => 'varchar(8000)', - 'MTEXT' => 'TEXT', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT_UNI' => 'varchar(4000)', - 'MTEXT_UNI' => 'TEXT', - 'TIMESTAMP' => 'INT4', // unsigned - 'DECIMAL' => 'decimal(5,2)', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar_ci', - 'VARBINARY' => 'bytea', - ), -); - -// A list of types being unsigned for better reference in some db's -$unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); - -// Only an example, but also commented out -$database_update_info = array( - // Changes from 3.0.RC2 to the next version - '3.0.RC2' => array( - // Change the following columns - 'change_columns' => array( - BANLIST_TABLE => array( - 'ban_reason' => array('VCHAR_UNI', ''), - 'ban_give_reason' => array('VCHAR_UNI', ''), - ), - ), - ), - // Changes from 3.0.RC3 to the next version - '3.0.RC3' => array( - // Change the following columns - 'change_columns' => array( - BANLIST_TABLE => array( - 'ban_reason' => array('VCHAR_UNI', ''), - 'ban_give_reason' => array('VCHAR_UNI', ''), - ), - STYLES_TABLE => array( - 'style_id' => array('USINT', 0), - 'template_id' => array('USINT', 0), - 'theme_id' => array('USINT', 0), - 'imageset_id' => array('USINT', 0), - ), - STYLES_TEMPLATE_TABLE => array( - 'template_id' => array('USINT', 0), - ), - STYLES_TEMPLATE_DATA_TABLE => array( - 'template_id' => array('USINT', 0), - ), - STYLES_THEME_TABLE => array( - 'theme_id' => array('USINT', 0), - ), - STYLES_IMAGESET_TABLE => array( - 'imageset_id' => array('USINT', 0), - ), - STYLES_IMAGESET_DATA_TABLE => array( - 'imageset_id' => array('USINT', 0), - ), - USERS_TABLE => array( - 'user_style' => array('USINT', 0), - ), - FORUMS_TABLE => array( - 'forum_style' => array('USINT', 0), - ), - GROUPS_TABLE => array( - 'group_avatar_type' => array('TINT:2', 0), - 'group_avatar_width' => array('USINT', 0), - 'group_avatar_height' => array('USINT', 0), - ), - ), - ), - // Changes from 3.0.RC4 to the next version - '3.0.RC4' => array( - // Change the following columns - 'change_columns' => array( - STYLES_TABLE => array( - 'style_id' => array('USINT', NULL, 'auto_increment'), - 'template_id' => array('USINT', 0), - 'theme_id' => array('USINT', 0), - 'imageset_id' => array('USINT', 0), - ), - STYLES_TEMPLATE_TABLE => array( - 'template_id' => array('USINT', NULL, 'auto_increment'), - ), - STYLES_TEMPLATE_DATA_TABLE => array( - 'template_id' => array('USINT', 0), - ), - STYLES_THEME_TABLE => array( - 'theme_id' => array('USINT', NULL, 'auto_increment'), - ), - STYLES_IMAGESET_TABLE => array( - 'imageset_id' => array('USINT', NULL, 'auto_increment'), - ), - STYLES_IMAGESET_DATA_TABLE => array( - 'imageset_id' => array('USINT', 0), - ), - USERS_TABLE => array( - 'user_style' => array('USINT', 0), - ), - FORUMS_TABLE => array( - 'forum_style' => array('USINT', 0), - ), - GROUPS_TABLE => array( - 'group_avatar_width' => array('USINT', 0), - 'group_avatar_height' => array('USINT', 0), - ), - ), - ), - // Changes from 3.0.RC5 to the next version - '3.0.RC5' => array( - // Add the following columns - 'add_columns' => array( - USERS_TABLE => array( - 'user_form_salt' => array('VCHAR_UNI:32', ''), - ), - ), - // Change the following columns - 'change_columns' => array( - POSTS_TABLE => array( - 'bbcode_uid' => array('VCHAR:8', ''), - ), - PRIVMSGS_TABLE => array( - 'bbcode_uid' => array('VCHAR:8', ''), - ), - USERS_TABLE => array( - 'user_sig_bbcode_uid' => array('VCHAR:8', ''), - ), - ), - ), - // Changes from 3.0.RC6 to the next version - '3.0.RC6' => array( - // Change the following columns - 'change_columns' => array( - FORUMS_TABLE => array( - 'forum_desc_uid' => array('VCHAR:8', ''), - 'forum_rules_uid' => array('VCHAR:8', ''), - ), - GROUPS_TABLE => array( - 'group_desc_uid' => array('VCHAR:8', ''), - ), - USERS_TABLE => array( - 'user_newpasswd' => array('VCHAR_UNI:40', ''), - ), - ), - ), - // Changes from 3.0.RC8 to the next version - '3.0.RC8' => array( - // Change the following columns - 'change_columns' => array( - USERS_TABLE => array( - 'user_new_privmsg' => array('INT:4', 0), - 'user_unread_privmsg' => array('INT:4', 0), - ), - ), - ), - // 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), - ), - ), - 'add_index' => array( - SESSIONS_TABLE => array( - 'session_forum_id' => array('session_forum_id'), - ), - GROUPS_TABLE => array( - 'group_legend_name' => array('group_legend', 'group_name'), - ), - ), - 'drop_keys' => array( - GROUPS_TABLE => array('group_legend'), - ), - ), - // 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('USINT', 0), - ), - USERS_TABLE => array( - 'user_style' => array('UINT', 0), - ), - ), - ), +// To let set_config() calls succeed, we need to make the config array available globally +$config = array(); - // Changes from 3.0.4-RC1 to 3.0.4 - '3.0.4-RC1' => array(), - - // Changes from 3.0.4 to 3.0.5-dev - '3.0.4' => array(), -); +$sql = 'SELECT * + FROM ' . CONFIG_TABLE; +$result = $db->sql_query($sql); -// Determine mapping database type -switch ($db->sql_layer) +while ($row = $db->sql_fetchrow($result)) { - case 'mysql': - $map_dbms = 'mysql_40'; - break; - - case 'mysql4': - if (version_compare($db->sql_server_info(true), '4.1.3', '>=')) - { - $map_dbms = 'mysql_41'; - } - else - { - $map_dbms = 'mysql_40'; - } - break; + $config[$row['config_name']] = $row['config_value']; +} +$db->sql_freeresult($result); - case 'mysqli': - $map_dbms = 'mysql_41'; - break; +// Include DB Tools +include($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); - case 'mssql': - case 'mssql_odbc': - $map_dbms = 'mssql'; - break; +$db_tools = new phpbb_db_tools($db, true); - default: - $map_dbms = $db->sql_layer; - break; -} +$database_update_info = database_update_info(); $error_ary = array(); $errored = false; @@ -657,7 +193,7 @@ header('Content-type: text/html; charset=UTF-8');
-
+

@@ -666,22 +202,10 @@ header('Content-type: text/html; charset=UTF-8');

:: sql_layer; ?>
sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $config[$row['config_name']] = $row['config_value']; -} -$db->sql_freeresult($result); - -/*if ($debug_from_version !== false) +if ($debug_from_version !== false) { $config['version'] = $debug_from_version; -}*/ +} echo $lang['PREVIOUS_VERSION'] . ' :: ' . $config['version'] . '
'; echo $lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . '

'; @@ -690,6 +214,61 @@ $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)); +} + +// 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') +{ + // 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)) . '

'; +?> +
+
+ +
+
+ + + + + + + +sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); } -// Checks/Operations that have to be completed prior to starting the update itself -$exit = false; -if (version_compare($current_version, '3.0.RC8', '<=')) /* && $debug_from_version === false) */ -{ - // Define missing language entries... - if (!isset($lang['CLEANING_USERNAMES'])) - { - $lang = array_merge($lang, array( - 'CLEANING_USERNAMES' => 'Cleaning usernames', - 'LONG_SCRIPT_EXECUTION' => 'Please note that this can take a while... Please do not stop the script.', - 'CHANGE_CLEAN_NAMES' => 'The method used to make sure a username is not used by multiple users has been changed. There are some users which have the same name when compared with the new method. You have to delete or rename these users to make sure that each name is only used by one user before you can proceed.', - 'USER_ACTIVE' => 'Active user', - 'USER_INACTIVE' => 'Inactive user', - 'BOT' => 'Spider/Robot', - 'UPDATE_REQUIRES_FILE' => 'The updater requires that the following file is present: %s', - - 'DELETE_USER_REMOVE' => 'Delete user and remove posts', - 'DELETE_USER_RETAIN' => 'Delete user but keep posts', - 'EDIT_USERNAME' => 'Edit username', - 'KEEP_OLD_NAME' => 'Keep username', - 'NEW_USERNAME' => 'New username', - )); - } +// Schema updates ?>

-

+


+

:: '')); - $new_usernames = request_var('new_usernames', array(0 => ''), true); +flush(); + +// We go through the schema changes from the lowest to the highest version +// We try to also include versions 'in-between'... +$no_updates = true; +$versions = array_keys($database_update_info); +for ($i = 0; $i < sizeof($versions); $i++) +{ + $version = $versions[$i]; + $schema_changes = $database_update_info[$version]; - // We need this file if someone wants to edit usernames. - include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); + $next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version; - if (!class_exists('utf_new_normalizer')) + // 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, '>=')) { - if (!file_exists($phpbb_root_path . 'install/data/new_normalizer.' . $phpEx)) - { - global $lang; - trigger_error(sprintf($lang['UPDATE_REQUIRES_FILE'], $phpbb_root_path . 'install/data/new_normalizer.' . $phpEx), E_USER_ERROR); - } - include($phpbb_root_path . 'install/data/new_normalizer.' . $phpEx); + continue; } - // the admin decided to change some usernames - if (sizeof($modify_users) && $submit) + if (!sizeof($schema_changes)) { - $sql = 'SELECT user_id, username, user_type - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', array_keys($modify_users)); - $result = $db->sql_query($sql); + continue; + } - $users = 0; - while ($row = $db->sql_fetchrow($result)) - { - $users++; - $user_id = (int) $row['user_id']; + $no_updates = false; - if (isset($modify_users[$user_id])) - { - $row['action'] = $modify_users[$user_id]; - $modify_users[$user_id] = $row; - } - } - $db->sql_freeresult($result); + $statements = $db_tools->perform_schema_changes($schema_changes); - // only if all ids really existed - if (sizeof($modify_users) == $users) - { - $user->data['user_id'] = ANONYMOUS; - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - foreach ($modify_users as $user_id => $row) - { - switch ($row['action']) - { - case 'edit': - if (isset($new_usernames[$user_id])) - { - $data = array('username' => utf8_new_normalize_nfc($new_usernames[$user_id])); - // Need to update config, forum, topic, posting, messages, etc. - if ($data['username'] != $row['username']) - { - $check_ary = array('username' => array( - array('string', false, $config['min_name_chars'], $config['max_name_chars']), - array('username'), - )); - // need a little trick for this to work properly - $user->data['username_clean'] = utf8_clean_string($data['username']) . 'a'; - $errors = validate_data($data, $check_ary); - - if ($errors) - { - include($phpbb_root_path . 'language/' . $language . '/ucp.' . $phpEx); - echo '

'; - foreach ($errors as $error) - { - echo '

' . $lang[$error] . '

'; - } - echo '
'; - } - - if (!$errors) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', array( - 'username' => $data['username'], - 'username_clean' => utf8_clean_string($data['username']) - )) . ' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - - add_log('user', $user_id, 'LOG_USER_UPDATE_NAME', $row['username'], $data['username']); - user_update_name($row['username'], $data['username']); - } - } - } - break; - - case 'delete_retain': - case 'delete_remove': - if ($user_id != ANONYMOUS && $row['user_type'] != USER_FOUNDER) - { - user_delete(substr($row['action'], 7), $user_id, $row['username']); - add_log('admin', 'LOG_USER_DELETED', $row['username']); - } - break; - } - } - } + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); } -?> - -

-

:: +} -sql_query($sql); +_write_result($no_updates, $errored, $error_ary); - $colliding_users = $found_names = array(); - $echos = 0; +// Data updates +$error_ary = array(); +$errored = $no_updates = false; - while ($row = $db->sql_fetchrow($result)) - { - // Calculate the new clean name. If it differs from the old one we need - // to make sure there is no collision - $clean_name = utf8_new_clean_string($row['username']); +?> - if ($clean_name != $row['username_clean']) - { - // Check if there would be a collission, if not put it up for changing - $user_id = (int) $row['user_id']; +

+

+
+

:: - // If this clean name was not the result of another user already ... - if (!isset($found_names[$clean_name])) - { - // then we need to figure out whether there are any other users - // who already had this clean name with the old version - $sql = 'SELECT user_id, username - FROM ' . USERS_TABLE . ' - WHERE username_clean = \'' . $db->sql_escape($clean_name) . '\''; - $result2 = $db->sql_query($sql); +sql_fetchrow($result2)) - { - // For not trimmed entries this could happen, yes. ;) - if ($row['user_id'] == $user_id) - { - continue; - } +flush(); - // Make sure this clean name will still be the same with the - // new function. If it is, then we have to add it to the list - // of user ids for this clean name - if (utf8_new_clean_string($row['username']) == $clean_name) - { - $user_ids[] = (int) $row['user_id']; - } - } - $db->sql_freeresult($result2); +$no_updates = true; +$versions = array_keys($database_update_info); - // if we already found a collision save it - if (sizeof($user_ids) > 1) - { - $colliding_users[$clean_name] = $user_ids; - $found_names[$clean_name] = true; - } - else - { - // otherwise just mark this name as found - $found_names[$clean_name] = $user_id; - } - } - // Else, if we already found the username - else - { - // If the value in the found_names lookup table is only true ... - if ($found_names[$clean_name] === true) - { - // then the actual data was already added to $colliding_users - // and we only need to append the user_id - $colliding_users[$clean_name][] = $user_id; - } - else - { - // otherwise it still keeps the first user_id for this name - // and we need to move the data to $colliding_users, and set - // the value in the found_names lookup table to true, so - // following users will directly be appended to $colliding_users - $colliding_users[$clean_name] = array($found_names[$clean_name], $user_id); - $found_names[$clean_name] = true; - } - } - } +// 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 (($echos % 1000) == 0) - { - echo '.'; - flush(); - } - $echos++; + // 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; } - $db->sql_freeresult($result); - _write_result(false, $errored, $error_ary); - - // now retrieve all information about the users and let the admin decide what to do - if (sizeof($colliding_users)) - { - $exit = true; - include($phpbb_root_path . 'includes/functions_display.' . $phpEx); - include($phpbb_root_path . 'language/' . $language . '/memberlist.' . $phpEx); - include($phpbb_root_path . 'language/' . $language . '/acp/users.' . $phpEx); - - // link a few things to the correct place so we don't get any problems - $user->lang = &$lang; - $user->data['user_id'] = ANONYMOUS; - $user->date_format = $config['default_dateformat']; - - // a little trick to get all user_ids - $user_ids = call_user_func_array('array_merge', array_values($colliding_users)); - - $sql = 'SELECT session_user_id, MAX(session_time) AS session_time - FROM ' . SESSIONS_TABLE . ' - WHERE session_time >= ' . (time() - $config['session_length']) . ' - AND ' . $db->sql_in_set('session_user_id', $user_ids) . ' - GROUP BY session_user_id'; - $result = $db->sql_query($sql); - - $session_times = array(); - while ($row = $db->sql_fetchrow($result)) - { - $session_times[$row['session_user_id']] = $row['session_time']; - } - $db->sql_freeresult($result); + change_database_data($no_updates, $version); +} - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_ids); - $result = $db->sql_query($sql); +_write_result($no_updates, $errored, $error_ary); - $users = array(); - while ($row = $db->sql_fetchrow($result)) - { - if (isset($session_times[$row['user_id']])) - { - $row['session_time'] = $session_times[$row['user_id']]; - } - else - { - $row['session_time'] = 0; - } - $users[(int) $row['user_id']] = $row; - } - $db->sql_freeresult($result); - unset($session_times); - - // now display a table with all users, some information about them and options - // for the admin: keep name, change name (with text input) or delete user - $u_action = "database_update.$phpEx?language=$language&type=$inline_update"; -?> -

- -

-
- - - $user_ids) - { -?> -
- - - - - - - - - - - - - - - $user_id) - { - $row = $users[$user_id]; - - $rank_title = $rank_img = ''; - get_user_rank($row['user_rank'], $row['user_posts'], $rank_title, $rank_img, $rank_img_src); - - $last_visit = (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit']; - - $info = ''; - switch ($row['user_type']) - { - case USER_INACTIVE: - $info .= $lang['USER_INACTIVE']; - break; - - case USER_IGNORE: - $info .= $lang['BOT']; - break; - - case USER_FOUNDER: - $info .= $lang['FOUNDER']; - break; - - default: - $info .= $lang['USER_ACTIVE']; - } - - if ($user_id == ANONYMOUS) - { - $info = $lang['GUEST']; - } -?> - - - - - - - - - - - -
-
- -
format_date($row['user_regdate']) ?>format_date($last_visit); ?>  -
-
- -
- - -
- -
-
- -

- -

-
-sql_in_set('user_id', array_values($found_names)); - $result = $db->sql_query($sql); - - $found_names = array(); - while ($row = $db->sql_fetchrow($result)) - { - $clean_name = utf8_new_clean_string($row['username']); - - if ($clean_name != $row['username_clean']) - { - $user_id = (int) $row['user_id']; - $found_names[$user_id] = $clean_name; - - // impossible unique clean name - $sql = 'UPDATE ' . USERS_TABLE . " - SET username_clean = ' {$user_id}' - WHERE user_id = {$user_id}"; - $db->sql_query($sql); - } - } - $db->sql_freeresult($result); - - foreach ($found_names as $user_id => $clean_name) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET username_clean = \'' . $db->sql_escape($clean_name) . '\' - WHERE user_id = ' . $user_id; - $db->sql_query($sql); - } - } - unset($found_names); - unset($colliding_users); -} - -if ($exit) -{ -?> - - - - - - - - - - - - - - - -

- -

- -
-

:: - -= 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; - } - -/* if ($debug_from_version !== false) - { - // Applying update schema for version array with key '$version' - // for version '$version' to '$next_version' - continue; - }*/ - - if (!sizeof($schema_changes)) - { - continue; - } - - $no_updates = false; - - // Change columns? - if (!empty($schema_changes['change_columns'])) - { - foreach ($schema_changes['change_columns'] as $table => $columns) - { - foreach ($columns as $column_name => $column_data) - { - sql_column_change($map_dbms, $table, $column_name, $column_data); - } - } - } - - // Add columns? - if (!empty($schema_changes['add_columns'])) - { - foreach ($schema_changes['add_columns'] as $table => $columns) - { - foreach ($columns as $column_name => $column_data) - { - // Only add the column if it does not exist yet - if (!column_exists($map_dbms, $table, $column_name)) - { - sql_column_add($map_dbms, $table, $column_name, $column_data); - } - } - } - } - - // Remove keys? - if (!empty($schema_changes['drop_keys'])) - { - foreach ($schema_changes['drop_keys'] as $table => $indexes) - { - foreach ($indexes as $index_name) - { - sql_index_drop($map_dbms, $index_name, $table); - } - } - } - - // Drop columns? - if (!empty($schema_changes['drop_columns'])) - { - foreach ($schema_changes['drop_columns'] as $table => $columns) - { - foreach ($columns as $column) - { - sql_column_remove($map_dbms, $table, $column); - } - } - } - - // Add primary keys? - if (!empty($schema_changes['add_primary_keys'])) - { - foreach ($schema_changes['add_primary_keys'] as $table => $columns) - { - sql_create_primary_key($map_dbms, $table, $columns); - } - } - - // Add unqiue indexes? - if (!empty($schema_changes['add_unique_index'])) - { - foreach ($schema_changes['add_unique_index'] as $table => $index_array) - { - foreach ($index_array as $index_name => $column) - { - sql_create_unique_index($map_dbms, $index_name, $table, $column); - } - } - } - - // Add indexes? - if (!empty($schema_changes['add_index'])) - { - foreach ($schema_changes['add_index'] as $table => $index_array) - { - foreach ($index_array as $index_name => $column) - { - sql_create_index($map_dbms, $index_name, $table, $column); - } - } - } -} - -_write_result($no_updates, $errored, $error_ary); - -// Data updates -$error_ary = array(); -$errored = $no_updates = false; +$error_ary = array(); +$errored = $no_updates = false; ?>

-

+


:: @@ -1317,63 +379,23 @@ $errored = $no_updates = false; flush(); -$no_updates = true; -$versions = array_keys($database_update_info); - -// some code magic -for ($i = 0; $i < sizeof($versions); $i++) +if ($debug_from_version === false) { - $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; - } - -/* if ($debug_from_version !== false) - { - // Applying update schema for version array with key '$version' - // for version '$version' to '$next_version' - continue; - }*/ - - change_database_data($no_updates, $version); + // update the version + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '$updates_to_version' + WHERE config_name = 'version'"; + _sql($sql, $errored, $error_ary); } -_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 @@ -1406,8 +428,6 @@ _write_result($no_updates, $errored, $error_ary); if (!$inline_update) { - // Purge the cache... - $cache->purge(); ?>

@@ -1460,380 +480,209 @@ if (function_exists('exit_handler')) } /** -* Function where all data changes are executed +* Function for triggering an sql statement */ -function change_database_data(&$no_updates, $version) +function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { - global $db, $map_dbms, $errored, $error_ary, $config, $phpbb_root_path, $phpEx; + global $db; - switch ($version) + if (defined('DEBUG_EXTRA')) { - case '3.0.RC2': + echo "
\n{$sql}\n
"; + } - $smileys = array(); + $db->sql_return_on_error(true); - $sql = 'SELECT smiley_id, code - FROM ' . SMILIES_TABLE; - $result = $db->sql_query($sql); + $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(); + } - while ($row = $db->sql_fetchrow($result)) - { - $smileys[$row['smiley_id']] = $row['code']; - } - $db->sql_freeresult($result); + $db->sql_return_on_error(false); - foreach ($smileys as $id => $code) - { - // 2.0 only entitized lt and gt; We need to do something about double quotes. - if (strchr($code, '"') === false) - { - continue; - } + if ($echo_dot) + { + echo ". \n"; + flush(); + } - $new_code = str_replace('&', '&', $code); - $new_code = str_replace('<', '<', $new_code); - $new_code = str_replace('>', '>', $new_code); - $new_code = utf8_htmlspecialchars($new_code); + return $result; +} - $sql = 'UPDATE ' . SMILIES_TABLE . ' - SET code = \'' . $db->sql_escape($new_code) . '\' - WHERE smiley_id = ' . (int) $id; - $db->sql_query($sql); - } +function _write_result($no_updates, $errored, $error_ary) +{ + global $lang; - $index_list = sql_list_index($map_dbms, ACL_ROLES_DATA_TABLE); + if ($no_updates) + { + echo ' ' . $lang['NO_UPDATES_REQUIRED'] . '

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

' . $lang['RESULT'] . ' :: '; + + if ($errored) + { + echo ' ' . $lang['SOME_QUERIES_FAILED'] . '
    '; - if (in_array('ath_opt_id', $index_list)) + for ($i = 0; $i < sizeof($error_ary['sql']); $i++) { - sql_index_drop($map_dbms, 'ath_opt_id', ACL_ROLES_DATA_TABLE); - sql_create_index($map_dbms, 'ath_op_id', ACL_ROLES_DATA_TABLE, array('auth_option_id')); + echo '
  • ' . $lang['ERROR'] . ' :: ' . htmlspecialchars($error_ary['error_code'][$i]['message']) . '
    '; + echo $lang['SQL'] . ' :: ' . htmlspecialchars($error_ary['sql'][$i]) . '

  • '; } - $no_updates = false; - break; - - case '3.0.RC3': - - if ($map_dbms === 'postgres') - { - $sql = "SELECT SETVAL('" . FORUMS_TABLE . "_seq',(select case when max(forum_id)>0 then max(forum_id)+1 else 1 end from " . FORUMS_TABLE . '));'; - _sql($sql, $errored, $error_ary); - } + echo '


' . $lang['SQL_FAILURE_EXPLAIN'] . '

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

'; + } + } +} - // we check for: - // ath_opt_id - // ath_op_id - // ACL_ROLES_DATA_TABLE_ath_opt_id - // we want ACL_ROLES_DATA_TABLE_ath_op_id - - $table_index_fix = array( - ACL_ROLES_DATA_TABLE => array( - 'ath_opt_id' => 'ath_op_id', - 'ath_op_id' => 'ath_op_id', - ACL_ROLES_DATA_TABLE . '_ath_opt_id' => 'ath_op_id' +/**************************************************************************** +* 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), ), - STYLES_IMAGESET_DATA_TABLE => array( - 'i_id' => 'i_d', - 'i_d' => 'i_d', - STYLES_IMAGESET_DATA_TABLE . '_i_id' => 'i_d' - ) - ); - - // we need to create some indicies... - $needed_creation = array(); - - foreach ($table_index_fix as $table_name => $index_info) - { - $index_list = sql_list_fake($map_dbms, $table_name); - foreach ($index_info as $bad_index => $good_index) - { - if (in_array($bad_index, $index_list)) - { - // mysql is actually OK, it won't get a hand in this crud - switch ($map_dbms) - { - // last version, mssql had issues with index removal - case 'mssql': - $sql = 'DROP INDEX ' . $table_name . '.' . $bad_index; - _sql($sql, $errored, $error_ary); - break; - - // last version, firebird, oracle, postgresql and sqlite all got bad index names - // we got kinda lucky, tho: they all support the same syntax - case 'firebird': - case 'oracle': - case 'postgres': - case 'sqlite': - $sql = 'DROP INDEX ' . $bad_index; - _sql($sql, $errored, $error_ary); - break; - } - - // If the good index already exist we do not need to create it again... - if (($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41') && $bad_index == $good_index) - { - } - else - { - $needed_creation[$table_name][$good_index] = 1; - } - } - } - } - - $new_index_defs = array('ath_op_id' => array('auth_option_id'), 'i_d' => array('imageset_id')); - - foreach ($needed_creation as $bad_table => $index_repair_list) - { - foreach ($index_repair_list as $new_index => $garbage) - { - sql_create_index($map_dbms, $new_index, $bad_table, $new_index_defs[$new_index]); - } - } - - // Make sure empty smiley codes do not exist - $sql = 'DELETE FROM ' . SMILIES_TABLE . " - WHERE code = ''"; - _sql($sql, $errored, $error_ary); - - set_config('allow_birthdays', '1'); - set_config('cron_lock', '0', true); - - $no_updates = false; - break; - - case '3.0.RC4': - - $update_auto_increment = array( - STYLES_TABLE => 'style_id', - STYLES_TEMPLATE_TABLE => 'template_id', - STYLES_THEME_TABLE => 'theme_id', - STYLES_IMAGESET_TABLE => 'imageset_id' - ); - - $sql = 'SELECT * - FROM ' . STYLES_TABLE . ' - WHERE style_id = 0'; - $result = _sql($sql, $errored, $error_ary); - $bad_style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($bad_style_row) - { - $sql = 'SELECT MAX(style_id) as max_id - FROM ' . STYLES_TABLE; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $proper_id = $row['max_id'] + 1; - - _sql('UPDATE ' . STYLES_TABLE . " SET style_id = $proper_id WHERE style_id = 0", $errored, $error_ary); - _sql('UPDATE ' . FORUMS_TABLE . " SET forum_style = $proper_id WHERE forum_style = 0", $errored, $error_ary); - _sql('UPDATE ' . USERS_TABLE . " SET user_style = $proper_id WHERE user_style = 0", $errored, $error_ary); - - $sql = 'SELECT config_value - FROM ' . CONFIG_TABLE . " - WHERE config_name = 'default_style'"; - $result = _sql($sql, $errored, $error_ary); - $style_config = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($style_config['config_value'] === '0') - { - set_config('default_style', (string) $proper_id); - } - } - - $sql = 'SELECT * - FROM ' . STYLES_TEMPLATE_TABLE . ' - WHERE template_id = 0'; - $result = _sql($sql, $errored, $error_ary); - $bad_style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($bad_style_row) - { - $sql = 'SELECT MAX(template_id) as max_id - FROM ' . STYLES_TEMPLATE_TABLE; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $proper_id = $row['max_id'] + 1; - - _sql('UPDATE ' . STYLES_TABLE . " SET template_id = $proper_id WHERE template_id = 0", $errored, $error_ary); - } - - $sql = 'SELECT * - FROM ' . STYLES_THEME_TABLE . ' - WHERE theme_id = 0'; - $result = _sql($sql, $errored, $error_ary); - $bad_style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($bad_style_row) - { - $sql = 'SELECT MAX(theme_id) as max_id - FROM ' . STYLES_THEME_TABLE; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $proper_id = $row['max_id'] + 1; - - _sql('UPDATE ' . STYLES_TABLE . " SET theme_id = $proper_id WHERE theme_id = 0", $errored, $error_ary); - } - - $sql = 'SELECT * - FROM ' . STYLES_IMAGESET_TABLE . ' - WHERE imageset_id = 0'; - $result = _sql($sql, $errored, $error_ary); - $bad_style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($bad_style_row) - { - $sql = 'SELECT MAX(imageset_id) as max_id - FROM ' . STYLES_IMAGESET_TABLE; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $proper_id = $row['max_id'] + 1; - - _sql('UPDATE ' . STYLES_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary); - _sql('UPDATE ' . STYLES_IMAGESET_DATA_TABLE . " SET imageset_id = $proper_id WHERE imageset_id = 0", $errored, $error_ary); - } - - if ($map_dbms == 'mysql_40' || $map_dbms == 'mysql_41') - { - foreach ($update_auto_increment as $auto_table_name => $auto_column_name) - { - $sql = "SELECT MAX({$auto_column_name}) as max_id - FROM {$auto_table_name}"; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $max_id = ((int) $row['max_id']) + 1; - _sql("ALTER TABLE {$auto_table_name} AUTO_INCREMENT = {$max_id}", $errored, $error_ary); - } - } - else if ($map_dbms == 'postgres') - { - foreach ($update_auto_increment as $auto_table_name => $auto_column_name) - { - $sql = "SELECT SETVAL('" . $auto_table_name . "_seq',(select case when max({$auto_column_name})>0 then max({$auto_column_name})+1 else 1 end from " . $auto_table_name . '));'; - _sql($sql, $errored, $error_ary); - } - - $sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq'; - _sql($sql, $errored, $error_ary); - } - else if ($map_dbms == 'firebird') - { - $sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE; - _sql($sql, $errored, $error_ary); - - $sql = 'DROP GENERATOR ' . STYLES_TEMPLATE_DATA_TABLE . '_gen'; - _sql($sql, $errored, $error_ary); - } - else if ($map_dbms == 'oracle') - { - $sql = 'DROP TRIGGER t_' . STYLES_TEMPLATE_DATA_TABLE; - _sql($sql, $errored, $error_ary); - - $sql = 'DROP SEQUENCE ' . STYLES_TEMPLATE_DATA_TABLE . '_seq'; - _sql($sql, $errored, $error_ary); - } - else if ($map_dbms == 'mssql') - { - // we use transactions because we need to have a working DB at the end of all of this - $db->sql_transaction('begin'); - - $sql = 'SELECT * - FROM ' . STYLES_TEMPLATE_DATA_TABLE; - $result = _sql($sql, $errored, $error_ary); - $old_style_rows = array(); - while ($row = $db->sql_fetchrow($result)) - { - $old_style_rows[] = $row; - } - $db->sql_freeresult($result); - - // death to the table, it is evil! - $sql = 'DROP TABLE ' . STYLES_TEMPLATE_DATA_TABLE; - _sql($sql, $errored, $error_ary); - - // the table of awesomeness, praise be to it (or something) - $sql = 'CREATE TABLE [' . STYLES_TEMPLATE_DATA_TABLE . "] ( - [template_id] [int] DEFAULT (0) NOT NULL , - [template_filename] [varchar] (100) DEFAULT ('') NOT NULL , - [template_included] [varchar] (8000) DEFAULT ('') NOT NULL , - [template_mtime] [int] DEFAULT (0) NOT NULL , - [template_data] [text] DEFAULT ('') NOT NULL - ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]"; - _sql($sql, $errored, $error_ary); - - // index? index - $sql = 'CREATE INDEX [tid] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_id]) ON [PRIMARY]'; - _sql($sql, $errored, $error_ary); - - // yet another index - $sql = 'CREATE INDEX [tfn] ON [' . STYLES_TEMPLATE_DATA_TABLE . ']([template_filename]) ON [PRIMARY]'; - _sql($sql, $errored, $error_ary); - - foreach ($old_style_rows as $return_row) - { - _sql('INSERT INTO ' . STYLES_TEMPLATE_DATA_TABLE . ' ' . $db->sql_build_array('INSERT', $return_row), $errored, $error_ary); - } - - $db->sql_transaction('commit'); - } - - // Setting this here again because new installations may not have it... - set_config('cron_lock', '0', true); - set_config('ldap_port', ''); - set_config('ldap_user_filter', ''); - - $no_updates = false; - break; - - case '3.0.RC5': - - // In case the user is having the bot mediapartner google "as is", adjust it. - $sql = 'UPDATE ' . BOTS_TABLE . " - SET bot_agent = '" . $db->sql_escape('Mediapartners-Google') . "' - WHERE bot_agent = '" . $db->sql_escape('Mediapartners-Google/') . "'"; - _sql($sql, $errored, $error_ary); + SESSIONS_TABLE => array( + 'session_forum_id' => array('UINT', 0), + ), + ), + 'add_index' => array( + SESSIONS_TABLE => array( + 'session_forum_id' => array('session_forum_id'), + ), + GROUPS_TABLE => array( + 'group_legend_name' => array('group_legend', 'group_name'), + ), + ), + 'drop_keys' => array( + GROUPS_TABLE => array('group_legend'), + ), + ), + // 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(), - set_config('form_token_lifetime', '7200'); - set_config('form_token_mintime', '0'); - set_config('min_time_reg', '5'); - set_config('min_time_terms', '2'); - set_config('form_token_sid_guests', '1'); + // 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), + ), + ), + ), - $db->sql_transaction('begin'); + // No changes from 3.0.3-RC1 to 3.0.3 + '3.0.3-RC1' => array(), - $sql = 'SELECT forum_id, forum_password - FROM ' . FORUMS_TABLE; - $result = _sql($sql, $errored, $error_ary); + // 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('USINT', 0), + ), + USERS_TABLE => array( + 'user_style' => array('UINT', 0), + ), + ), + ), - while ($row = $db->sql_fetchrow($result)) - { - if (!empty($row['forum_password'])) - { - _sql('UPDATE ' . FORUMS_TABLE . " SET forum_password = '" . md5($row['forum_password']) . "' WHERE forum_id = {$row['forum_id']}", $errored, $error_ary); - } - } - $db->sql_freeresult($result); + // Changes from 3.0.4-RC1 to 3.0.4 + '3.0.4-RC1' => array(), - $db->sql_transaction('commit'); + // Changes from 3.0.4 to 3.0.5-dev + '3.0.4' => array(), + ); +} - $no_updates = false; - break; +/**************************************************************************** +* 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, $errored, $error_ary, $config, $phpbb_root_path, $phpEx; + switch ($version) + { case '3.0.0': $sql = 'UPDATE ' . TOPICS_TABLE . " @@ -2032,22 +881,21 @@ function change_database_data(&$no_updates, $version) _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-dev case '3.0.4': set_config('captcha_gd_wave', 0); set_config('captcha_gd_3d_noise', 1); - - $sql = 'SELECT user_id, user_password - FROM ' . USERS_TABLE . ' + $sql = 'SELECT user_id, user_password + FROM ' . USERS_TABLE . ' WHERE user_pass_convert = 1'; $result = _sql($sql, $errored, $error_ary); @@ -2062,6 +910,7 @@ function change_database_data(&$no_updates, $version) _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); $no_updates = false; @@ -2069,1135 +918,4 @@ function change_database_data(&$no_updates, $version) } } -/** -* Function for triggering an sql statement -*/ -function _sql($sql, &$errored, &$error_ary, $echo_dot = true) -{ - global $db; - - if (defined('DEBUG_EXTRA')) - { - echo "
\n{$sql}\n
"; - } - - $db->sql_return_on_error(true); - - $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(); - } - - $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'] . '

'; - } - } -} - -/** -* Check if a specified column exist -*/ -function column_exists($dbms, $table, $column_name) -{ - global $db; - - switch ($dbms) - { - case 'mysql_40': - case 'mysql_41': - $sql = "SHOW COLUMNS - FROM $table"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - // lower case just in case - if (strtolower($row['Field']) == $column_name) - { - $db->sql_freeresult($result); - return true; - } - } - $db->sql_freeresult($result); - return false; - break; - - // PostgreSQL has a way of doing this in a much simpler way but would - // not allow us to support all versions of PostgreSQL - case 'postgres': - $sql = "SELECT a.attname - FROM pg_class c, pg_attribute a - WHERE c.relname = '{$table}' - AND a.attnum > 0 - AND a.attrelid = c.oid"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - // lower case just in case - if (strtolower($row['attname']) == $column_name) - { - $db->sql_freeresult($result); - return true; - } - } - $db->sql_freeresult($result); - return false; - break; - - // same deal with PostgreSQL, we must perform more complex operations than - // we technically could - case 'mssql': - $sql = "SELECT c.name - FROM syscolumns c - LEFT JOIN sysobjects o ON c.id = o.id - WHERE o.name = '{$table}'"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - // lower case just in case - if (strtolower($row['name']) == $column_name) - { - $db->sql_freeresult($result); - return true; - } - } - $db->sql_freeresult($result); - return false; - break; - - case 'oracle': - $sql = "SELECT column_name - FROM user_tab_columns - WHERE table_name = '{$table}'"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - // lower case just in case - if (strtolower($row['column_name']) == $column_name) - { - $db->sql_freeresult($result); - return true; - } - } - $db->sql_freeresult($result); - return false; - break; - - case 'firebird': - $sql = "SELECT RDB\$FIELD_NAME as FNAME - FROM RDB\$RELATION_FIELDS - WHERE RDB\$RELATION_NAME = '{$table}'"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - // lower case just in case - if (strtolower($row['fname']) == $column_name) - { - $db->sql_freeresult($result); - return true; - } - } - $db->sql_freeresult($result); - return false; - break; - - // ugh, SQLite - case 'sqlite': - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table}'"; - $result = $db->sql_query($sql); - - if (!$result) - { - return false; - } - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $cols = trim($matches[1]); - $col_array = preg_split('/,(?![\s\w]+\))/m', $cols); - - foreach ($col_array as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - - if (strtolower($entities[0]) == $column_name) - { - return true; - } - } - return false; - break; - } -} - -/** -* Function to prepare some column information for better usage -*/ -function prepare_column_data($dbms, $column_data, $table_name, $column_name) -{ - global $dbms_type_map, $unsigned_types; - - // Get type - if (strpos($column_data[0], ':') !== false) - { - list($orig_column_type, $column_length) = explode(':', $column_data[0]); - - if (!is_array($dbms_type_map[$dbms][$orig_column_type . ':'])) - { - $column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'], $column_length); - } - else - { - if (isset($dbms_type_map[$dbms][$orig_column_type . ':']['rule'])) - { - switch ($dbms_type_map[$dbms][$orig_column_type . ':']['rule'][0]) - { - case 'div': - $column_length /= $dbms_type_map[$dbms][$orig_column_type . ':']['rule'][1]; - $column_length = ceil($column_length); - $column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length); - break; - } - } - - if (isset($dbms_type_map[$dbms][$orig_column_type . ':']['limit'])) - { - switch ($dbms_type_map[$dbms][$orig_column_type . ':']['limit'][0]) - { - case 'mult': - $column_length *= $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][1]; - if ($column_length > $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][2]) - { - $column_type = $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][3]; - } - else - { - $column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length); - } - break; - } - } - } - $orig_column_type .= ':'; - } - else - { - $orig_column_type = $column_data[0]; - $column_type = $dbms_type_map[$dbms][$column_data[0]]; - } - - // Adjust default value if db-dependant specified - if (is_array($column_data[1])) - { - $column_data[1] = (isset($column_data[1][$dbms])) ? $column_data[1][$dbms] : $column_data[1]['default']; - } - - $sql = ''; - $return_array = array(); - - switch ($dbms) - { - case 'firebird': - $sql .= " {$column_type} "; - - if (!is_null($column_data[1])) - { - $sql .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; - } - - $sql .= 'NOT NULL'; - - // This is a UNICODE column and thus should be given it's fair share - if (preg_match('/^X?STEXT_UNI|VCHAR_(CI|UNI:?)/', $column_data[0])) - { - $sql .= ' COLLATE UNICODE'; - } - - break; - - case 'mssql': - $sql .= " {$column_type} "; - $sql_default = " {$column_type} "; - - // For adding columns we need the default definition - if (!is_null($column_data[1])) - { - // For hexadecimal values do not use single quotes - if (strpos($column_data[1], '0x') === 0) - { - $sql_default .= 'DEFAULT (' . $column_data[1] . ') '; - } - else - { - $sql_default .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; - } - } - - $sql .= 'NOT NULL'; - $sql_default .= 'NOT NULL'; - - $return_array['column_type_sql_default'] = $sql_default; - break; - - case 'mysql_40': - case 'mysql_41': - $sql .= " {$column_type} "; - - // For hexadecimal values do not use single quotes - if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob') - { - $sql .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' "; - } - $sql .= 'NOT NULL'; - - if (isset($column_data[2])) - { - if ($column_data[2] == 'auto_increment') - { - $sql .= ' auto_increment'; - } - else if ($dbms === 'mysql_41' && $column_data[2] == 'true_sort') - { - $sql .= ' COLLATE utf8_unicode_ci'; - } - } - - break; - - case 'oracle': - $sql .= " {$column_type} "; - $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : ''; - - // In Oracle empty strings ('') are treated as NULL. - // Therefore in oracle we allow NULL's for all DEFAULT '' entries - // Oracle does not like setting NOT NULL on a column that is already NOT NULL (this happens only on number fields) - if (preg_match('/number/i', $column_type)) - { - $sql .= ($column_data[1] === '') ? '' : 'NOT NULL'; - } - break; - - case 'postgres': - $return_array['column_type'] = $column_type; - - $sql .= " {$column_type} "; - - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $default_val = "nextval('{$table_name}_seq')"; - } - else if (!is_null($column_data[1])) - { - $default_val = "'" . $column_data[1] . "'"; - $return_array['null'] = 'NOT NULL'; - $sql .= 'NOT NULL '; - } - - $return_array['default'] = $default_val; - - $sql .= "DEFAULT {$default_val}"; - - // Unsigned? Then add a CHECK contraint - if (in_array($orig_column_type, $unsigned_types)) - { - $return_array['constraint'] = "CHECK ({$column_name} >= 0)"; - $sql .= " CHECK ({$column_name} >= 0)"; - } - break; - - case 'sqlite': - if (isset($column_data[2]) && $column_data[2] == 'auto_increment') - { - $sql .= ' INTEGER PRIMARY KEY'; - } - else - { - $sql .= ' ' . $column_type; - } - - $sql .= ' NOT NULL '; - $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : ''; - break; - } - - $return_array['column_type_sql'] = $sql; - - return $return_array; -} - -/** -* Add new column -*/ -function sql_column_add($dbms, $table_name, $column_name, $column_data) -{ - global $errored, $error_ary; - - $column_data = prepare_column_data($dbms, $column_data, $table_name, $column_name); - - switch ($dbms) - { - case 'firebird': - $sql = 'ALTER TABLE "' . $table_name . '" ADD "' . $column_name . '" ' . $column_data['column_type_sql']; - _sql($sql, $errored, $error_ary); - break; - - case 'mssql': - $sql = 'ALTER TABLE [' . $table_name . '] ADD [' . $column_name . '] ' . $column_data['column_type_sql_default']; - _sql($sql, $errored, $error_ary); - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'ALTER TABLE `' . $table_name . '` ADD COLUMN `' . $column_name . '` ' . $column_data['column_type_sql']; - _sql($sql, $errored, $error_ary); - break; - - case 'oracle': - $sql = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql']; - _sql($sql, $errored, $error_ary); - break; - - case 'postgres': - $sql = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; - _sql($sql, $errored, $error_ary); - break; - - case 'sqlite': - if (version_compare(sqlite_libversion(), '3.0') == -1) - { - global $db; - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}' - ORDER BY type DESC, name;"; - $result = $db->sql_query($sql); - - if (!$result) - { - break; - } - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $db->sql_transaction('begin'); - - // Create a backup table and populate it, destroy the existing one - $db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql'])); - $db->sql_query('INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name); - $db->sql_query('DROP TABLE ' . $table_name); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - $column_list[] = $entities[0]; - } - - $columns = implode(',', $column_list); - - $new_table_cols = $column_name . ' ' . $column_data['column_type_sql'] . ',' . $new_table_cols; - - // create a new table and fill it up. destroy the temp one - $db->sql_query('CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');'); - $db->sql_query('INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'); - $db->sql_query('DROP TABLE ' . $table_name . '_temp'); - - $db->sql_transaction('commit'); - } - else - { - $sql = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' [' . $column_data['column_type_sql'] . ']'; - _sql($sql, $errored, $error_ary); - } - break; - } -} - -/** -* Drop column -*/ -function sql_column_remove($dbms, $table_name, $column_name) -{ - global $errored, $error_ary; - - switch ($dbms) - { - case 'firebird': - $sql = 'ALTER TABLE "' . $table_name . '" DROP "' . $column_name . '"'; - _sql($sql, $errored, $error_ary); - break; - - case 'mssql': - $sql = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; - _sql($sql, $errored, $error_ary); - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'ALTER TABLE `' . $table_name . '` DROP COLUMN `' . $column_name . '`'; - _sql($sql, $errored, $error_ary); - break; - - case 'oracle': - $sql = 'ALTER TABLE ' . $table_name . ' DROP ' . $column_name; - _sql($sql, $errored, $error_ary); - break; - - case 'postgres': - $sql = 'ALTER TABLE ' . $table_name . ' DROP COLUMN "' . $column_name . '"'; - _sql($sql, $errored, $error_ary); - break; - - case 'sqlite': - if (version_compare(sqlite_libversion(), '3.0') == -1) - { - global $db; - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}' - ORDER BY type DESC, name;"; - $result = $db->sql_query($sql); - - if (!$result) - { - break; - } - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $db->sql_transaction('begin'); - - // Create a backup table and populate it, destroy the existing one - $db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql'])); - $db->sql_query('INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name); - $db->sql_query('DROP TABLE ' . $table_name); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY' || $entities[0] === $column_name) - { - continue; - } - $column_list[] = $entities[0]; - } - - $columns = implode(',', $column_list); - - $new_table_cols = $new_table_cols = preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols); - - // create a new table and fill it up. destroy the temp one - $db->sql_query('CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');'); - $db->sql_query('INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'); - $db->sql_query('DROP TABLE ' . $table_name . '_temp'); - - $db->sql_transaction('commit'); - } - else - { - $sql = 'ALTER TABLE ' . $table_name . ' DROP COLUMN ' . $column_name; - _sql($sql, $errored, $error_ary); - } - break; - } -} - -function sql_index_drop($dbms, $index_name, $table_name) -{ - global $dbms_type_map, $db; - global $errored, $error_ary; - - switch ($dbms) - { - case 'mssql': - $sql = 'DROP INDEX ' . $table_name . '.' . $index_name; - _sql($sql, $errored, $error_ary); - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'DROP INDEX ' . $index_name . ' ON ' . $table_name; - _sql($sql, $errored, $error_ary); - break; - - case 'firebird': - case 'oracle': - case 'postgres': - case 'sqlite': - $sql = 'DROP INDEX ' . $table_name . '_' . $index_name; - _sql($sql, $errored, $error_ary); - break; - } -} - -function sql_create_primary_key($dbms, $table_name, $column) -{ - global $dbms_type_map, $db; - global $errored, $error_ary; - - switch ($dbms) - { - case 'firebird': - case 'postgres': - $sql = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; - _sql($sql, $errored, $error_ary); - break; - - case 'mssql': - $sql = "ALTER TABLE [{$table_name}] WITH NOCHECK ADD "; - $sql .= "CONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED ("; - $sql .= '[' . implode("],\n\t\t[", $column) . ']'; - $sql .= ') ON [PRIMARY]'; - _sql($sql, $errored, $error_ary); - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; - _sql($sql, $errored, $error_ary); - break; - - case 'oracle': - $sql = 'ALTER TABLE ' . $table_name . 'add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')'; - _sql($sql, $errored, $error_ary); - break; - - case 'sqlite': - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}' - ORDER BY type DESC, name;"; - $result = _sql($sql, $errored, $error_ary); - - if (!$result) - { - break; - } - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $db->sql_transaction('begin'); - - // Create a backup table and populate it, destroy the existing one - $db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql'])); - $db->sql_query('INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name); - $db->sql_query('DROP TABLE ' . $table_name); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - if ($entities[0] == 'PRIMARY') - { - continue; - } - $column_list[] = $entities[0]; - } - - $columns = implode(',', $column_list); - - // create a new table and fill it up. destroy the temp one - $db->sql_query('CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ', PRIMARY KEY (' . implode(', ', $column) . '));'); - $db->sql_query('INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'); - $db->sql_query('DROP TABLE ' . $table_name . '_temp'); - - $db->sql_transaction('commit'); - break; - } -} - -function sql_create_unique_index($dbms, $index_name, $table_name, $column) -{ - global $dbms_type_map, $db; - global $errored, $error_ary; - - switch ($dbms) - { - case 'firebird': - case 'postgres': - case 'oracle': - case 'sqlite': - $sql = 'CREATE UNIQUE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - _sql($sql, $errored, $error_ary); - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - _sql($sql, $errored, $error_ary); - break; - - case 'mssql': - $sql = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; - _sql($sql, $errored, $error_ary); - break; - } -} - -function sql_create_index($dbms, $index_name, $table_name, $column) -{ - global $dbms_type_map, $db; - global $errored, $error_ary; - - switch ($dbms) - { - case 'firebird': - case 'postgres': - case 'oracle': - case 'sqlite': - $sql = 'CREATE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - _sql($sql, $errored, $error_ary); - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; - _sql($sql, $errored, $error_ary); - break; - - case 'mssql': - $sql = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; - _sql($sql, $errored, $error_ary); - break; - } -} - -// List all of the indices that belong to a table, -// does not count: -// * UNIQUE indices -// * PRIMARY keys -function sql_list_index($dbms, $table_name) -{ - global $dbms_type_map, $db; - global $errored, $error_ary; - - $index_array = array(); - - if ($dbms == 'mssql') - { - $sql = "EXEC sp_statistics '$table_name'"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['TYPE'] == 3) - { - $index_array[] = $row['INDEX_NAME']; - } - } - $db->sql_freeresult($result); - } - else - { - switch ($dbms) - { - case 'firebird': - $sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name - FROM RDB\$INDICES - WHERE RDB\$RELATION_NAME = " . strtoupper($table_name) . " - AND RDB\$UNIQUE_FLAG IS NULL - AND RDB\$FOREIGN_KEY IS NULL"; - $col = 'index_name'; - break; - - case 'postgres': - $sql = "SELECT ic.relname as index_name - FROM pg_class bc, pg_class ic, pg_index i - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (bc.relname = '" . $table_name . "') - AND (i.indisunique != 't') - AND (i.indisprimary != 't')"; - $col = 'index_name'; - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'SHOW KEYS - FROM ' . $table_name; - $col = 'Key_name'; - break; - - case 'oracle': - $sql = "SELECT index_name - FROM user_indexes - WHERE table_name = '" . $table_name . "' - AND generated = 'N'"; - break; - - case 'sqlite': - $sql = "PRAGMA index_info('" . $table_name . "');"; - $col = 'name'; - break; - } - - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if (($dbms == 'mysql_40' || $dbms == 'mysql_41') && !$row['Non_unique']) - { - continue; - } - - switch ($dbms) - { - case 'firebird': - case 'oracle': - case 'postgres': - case 'sqlite': - $row[$col] = substr($row[$col], strlen($table_name) + 1); - break; - } - - $index_array[] = $row[$col]; - } - $db->sql_freeresult($result); - } - - return array_map('strtolower', $index_array); -} - -// This is totally fake, never use it -// it exists only to mend bad update functions introduced -// * UNIQUE indices -// * PRIMARY keys -function sql_list_fake($dbms, $table_name) -{ - global $dbms_type_map, $db; - global $errored, $error_ary; - - $index_array = array(); - - if ($dbms == 'mssql') - { - $sql = "EXEC sp_statistics '$table_name'"; - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if ($row['TYPE'] == 3) - { - $index_array[] = $row['INDEX_NAME']; - } - } - $db->sql_freeresult($result); - } - else - { - switch ($dbms) - { - case 'firebird': - $sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name - FROM RDB\$INDICES - WHERE RDB\$RELATION_NAME = " . strtoupper($table_name) . " - AND RDB\$UNIQUE_FLAG IS NULL - AND RDB\$FOREIGN_KEY IS NULL"; - $col = 'index_name'; - break; - - case 'postgres': - $sql = "SELECT ic.relname as index_name - FROM pg_class bc, pg_class ic, pg_index i - WHERE (bc.oid = i.indrelid) - AND (ic.oid = i.indexrelid) - AND (bc.relname = '" . $table_name . "') - AND (i.indisunique != 't') - AND (i.indisprimary != 't')"; - $col = 'index_name'; - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'SHOW KEYS - FROM ' . $table_name; - $col = 'Key_name'; - break; - - case 'oracle': - $sql = "SELECT index_name - FROM user_indexes - WHERE table_name = '" . $table_name . "' - AND generated = 'N'"; - break; - - case 'sqlite': - $sql = "PRAGMA index_info('" . $table_name . "');"; - $col = 'name'; - break; - } - - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - if (($dbms == 'mysql_40' || $dbms == 'mysql_41') && !$row['Non_unique']) - { - continue; - } - - $index_array[] = $row[$col]; - } - $db->sql_freeresult($result); - } - - return array_map('strtolower', $index_array); -} - -/** -* Change column type (not name!) -*/ -function sql_column_change($dbms, $table_name, $column_name, $column_data) -{ - global $dbms_type_map, $db; - global $errored, $error_ary; - - $column_data = prepare_column_data($dbms, $column_data, $table_name, $column_name); - - switch ($dbms) - { - case 'firebird': - // Change type... - $sql = 'ALTER TABLE "' . $table_name . '" ALTER COLUMN "' . $column_name . '" TYPE ' . ' ' . $column_data['column_type_sql']; - _sql($sql, $errored, $error_ary); - break; - - case 'mssql': - $sql = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; - _sql($sql, $errored, $error_ary); - break; - - case 'mysql_40': - case 'mysql_41': - $sql = 'ALTER TABLE `' . $table_name . '` CHANGE `' . $column_name . '` `' . $column_name . '` ' . $column_data['column_type_sql']; - _sql($sql, $errored, $error_ary); - break; - - case 'oracle': - $sql = 'ALTER TABLE ' . $table_name . ' MODIFY ' . $column_name . ' ' . $column_data['column_type_sql']; - _sql($sql, $errored, $error_ary); - break; - - case 'postgres': - $sql = 'ALTER TABLE ' . $table_name . ' '; - - $sql_array = array(); - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' TYPE ' . $column_data['column_type']; - - if (isset($column_data['null'])) - { - if ($column_data['null'] == 'NOT NULL') - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' SET NOT NULL'; - } - else if ($column_data['null'] == 'NULL') - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' DROP NOT NULL'; - } - } - - if (isset($column_data['default'])) - { - $sql_array[] = 'ALTER COLUMN ' . $column_name . ' SET DEFAULT ' . $column_data['default']; - } - - // we don't want to double up on constraints if we change different number data types - if (isset($column_data['constraint'])) - { - $constraint_sql = "SELECT consrc as constraint_data - FROM pg_constraint, pg_class bc - WHERE conrelid = bc.oid - AND bc.relname = '{$table_name}' - AND NOT EXISTS ( - SELECT * - FROM pg_constraint as c, pg_inherits as i - WHERE i.inhrelid = pg_constraint.conrelid - AND c.conname = pg_constraint.conname - AND c.consrc = pg_constraint.consrc - AND c.conrelid = i.inhparent - )"; - - $constraint_exists = false; - - $result = $db->sql_query($constraint_sql); - while ($row = $db->sql_fetchrow($result)) - { - if (trim($row['constraint_data']) == trim($column_data['constraint'])) - { - $constraint_exists = true; - break; - } - } - $db->sql_freeresult($result); - - if (!$constraint_exists) - { - $sql_array[] = 'ADD ' . $column_data['constraint']; - } - } - - $sql .= implode(', ', $sql_array); - - _sql($sql, $errored, $error_ary); - break; - - case 'sqlite': - - $sql = "SELECT sql - FROM sqlite_master - WHERE type = 'table' - AND name = '{$table_name}' - ORDER BY type DESC, name;"; - $result = _sql($sql, $errored, $error_ary); - - if (!$result) - { - break; - } - - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $db->sql_transaction('begin'); - - // Create a temp table and populate it, destroy the existing one - $db->sql_query(preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql'])); - $db->sql_query('INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name); - $db->sql_query('DROP TABLE ' . $table_name); - - preg_match('#\((.*)\)#s', $row['sql'], $matches); - - $new_table_cols = trim($matches[1]); - $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); - $column_list = array(); - - foreach ($old_table_cols as $key => $declaration) - { - $entities = preg_split('#\s+#', trim($declaration)); - $column_list[] = $entities[0]; - if ($entities[0] == $column_name) - { - $old_table_cols[$key] = $column_name . ' ' . $column_data['column_type_sql']; - } - } - - $columns = implode(',', $column_list); - - // create a new table and fill it up. destroy the temp one - $db->sql_query('CREATE TABLE ' . $table_name . ' (' . implode(',', $old_table_cols) . ');'); - $db->sql_query('INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'); - $db->sql_query('DROP TABLE ' . $table_name . '_temp'); - - $db->sql_transaction('commit'); - - break; - } -} - -function utf8_new_clean_string($text) -{ - static $homographs = array(); - static $utf8_case_fold_nfkc = ''; - if (empty($homographs)) - { - global $phpbb_root_path, $phpEx; - if (!function_exists('utf8_case_fold_nfkc') || !file_exists($phpbb_root_path . 'includes/utf/data/confusables.' . $phpEx)) - { - if (!file_exists($phpbb_root_path . 'install/data/confusables.' . $phpEx)) - { - global $lang; - trigger_error(sprintf($lang['UPDATE_REQUIRES_FILE'], $phpbb_root_path . 'install/data/confusables.' . $phpEx), E_USER_ERROR); - } - $homographs = include($phpbb_root_path . 'install/data/confusables.' . $phpEx); - $utf8_case_fold_nfkc = 'utf8_new_case_fold_nfkc'; - } - else - { - $homographs = include($phpbb_root_path . 'includes/utf/data/confusables.' . $phpEx); - $utf8_case_fold_nfkc = 'utf8_case_fold_nfkc'; - } - } - - $text = $utf8_case_fold_nfkc($text); - $text = strtr($text, $homographs); - // Other control characters - $text = preg_replace('#(?:[\x00-\x1F\x7F]+|(?:\xC2[\x80-\x9F])+)#', '', $text); - - $text = preg_replace('# {2,}#', ' ', $text); - - // we can use trim here as all the other space characters should have been turned - // into normal ASCII spaces by now - return trim($text); -} - -?> +?> \ No newline at end of file -- cgit v1.2.1 From 3896f64ba5a96dac8c26df15c5c6d3005a2e3c45 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Mon, 2 Mar 2009 02:33:15 +0000 Subject: Removed the major version number from the useragent match of the Ichiro bot, it has been upgraded git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9354 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4f96966a81..f805d19d38 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -912,6 +912,11 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = 'ichiro/' + WHERE bot_agent = 'ichiro/2'"; + _sql($sql, $errored, $error_ary); + $no_updates = false; break; -- cgit v1.2.1 From 01078bb2fa8795e495e356a66676cb36dd3b0cd1 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 17 Mar 2009 16:04:58 +0000 Subject: captcha changes git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9390 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f805d19d38..ca94bf03a9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -893,6 +893,10 @@ function change_database_data(&$no_updates, $version) set_config('captcha_gd_wave', 0); set_config('captcha_gd_3d_noise', 1); + set_config('captcha_gd_fonts', 1); + set_config('confirm_refresh', 1); + + $sql = 'SELECT user_id, user_password FROM ' . USERS_TABLE . ' -- cgit v1.2.1 From 0f162568f241753ff3ec5a15c3ec9d3028c10f23 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 20 Mar 2009 13:22:19 +0000 Subject: Fix duplicate creation of acl options in acl_add_options() under certain conditions. (Bug #38385, #40225) Add unique key to ACL options table to prevent duplicate permission options. (Bug #41835) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9400 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 66 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ca94bf03a9..3ad01f62bb 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -894,10 +894,10 @@ function change_database_data(&$no_updates, $version) set_config('captcha_gd_wave', 0); set_config('captcha_gd_3d_noise', 1); set_config('captcha_gd_fonts', 1); - set_config('confirm_refresh', 1); - + set_config('confirm_refresh', 1); + // Hash old MD5 passwords $sql = 'SELECT user_id, user_password FROM ' . USERS_TABLE . ' WHERE user_pass_convert = 1'; @@ -916,11 +916,73 @@ function change_database_data(&$no_updates, $version) } $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(*) >= 1'; + $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"; + $result = $db->sql_query_limit($sql, 0, 1); + + 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'), + ), + 'add_unique_index' => array( + ACL_OPTIONS_TABLE => array( + 'auth_option' => array('auth_option'), + ), + ), + ); + + global $db_tools; + + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + $no_updates = false; break; -- cgit v1.2.1 From d75616c71708b812dc2ac88594985cdaef2f896a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 24 Mar 2009 12:24:55 +0000 Subject: unfortunately we are not able to use db_tools - because we do not know the state it is in, therefore can't rely on it. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9405 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 1379 ++++++++++++++++++++++++++++++++++++- 1 file changed, 1375 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3ad01f62bb..0639f41b35 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -156,10 +156,9 @@ while ($row = $db->sql_fetchrow($result)) } $db->sql_freeresult($result); -// Include DB Tools -include($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); - -$db_tools = new phpbb_db_tools($db, true); +// We do not include DB Tools here, because we can not be sure the file is up-to-date ;) +// Instead, this file defines a clean db_tools version (we are also not able to provide a different file, else the database update will not work standalone) +$db_tools = new updater_db_tools($db, true); $database_update_info = database_update_info(); @@ -989,4 +988,1376 @@ function change_database_data(&$no_updates, $version) } } + +/** +* Database Tools for handling cross-db actions such as altering columns, etc. +* Currently not supported is returning SQL for creating tables. +* +* @package dbal +*/ +class updater_db_tools +{ + /** + * Current sql layer + */ + var $sql_layer = ''; + + /** + * @var object DB object + */ + var $db = NULL; + + /** + * The Column types for every database we support + * @var array + */ + var $dbms_type_map = array( + 'mysql_41' => array( + 'INT:' => 'int(%d)', + 'BINT' => 'bigint(20)', + 'UINT' => 'mediumint(8) UNSIGNED', + 'UINT:' => 'int(%d) UNSIGNED', + 'TINT:' => 'tinyint(%d)', + 'USINT' => 'smallint(4) UNSIGNED', + 'BOOL' => 'tinyint(1) UNSIGNED', + 'VCHAR' => 'varchar(255)', + 'VCHAR:' => 'varchar(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'text', + 'XSTEXT_UNI'=> 'varchar(100)', + 'STEXT' => 'text', + 'STEXT_UNI' => 'varchar(255)', + 'TEXT' => 'text', + 'TEXT_UNI' => 'text', + 'MTEXT' => 'mediumtext', + 'MTEXT_UNI' => 'mediumtext', + 'TIMESTAMP' => 'int(11) UNSIGNED', + 'DECIMAL' => 'decimal(5,2)', + 'DECIMAL:' => 'decimal(%d,2)', + 'PDECIMAL' => 'decimal(6,3)', + 'PDECIMAL:' => 'decimal(%d,3)', + 'VCHAR_UNI' => 'varchar(255)', + 'VCHAR_UNI:'=> 'varchar(%d)', + 'VCHAR_CI' => 'varchar(255)', + 'VARBINARY' => 'varbinary(255)', + ), + + 'mysql_40' => array( + 'INT:' => 'int(%d)', + 'BINT' => 'bigint(20)', + 'UINT' => 'mediumint(8) UNSIGNED', + 'UINT:' => 'int(%d) UNSIGNED', + 'TINT:' => 'tinyint(%d)', + 'USINT' => 'smallint(4) UNSIGNED', + 'BOOL' => 'tinyint(1) UNSIGNED', + 'VCHAR' => 'varbinary(255)', + 'VCHAR:' => 'varbinary(%d)', + 'CHAR:' => 'binary(%d)', + 'XSTEXT' => 'blob', + 'XSTEXT_UNI'=> 'blob', + 'STEXT' => 'blob', + 'STEXT_UNI' => 'blob', + 'TEXT' => 'blob', + 'TEXT_UNI' => 'blob', + 'MTEXT' => 'mediumblob', + 'MTEXT_UNI' => 'mediumblob', + 'TIMESTAMP' => 'int(11) UNSIGNED', + 'DECIMAL' => 'decimal(5,2)', + 'DECIMAL:' => 'decimal(%d,2)', + 'PDECIMAL' => 'decimal(6,3)', + 'PDECIMAL:' => 'decimal(%d,3)', + 'VCHAR_UNI' => 'blob', + 'VCHAR_UNI:'=> array('varbinary(%d)', 'limit' => array('mult', 3, 255, 'blob')), + 'VCHAR_CI' => 'blob', + 'VARBINARY' => 'varbinary(255)', + ), + + 'firebird' => array( + 'INT:' => 'INTEGER', + 'BINT' => 'DOUBLE PRECISION', + 'UINT' => 'INTEGER', + 'UINT:' => 'INTEGER', + 'TINT:' => 'INTEGER', + 'USINT' => 'INTEGER', + 'BOOL' => 'INTEGER', + 'VCHAR' => 'VARCHAR(255) CHARACTER SET NONE', + 'VCHAR:' => 'VARCHAR(%d) CHARACTER SET NONE', + 'CHAR:' => 'CHAR(%d) CHARACTER SET NONE', + 'XSTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', + 'STEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', + 'TEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', + 'MTEXT' => 'BLOB SUB_TYPE TEXT CHARACTER SET NONE', + 'XSTEXT_UNI'=> 'VARCHAR(100) CHARACTER SET UTF8', + 'STEXT_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', + 'TEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', + 'MTEXT_UNI' => 'BLOB SUB_TYPE TEXT CHARACTER SET UTF8', + 'TIMESTAMP' => 'INTEGER', + 'DECIMAL' => 'DOUBLE PRECISION', + 'DECIMAL:' => 'DOUBLE PRECISION', + 'PDECIMAL' => 'DOUBLE PRECISION', + 'PDECIMAL:' => 'DOUBLE PRECISION', + 'VCHAR_UNI' => 'VARCHAR(255) CHARACTER SET UTF8', + 'VCHAR_UNI:'=> 'VARCHAR(%d) CHARACTER SET UTF8', + 'VCHAR_CI' => 'VARCHAR(255) CHARACTER SET UTF8', + 'VARBINARY' => 'CHAR(255) CHARACTER SET NONE', + ), + + 'mssql' => array( + 'INT:' => '[int]', + 'BINT' => '[float]', + 'UINT' => '[int]', + 'UINT:' => '[int]', + 'TINT:' => '[int]', + 'USINT' => '[int]', + 'BOOL' => '[int]', + 'VCHAR' => '[varchar] (255)', + 'VCHAR:' => '[varchar] (%d)', + 'CHAR:' => '[char] (%d)', + 'XSTEXT' => '[varchar] (1000)', + 'STEXT' => '[varchar] (3000)', + 'TEXT' => '[varchar] (8000)', + 'MTEXT' => '[text]', + 'XSTEXT_UNI'=> '[varchar] (100)', + 'STEXT_UNI' => '[varchar] (255)', + 'TEXT_UNI' => '[varchar] (4000)', + 'MTEXT_UNI' => '[text]', + 'TIMESTAMP' => '[int]', + 'DECIMAL' => '[float]', + 'DECIMAL:' => '[float]', + 'PDECIMAL' => '[float]', + 'PDECIMAL:' => '[float]', + 'VCHAR_UNI' => '[varchar] (255)', + 'VCHAR_UNI:'=> '[varchar] (%d)', + 'VCHAR_CI' => '[varchar] (255)', + 'VARBINARY' => '[varchar] (255)', + ), + + 'oracle' => array( + 'INT:' => 'number(%d)', + 'BINT' => 'number(20)', + 'UINT' => 'number(8)', + 'UINT:' => 'number(%d)', + 'TINT:' => 'number(%d)', + 'USINT' => 'number(4)', + 'BOOL' => 'number(1)', + 'VCHAR' => 'varchar2(255)', + 'VCHAR:' => 'varchar2(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'varchar2(1000)', + 'STEXT' => 'varchar2(3000)', + 'TEXT' => 'clob', + 'MTEXT' => 'clob', + 'XSTEXT_UNI'=> 'varchar2(300)', + 'STEXT_UNI' => 'varchar2(765)', + 'TEXT_UNI' => 'clob', + 'MTEXT_UNI' => 'clob', + 'TIMESTAMP' => 'number(11)', + 'DECIMAL' => 'number(5, 2)', + 'DECIMAL:' => 'number(%d, 2)', + 'PDECIMAL' => 'number(6, 3)', + 'PDECIMAL:' => 'number(%d, 3)', + 'VCHAR_UNI' => 'varchar2(765)', + 'VCHAR_UNI:'=> array('varchar2(%d)', 'limit' => array('mult', 3, 765, 'clob')), + 'VCHAR_CI' => 'varchar2(255)', + 'VARBINARY' => 'raw(255)', + ), + + 'sqlite' => array( + 'INT:' => 'int(%d)', + 'BINT' => 'bigint(20)', + 'UINT' => 'INTEGER UNSIGNED', //'mediumint(8) UNSIGNED', + 'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED', + 'TINT:' => 'tinyint(%d)', + 'USINT' => 'INTEGER UNSIGNED', //'mediumint(4) UNSIGNED', + 'BOOL' => 'INTEGER UNSIGNED', //'tinyint(1) UNSIGNED', + 'VCHAR' => 'varchar(255)', + 'VCHAR:' => 'varchar(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'text(65535)', + 'STEXT' => 'text(65535)', + 'TEXT' => 'text(65535)', + 'MTEXT' => 'mediumtext(16777215)', + 'XSTEXT_UNI'=> 'text(65535)', + 'STEXT_UNI' => 'text(65535)', + 'TEXT_UNI' => 'text(65535)', + 'MTEXT_UNI' => 'mediumtext(16777215)', + 'TIMESTAMP' => 'INTEGER UNSIGNED', //'int(11) UNSIGNED', + 'DECIMAL' => 'decimal(5,2)', + 'DECIMAL:' => 'decimal(%d,2)', + 'PDECIMAL' => 'decimal(6,3)', + 'PDECIMAL:' => 'decimal(%d,3)', + 'VCHAR_UNI' => 'varchar(255)', + 'VCHAR_UNI:'=> 'varchar(%d)', + 'VCHAR_CI' => 'varchar(255)', + 'VARBINARY' => 'blob', + ), + + 'postgres' => array( + 'INT:' => 'INT4', + 'BINT' => 'INT8', + 'UINT' => 'INT4', // unsigned + 'UINT:' => 'INT4', // unsigned + 'USINT' => 'INT2', // unsigned + 'BOOL' => 'INT2', // unsigned + 'TINT:' => 'INT2', + 'VCHAR' => 'varchar(255)', + 'VCHAR:' => 'varchar(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'varchar(1000)', + 'STEXT' => 'varchar(3000)', + 'TEXT' => 'varchar(8000)', + 'MTEXT' => 'TEXT', + 'XSTEXT_UNI'=> 'varchar(100)', + 'STEXT_UNI' => 'varchar(255)', + 'TEXT_UNI' => 'varchar(4000)', + 'MTEXT_UNI' => 'TEXT', + 'TIMESTAMP' => 'INT4', // unsigned + 'DECIMAL' => 'decimal(5,2)', + 'DECIMAL:' => 'decimal(%d,2)', + 'PDECIMAL' => 'decimal(6,3)', + 'PDECIMAL:' => 'decimal(%d,3)', + 'VCHAR_UNI' => 'varchar(255)', + 'VCHAR_UNI:'=> 'varchar(%d)', + 'VCHAR_CI' => 'varchar_ci', + 'VARBINARY' => 'bytea', + ), + ); + + /** + * A list of types being unsigned for better reference in some db's + * @var array + */ + var $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); + + /** + * A list of supported DBMS. We change this class to support more DBMS, the DBMS itself only need to follow some rules. + * @var array + */ + var $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); + + /** + * This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). + * This mode has no effect on some methods (inserting of data for example). This is expressed within the methods command. + */ + var $return_statements = false; + + /** + * Constructor. Set DB Object and set {@link $return_statements return_statements}. + * + * @param phpbb_dbal $db DBAL object + * @param bool $return_statements True if only statements should be returned and no SQL being executed + */ + function updater_db_tools(&$db, $return_statements = false) + { + $this->db = $db; + $this->return_statements = $return_statements; + + // Determine mapping database type + switch ($this->db->sql_layer) + { + case 'mysql': + $this->sql_layer = 'mysql_40'; + break; + + case 'mysql4': + if (version_compare($this->db->sql_server_info(true), '4.1.3', '>=')) + { + $this->sql_layer = 'mysql_41'; + } + else + { + $this->sql_layer = 'mysql_40'; + } + break; + + case 'mysqli': + $this->sql_layer = 'mysql_41'; + break; + + case 'mssql': + case 'mssql_odbc': + $this->sql_layer = 'mssql'; + break; + + default: + $this->sql_layer = $this->db->sql_layer; + break; + } + } + + /** + * Handle passed database update array. + * Expected structure... + * Key being one of the following + * change_columns: Column changes (only type, not name) + * add_columns: Add columns to a table + * drop_keys: Dropping keys + * drop_columns: Removing/Dropping columns + * add_primary_keys: adding primary keys + * add_unique_index: adding an unique index + * add_index: adding an index + * + * The values are in this format: + * {TABLE NAME} => array( + * {COLUMN NAME} => array({COLUMN TYPE}, {DEFAULT VALUE}, {OPTIONAL VARIABLES}), + * {KEY/INDEX NAME} => array({COLUMN NAMES}), + * ) + * + * For more information have a look at /develop/create_schema_files.php (only available through SVN) + */ + function perform_schema_changes($schema_changes) + { + if (empty($schema_changes)) + { + return; + } + + $statements = array(); + + // Change columns? + if (!empty($schema_changes['change_columns'])) + { + foreach ($schema_changes['change_columns'] as $table => $columns) + { + foreach ($columns as $column_name => $column_data) + { + // If the column exists we change it, else we add it ;) + if ($this->sql_column_exists($table, $column_name)) + { + $result = $this->sql_column_change($table, $column_name, $column_data); + } + else + { + $result = $this->sql_column_add($table, $column_name, $column_data); + } + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + } + + // Add columns? + if (!empty($schema_changes['add_columns'])) + { + foreach ($schema_changes['add_columns'] as $table => $columns) + { + foreach ($columns as $column_name => $column_data) + { + // Only add the column if it does not exist yet, else change it (to be consistent) + if ($this->sql_column_exists($table, $column_name)) + { + $result = $this->sql_column_change($table, $column_name, $column_data); + } + else + { + $result = $this->sql_column_add($table, $column_name, $column_data); + } + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + } + + // Remove keys? + if (!empty($schema_changes['drop_keys'])) + { + foreach ($schema_changes['drop_keys'] as $table => $indexes) + { + foreach ($indexes as $index_name) + { + $result = $this->sql_index_drop($table, $index_name); + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + } + + // Drop columns? + if (!empty($schema_changes['drop_columns'])) + { + foreach ($schema_changes['drop_columns'] as $table => $columns) + { + foreach ($columns as $column) + { + // Only remove the column if it exists... + if ($this->sql_column_exists($table, $column)) + { + $result = $this->sql_column_remove($table, $column); + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + } + } + + // Add primary keys? + if (!empty($schema_changes['add_primary_keys'])) + { + foreach ($schema_changes['add_primary_keys'] as $table => $columns) + { + $result = $this->sql_create_primary_key($table, $columns); + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + + // Add unqiue indexes? + if (!empty($schema_changes['add_unique_index'])) + { + foreach ($schema_changes['add_unique_index'] as $table => $index_array) + { + foreach ($index_array as $index_name => $column) + { + $result = $this->sql_create_unique_index($table, $index_name, $column); + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + } + + // Add indexes? + if (!empty($schema_changes['add_index'])) + { + foreach ($schema_changes['add_index'] as $table => $index_array) + { + foreach ($index_array as $index_name => $column) + { + $result = $this->sql_create_index($table, $index_name, $column); + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + } + + if ($this->return_statements) + { + return $statements; + } + } + + /** + * Check if a specified column exist + * + * @param string $table Table to check the column at + * @param string $column_name The column to check + * + * @return bool True if column exists, else false + */ + function sql_column_exists($table, $column_name) + { + switch ($this->sql_layer) + { + case 'mysql_40': + case 'mysql_41': + + $sql = "SHOW COLUMNS FROM $table"; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + // lower case just in case + if (strtolower($row['Field']) == $column_name) + { + $this->db->sql_freeresult($result); + return true; + } + } + $this->db->sql_freeresult($result); + return false; + break; + + // PostgreSQL has a way of doing this in a much simpler way but would + // not allow us to support all versions of PostgreSQL + case 'postgres': + $sql = "SELECT a.attname + FROM pg_class c, pg_attribute a + WHERE c.relname = '{$table}' + AND a.attnum > 0 + AND a.attrelid = c.oid"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + // lower case just in case + if (strtolower($row['attname']) == $column_name) + { + $this->db->sql_freeresult($result); + return true; + } + } + $this->db->sql_freeresult($result); + + return false; + break; + + // same deal with PostgreSQL, we must perform more complex operations than + // we technically could + case 'mssql': + $sql = "SELECT c.name + FROM syscolumns c + LEFT JOIN sysobjects o ON c.id = o.id + WHERE o.name = '{$table}'"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + // lower case just in case + if (strtolower($row['name']) == $column_name) + { + $this->db->sql_freeresult($result); + return true; + } + } + $this->db->sql_freeresult($result); + return false; + break; + + case 'oracle': + $sql = "SELECT column_name + FROM user_tab_columns + WHERE table_name = '{$table}'"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + // lower case just in case + if (strtolower($row['column_name']) == $column_name) + { + $this->db->sql_freeresult($result); + return true; + } + } + $this->db->sql_freeresult($result); + return false; + break; + + case 'firebird': + $sql = "SELECT RDB\$FIELD_NAME as FNAME + FROM RDB\$RELATION_FIELDS + WHERE RDB\$RELATION_NAME = '{$table}'"; + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + // lower case just in case + if (strtolower($row['fname']) == $column_name) + { + $this->db->sql_freeresult($result); + return true; + } + } + $this->db->sql_freeresult($result); + return false; + break; + + // ugh, SQLite + case 'sqlite': + $sql = "SELECT sql + FROM sqlite_master + WHERE type = 'table' + AND name = '{$table}'"; + $result = $this->db->sql_query($sql); + + if (!$result) + { + return false; + } + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + preg_match('#\((.*)\)#s', $row['sql'], $matches); + + $cols = trim($matches[1]); + $col_array = preg_split('/,(?![\s\w]+\))/m', $cols); + + foreach ($col_array as $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if ($entities[0] == 'PRIMARY') + { + continue; + } + + if (strtolower($entities[0]) == $column_name) + { + return true; + } + } + return false; + break; + } + } + + /** + * Private method for performing sql statements (either execute them or return them) + * @access private + */ + function _sql_run_sql($statements) + { + if ($this->return_statements) + { + return $statements; + } + + // We could add error handling here... + foreach ($statements as $sql) + { + if ($sql === 'begin') + { + $this->db->sql_transaction('begin'); + } + else if ($sql === 'commit') + { + $this->db->sql_transaction('commit'); + } + else + { + $this->db->sql_query($sql); + } + } + + return true; + } + + /** + * Function to prepare some column information for better usage + * @access private + */ + function sql_prepare_column_data($table_name, $column_name, $column_data) + { + // Get type + if (strpos($column_data[0], ':') !== false) + { + list($orig_column_type, $column_length) = explode(':', $column_data[0]); + if (!is_array($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'])) + { + $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'], $column_length); + } + else + { + if (isset($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'])) + { + switch ($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'][0]) + { + case 'div': + $column_length /= $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['rule'][1]; + $column_length = ceil($column_length); + $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'][0], $column_length); + break; + } + } + + if (isset($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'])) + { + switch ($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][0]) + { + case 'mult': + $column_length *= $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][1]; + if ($column_length > $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][2]) + { + $column_type = $this->dbms_type_map[$this->sql_layer][$orig_column_type . ':']['limit'][3]; + } + else + { + $column_type = sprintf($this->dbms_type_map[$this->sql_layer][$orig_column_type . ':'][0], $column_length); + } + break; + } + } + } + $orig_column_type .= ':'; + } + else + { + $orig_column_type = $column_data[0]; + $column_type = $this->dbms_type_map[$this->sql_layer][$column_data[0]]; + } + + // Adjust default value if db-dependant specified + if (is_array($column_data[1])) + { + $column_data[1] = (isset($column_data[1][$this->sql_layer])) ? $column_data[1][$this->sql_layer] : $column_data[1]['default']; + } + + $sql = ''; + + $return_array = array(); + + switch ($this->sql_layer) + { + case 'firebird': + $sql .= " {$column_type} "; + + if (!is_null($column_data[1])) + { + $sql .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; + } + + $sql .= 'NOT NULL'; + + // This is a UNICODE column and thus should be given it's fair share + if (preg_match('/^X?STEXT_UNI|VCHAR_(CI|UNI:?)/', $column_data[0])) + { + $sql .= ' COLLATE UNICODE'; + } + + $return_array['auto_increment'] = false; + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $return_array['auto_increment'] = true; + } + + break; + + case 'mssql': + $sql .= " {$column_type} "; + $sql_default = " {$column_type} "; + + // For adding columns we need the default definition + if (!is_null($column_data[1])) + { + // For hexadecimal values do not use single quotes + if (strpos($column_data[1], '0x') === 0) + { + $sql_default .= 'DEFAULT (' . $column_data[1] . ') '; + } + else + { + $sql_default .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; + } + } + + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { +// $sql .= 'IDENTITY (1, 1) '; + $sql_default .= 'IDENTITY (1, 1) '; + } + + $return_array['textimage'] = $column_type === '[text]'; + + $sql .= 'NOT NULL'; + $sql_default .= 'NOT NULL'; + + $return_array['column_type_sql_default'] = $sql_default; + + break; + + case 'mysql_40': + case 'mysql_41': + $sql .= " {$column_type} "; + + // For hexadecimal values do not use single quotes + if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob') + { + $sql .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' "; + } + $sql .= 'NOT NULL'; + + if (isset($column_data[2])) + { + if ($column_data[2] == 'auto_increment') + { + $sql .= ' auto_increment'; + } + else if ($this->sql_layer === 'mysql_41' && $column_data[2] == 'true_sort') + { + $sql .= ' COLLATE utf8_unicode_ci'; + } + } + + break; + + case 'oracle': + $sql .= " {$column_type} "; + $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : ''; + + // In Oracle empty strings ('') are treated as NULL. + // Therefore in oracle we allow NULL's for all DEFAULT '' entries + // Oracle does not like setting NOT NULL on a column that is already NOT NULL (this happens only on number fields) + if (!preg_match('/number/i', $column_type)) + { + $sql .= ($column_data[1] === '') ? '' : 'NOT NULL'; + } + + $return_array['auto_increment'] = false; + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $return_array['auto_increment'] = true; + } + + break; + + case 'postgres': + $return_array['column_type'] = $column_type; + + $sql .= " {$column_type} "; + + $return_array['auto_increment'] = false; + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $default_val = "nextval('{$table_name}_seq')"; + $return_array['auto_increment'] = true; + } + else if (!is_null($column_data[1])) + { + $default_val = "'" . $column_data[1] . "'"; + $return_array['null'] = 'NOT NULL'; + $sql .= 'NOT NULL '; + } + + $return_array['default'] = $default_val; + + $sql .= "DEFAULT {$default_val}"; + + // Unsigned? Then add a CHECK contraint + if (in_array($orig_column_type, $this->unsigned_types)) + { + $return_array['constraint'] = "CHECK ({$column_name} >= 0)"; + $sql .= " CHECK ({$column_name} >= 0)"; + } + + break; + + case 'sqlite': + $return_array['primary_key_set'] = false; + if (isset($column_data[2]) && $column_data[2] == 'auto_increment') + { + $sql .= ' INTEGER PRIMARY KEY'; + $return_array['primary_key_set'] = true; + } + else + { + $sql .= ' ' . $column_type; + } + + $sql .= ' NOT NULL '; + $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : ''; + + break; + } + + $return_array['column_type_sql'] = $sql; + + return $return_array; + } + + /** + * Add new column + */ + function sql_column_add($table_name, $column_name, $column_data) + { + $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); + $statements = array(); + + switch ($this->sql_layer) + { + case 'firebird': + $statements[] = 'ALTER TABLE "' . $table_name . '" ADD "' . $column_name . '" ' . $column_data['column_type_sql']; + break; + + case 'mssql': + $statements[] = 'ALTER TABLE [' . $table_name . '] ADD [' . $column_name . '] ' . $column_data['column_type_sql_default']; + break; + + case 'mysql_40': + case 'mysql_41': + $statements[] = 'ALTER TABLE `' . $table_name . '` ADD COLUMN `' . $column_name . '` ' . $column_data['column_type_sql']; + break; + + case 'oracle': + $statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql']; + break; + + case 'postgres': + $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; + break; + + case 'sqlite': + if (version_compare(sqlite_libversion(), '3.0') == -1) + { + $sql = "SELECT sql + FROM sqlite_master + WHERE type = 'table' + AND name = '{$table_name}' + ORDER BY type DESC, name;"; + $result = $this->db->sql_query($sql); + + if (!$result) + { + break; + } + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $statements[] = 'begin'; + + // Create a backup table and populate it, destroy the existing one + $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); + $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; + $statements[] = 'DROP TABLE ' . $table_name; + + preg_match('#\((.*)\)#s', $row['sql'], $matches); + + $new_table_cols = trim($matches[1]); + $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); + $column_list = array(); + + foreach ($old_table_cols as $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if ($entities[0] == 'PRIMARY') + { + continue; + } + $column_list[] = $entities[0]; + } + + $columns = implode(',', $column_list); + + $new_table_cols = $column_name . ' ' . $column_data['column_type_sql'] . ',' . $new_table_cols; + + // create a new table and fill it up. destroy the temp one + $statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');'; + $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; + $statements[] = 'DROP TABLE ' . $table_name . '_temp'; + + $statements[] = 'commit'; + } + else + { + $statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' [' . $column_data['column_type_sql'] . ']'; + } + break; + } + + return $this->_sql_run_sql($statements); + } + + /** + * Drop column + */ + function sql_column_remove($table_name, $column_name) + { + $statements = array(); + + switch ($this->sql_layer) + { + case 'firebird': + $statements[] = 'ALTER TABLE "' . $table_name . '" DROP "' . $column_name . '"'; + break; + + case 'mssql': + $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; + break; + + case 'mysql_40': + case 'mysql_41': + $statements[] = 'ALTER TABLE `' . $table_name . '` DROP COLUMN `' . $column_name . '`'; + break; + + case 'oracle': + $statements[] = 'ALTER TABLE ' . $table_name . ' DROP ' . $column_name; + break; + + case 'postgres': + $statements[] = 'ALTER TABLE ' . $table_name . ' DROP COLUMN "' . $column_name . '"'; + break; + + case 'sqlite': + if (version_compare(sqlite_libversion(), '3.0') == -1) + { + $sql = "SELECT sql + FROM sqlite_master + WHERE type = 'table' + AND name = '{$table_name}' + ORDER BY type DESC, name;"; + $result = $this->db->sql_query($sql); + + if (!$result) + { + break; + } + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $statements[] = 'begin'; + + // Create a backup table and populate it, destroy the existing one + $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); + $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; + $statements[] = 'DROP TABLE ' . $table_name; + + preg_match('#\((.*)\)#s', $row['sql'], $matches); + + $new_table_cols = trim($matches[1]); + $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); + $column_list = array(); + + foreach ($old_table_cols as $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if ($entities[0] == 'PRIMARY' || $entities[0] === $column_name) + { + continue; + } + $column_list[] = $entities[0]; + } + + $columns = implode(',', $column_list); + + $new_table_cols = $new_table_cols = preg_replace('/' . $column_name . '[^,]+(?:,|$)/m', '', $new_table_cols); + + // create a new table and fill it up. destroy the temp one + $statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');'; + $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; + $statements[] = 'DROP TABLE ' . $table_name . '_temp'; + + $statements[] = 'commit'; + } + else + { + $statements[] = 'ALTER TABLE ' . $table_name . ' DROP COLUMN ' . $column_name; + } + break; + } + + return $this->_sql_run_sql($statements); + } + + /** + * Drop Index + */ + function sql_index_drop($table_name, $index_name) + { + $statements = array(); + + switch ($this->sql_layer) + { + case 'mssql': + $statements[] = 'DROP INDEX ' . $table_name . '.' . $index_name; + break; + + case 'mysql_40': + case 'mysql_41': + $statements[] = 'DROP INDEX ' . $index_name . ' ON ' . $table_name; + break; + + case 'firebird': + case 'oracle': + case 'postgres': + case 'sqlite': + $statements[] = 'DROP INDEX ' . $table_name . '_' . $index_name; + break; + } + + return $this->_sql_run_sql($statements); + } + + /** + * Add primary key + */ + function sql_create_primary_key($table_name, $column) + { + $statements = array(); + + switch ($this->sql_layer) + { + case 'firebird': + case 'postgres': + case 'mysql_40': + case 'mysql_41': + $statements[] = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; + break; + + case 'mssql': + $sql = "ALTER TABLE [{$table_name}] WITH NOCHECK ADD "; + $sql .= "CONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED ("; + $sql .= '[' . implode("],\n\t\t[", $column) . ']'; + $sql .= ') ON [PRIMARY]'; + + $statements[] = $sql; + break; + + case 'oracle': + $statements[] = 'ALTER TABLE ' . $table_name . 'add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')'; + break; + + case 'sqlite': + $sql = "SELECT sql + FROM sqlite_master + WHERE type = 'table' + AND name = '{$table_name}' + ORDER BY type DESC, name;"; + $result = $this->db->sql_query($sql); + + if (!$result) + { + break; + } + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $statements[] = 'begin'; + + // Create a backup table and populate it, destroy the existing one + $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); + $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; + $statements[] = 'DROP TABLE ' . $table_name; + + preg_match('#\((.*)\)#s', $row['sql'], $matches); + + $new_table_cols = trim($matches[1]); + $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); + $column_list = array(); + + foreach ($old_table_cols as $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if ($entities[0] == 'PRIMARY') + { + continue; + } + $column_list[] = $entities[0]; + } + + $columns = implode(',', $column_list); + + // create a new table and fill it up. destroy the temp one + $statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ', PRIMARY KEY (' . implode(', ', $column) . '));'; + $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; + $statements[] = 'DROP TABLE ' . $table_name . '_temp'; + + $statements[] = 'commit'; + break; + } + + return $this->_sql_run_sql($statements); + } + + /** + * Add unique index + */ + function sql_create_unique_index($table_name, $index_name, $column) + { + $statements = array(); + + switch ($this->sql_layer) + { + case 'firebird': + case 'postgres': + case 'oracle': + case 'sqlite': + $statements[] = 'CREATE UNIQUE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + break; + + case 'mysql_40': + case 'mysql_41': + $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + break; + + case 'mssql': + $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; + break; + } + + return $this->_sql_run_sql($statements); + } + + /** + * Add index + */ + function sql_create_index($table_name, $index_name, $column) + { + $statements = array(); + + switch ($this->sql_layer) + { + case 'firebird': + case 'postgres': + case 'oracle': + case 'sqlite': + $statements[] = 'CREATE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + break; + + case 'mysql_40': + case 'mysql_41': + $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; + break; + + case 'mssql': + $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; + break; + } + + return $this->_sql_run_sql($statements); + } + + /** + * Change column type (not name!) + */ + function sql_column_change($table_name, $column_name, $column_data) + { + $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); + $statements = array(); + + switch ($this->sql_layer) + { + case 'firebird': + // Change type... + $statements[] = 'ALTER TABLE "' . $table_name . '" ALTER COLUMN "' . $column_name . '" TYPE ' . ' ' . $column_data['column_type_sql']; + break; + + case 'mssql': + $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; + break; + + case 'mysql_40': + case 'mysql_41': + $statements[] = 'ALTER TABLE `' . $table_name . '` CHANGE `' . $column_name . '` `' . $column_name . '` ' . $column_data['column_type_sql']; + break; + + case 'oracle': + $statements[] = 'ALTER TABLE ' . $table_name . ' MODIFY ' . $column_name . ' ' . $column_data['column_type_sql']; + break; + + case 'postgres': + $sql = 'ALTER TABLE ' . $table_name . ' '; + + $sql_array = array(); + $sql_array[] = 'ALTER COLUMN ' . $column_name . ' TYPE ' . $column_data['column_type']; + + if (isset($column_data['null'])) + { + if ($column_data['null'] == 'NOT NULL') + { + $sql_array[] = 'ALTER COLUMN ' . $column_name . ' SET NOT NULL'; + } + else if ($column_data['null'] == 'NULL') + { + $sql_array[] = 'ALTER COLUMN ' . $column_name . ' DROP NOT NULL'; + } + } + + if (isset($column_data['default'])) + { + $sql_array[] = 'ALTER COLUMN ' . $column_name . ' SET DEFAULT ' . $column_data['default']; + } + + // we don't want to double up on constraints if we change different number data types + if (isset($column_data['constraint'])) + { + $constraint_sql = "SELECT consrc as constraint_data + FROM pg_constraint, pg_class bc + WHERE conrelid = bc.oid + AND bc.relname = '{$table_name}' + AND NOT EXISTS ( + SELECT * + FROM pg_constraint as c, pg_inherits as i + WHERE i.inhrelid = pg_constraint.conrelid + AND c.conname = pg_constraint.conname + AND c.consrc = pg_constraint.consrc + AND c.conrelid = i.inhparent + )"; + + $constraint_exists = false; + + $result = $this->db->sql_query($constraint_sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (trim($row['constraint_data']) == trim($column_data['constraint'])) + { + $constraint_exists = true; + break; + } + } + $this->db->sql_freeresult($result); + + if (!$constraint_exists) + { + $sql_array[] = 'ADD ' . $column_data['constraint']; + } + } + + $sql .= implode(', ', $sql_array); + + $statements[] = $sql; + break; + + case 'sqlite': + + $sql = "SELECT sql + FROM sqlite_master + WHERE type = 'table' + AND name = '{$table_name}' + ORDER BY type DESC, name;"; + $result = $this->db->sql_query($sql); + + if (!$result) + { + break; + } + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $statements[] = 'begin'; + + // Create a temp table and populate it, destroy the existing one + $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); + $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; + $statements[] = 'DROP TABLE ' . $table_name; + + preg_match('#\((.*)\)#s', $row['sql'], $matches); + + $new_table_cols = trim($matches[1]); + $old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols); + $column_list = array(); + + foreach ($old_table_cols as $key => $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + $column_list[] = $entities[0]; + if ($entities[0] == $column_name) + { + $old_table_cols[$key] = $column_name . ' ' . $column_data['column_type_sql']; + } + } + + $columns = implode(',', $column_list); + + // create a new table and fill it up. destroy the temp one + $statements[] = 'CREATE TABLE ' . $table_name . ' (' . implode(',', $old_table_cols) . ');'; + $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; + $statements[] = 'DROP TABLE ' . $table_name . '_temp'; + + $statements[] = 'commit'; + + break; + } + + return $this->_sql_run_sql($statements); + } +} + ?> \ No newline at end of file -- cgit v1.2.1 From 1fae177b9a424db90c33d9cde373d360ebeac878 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 30 Mar 2009 10:44:18 +0000 Subject: Fix bug in postgresql db layer for LIMIT ALL clauses (reported by JRSweets) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9412 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0639f41b35..42af092d8b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -947,7 +947,11 @@ function change_database_data(&$no_updates, $version) FROM ' . ACL_OPTIONS_TABLE . " WHERE auth_option = '" . $db->sql_escape($option) . "' ORDER BY auth_option_id DESC"; - $result = $db->sql_query_limit($sql, 0, 1); + // 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)) { -- cgit v1.2.1 From cda9e5e9ec0dfe9c3e0a04809ffc5d0099020046 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 11 Apr 2009 09:11:08 +0000 Subject: a language alteration for captchas. Added min/max captcha chars constants and changed the length from 5-8 to 4-7 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9437 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 42af092d8b..18a1162c41 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -11,7 +11,7 @@ $updates_to_version = '3.0.5-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. -$debug_from_version = false; +$debug_from_version = '3.0.4'; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) -- cgit v1.2.1 From 4d9b106db2ccc6e15b4afd3fc2e69cf37fae81cf Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 11 Apr 2009 11:09:45 +0000 Subject: New search option: Maximum number of words allowed to search for. (the more words the more database load) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9438 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 18a1162c41..e164e5442c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -11,7 +11,7 @@ $updates_to_version = '3.0.5-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. -$debug_from_version = '3.0.4'; +$debug_from_version = false; // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -896,6 +896,9 @@ function change_database_data(&$no_updates, $version) set_config('confirm_refresh', 1); + // Maximum number of keywords + set_config('max_num_search_keywords', 10); + // Hash old MD5 passwords $sql = 'SELECT user_id, user_password FROM ' . USERS_TABLE . ' -- cgit v1.2.1 From 83ed73c9b4f0fc1313d239792426f80bc1690887 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 17 Apr 2009 13:16:20 +0000 Subject: fix forum_style column. :/ Bug #38905 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9455 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e164e5442c..4fda30463f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -655,7 +655,7 @@ function database_update_info() 'template_id' => array('UINT', 0), ), FORUMS_TABLE => array( - 'forum_style' => array('USINT', 0), + 'forum_style' => array('UINT', 0), ), USERS_TABLE => array( 'user_style' => array('UINT', 0), @@ -667,7 +667,13 @@ function database_update_info() '3.0.4-RC1' => array(), // Changes from 3.0.4 to 3.0.5-dev - '3.0.4' => array(), + '3.0.4' => array( + 'change_columns' => array( + FORUMS_TABLE => array( + 'forum_style' => array('UINT', 0), + ), + ), + ), ); } -- cgit v1.2.1 From ab122983f740c7dbd1e962bb8306033ad4f3c360 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 28 Apr 2009 11:18:02 +0000 Subject: Fix column handling in db updater, custom profile fields an db tools for firebird DBMS (Bug #44555) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9492 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4fda30463f..90c46be06b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1883,7 +1883,7 @@ class updater_db_tools switch ($this->sql_layer) { case 'firebird': - $statements[] = 'ALTER TABLE "' . $table_name . '" ADD "' . $column_name . '" ' . $column_data['column_type_sql']; + $statements[] = 'ALTER TABLE ' . $table_name . ' ADD "' . strtoupper($column_name) . '" ' . $column_data['column_type_sql']; break; case 'mssql': @@ -1975,7 +1975,7 @@ class updater_db_tools switch ($this->sql_layer) { case 'firebird': - $statements[] = 'ALTER TABLE "' . $table_name . '" DROP "' . $column_name . '"'; + $statements[] = 'ALTER TABLE ' . $table_name . ' DROP "' . strtoupper($column_name) . '"'; break; case 'mssql': @@ -2238,7 +2238,7 @@ class updater_db_tools { case 'firebird': // Change type... - $statements[] = 'ALTER TABLE "' . $table_name . '" ALTER COLUMN "' . $column_name . '" TYPE ' . ' ' . $column_data['column_type_sql']; + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql']; break; case 'mssql': -- cgit v1.2.1 From 2e4174da2a6789aa0125ba214588deaa4c635d0f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 1 May 2009 09:59:57 +0000 Subject: make search_indexing_state dynamic. This is related to bug #44535 - although i think we only fix the symptoms and not the cause. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9502 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 90c46be06b..e79ea717cf 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -896,6 +896,7 @@ function change_database_data(&$no_updates, $version) // Changes from 3.0.4 to 3.0.5-dev 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); @@ -905,6 +906,12 @@ function change_database_data(&$no_updates, $version) // 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 . ' -- cgit v1.2.1 From 864c63406078cc2b4a7ea2e256598c3c5a86f265 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 1 May 2009 10:06:41 +0000 Subject: Set new version... git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9503 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e79ea717cf..ee28799694 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.5-dev'; +$updates_to_version = '3.0.5-RC1'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -666,7 +666,7 @@ function database_update_info() // Changes from 3.0.4-RC1 to 3.0.4 '3.0.4-RC1' => array(), - // Changes from 3.0.4 to 3.0.5-dev + // Changes from 3.0.4 to 3.0.5-RC1 '3.0.4' => array( 'change_columns' => array( FORUMS_TABLE => array( @@ -893,7 +893,7 @@ function change_database_data(&$no_updates, $version) case '3.0.4-RC1': break; - // Changes from 3.0.4 to 3.0.5-dev + // Changes from 3.0.4 to 3.0.5-RC1 case '3.0.4': // Captcha config variables -- cgit v1.2.1 From 6c3532761bbbcb26cd4186e8b204d62a7391d331 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 6 May 2009 08:38:30 +0000 Subject: slight change for 3.0.5 for updating. - only return auth options having 2 or more columns (does not change the outcome, the script works fine) - purge the theme after a successful update the easy way to let style.php do the job git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9510 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ee28799694..60a20920bb 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -943,7 +943,7 @@ function change_database_data(&$no_updates, $version) $sql = 'SELECT auth_option FROM ' . ACL_OPTIONS_TABLE . ' GROUP BY auth_option - HAVING COUNT(*) >= 1'; + HAVING COUNT(*) >= 2'; $result = $db->sql_query($sql); $auth_options = array(); -- cgit v1.2.1 From 4a36fe5264ed2a2b2073ec1bd3c67f6b0d208cc2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 31 May 2009 10:46:40 +0000 Subject: update version number git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9521 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 60a20920bb..c66ac859cf 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.5-RC1'; +$updates_to_version = '3.0.5'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -674,6 +674,9 @@ function database_update_info() ), ), ), + + // No changes from 3.0.5-RC1 to 3.0.5 + '3.0.5-RC1' => array(), ); } @@ -1005,6 +1008,10 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // No changes from 3.0.5-RC1 to 3.0.5 + case '3.0.5-RC1': + break; } } -- cgit v1.2.1 From b776d02682492077a4fafd8835d7c4a17e50762d Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 2 Jun 2009 14:12:23 +0000 Subject: Okay, a first ci of the new captcha plugins. We'll add dynamic template includes later, as well as documentation on how to use this. I'm prepared to get yelled at for bugs (oh, I know that there are plenty); but please blame spammers for broken styles and MODs. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9524 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c66ac859cf..fe855496e4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.5'; +$updates_to_version = '3.0.6-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -677,6 +677,9 @@ function database_update_info() // No changes from 3.0.5-RC1 to 3.0.5 '3.0.5-RC1' => array(), + + // No changes from 3.0.5 + '3.0.5' => array(), ); } @@ -1012,6 +1015,14 @@ function change_database_data(&$no_updates, $version) // No changes from 3.0.5-RC1 to 3.0.5 case '3.0.5-RC1': break; + + + + case '3.0.5': + // TODO: smarter detection here; problem without GD. + set_config('captcha_plugin', 'phpbb_captcha_nogd'); + + break; } } -- cgit v1.2.1 From a539fca62b10f53a5f5dadf07f9ab07340fdabf9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 7 Jun 2009 11:34:01 +0000 Subject: some corrections, only very minor things. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9554 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fe855496e4..a77896c470 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -677,7 +677,7 @@ function database_update_info() // No changes from 3.0.5-RC1 to 3.0.5 '3.0.5-RC1' => array(), - + // No changes from 3.0.5 '3.0.5' => array(), ); @@ -1015,13 +1015,12 @@ function change_database_data(&$no_updates, $version) // No changes from 3.0.5-RC1 to 3.0.5 case '3.0.5-RC1': break; - - - + case '3.0.5': // TODO: smarter detection here; problem without GD. set_config('captcha_plugin', 'phpbb_captcha_nogd'); + $no_updates = false; break; } } -- cgit v1.2.1 From 9f21f1ab5e2b70da18459ef26c14a2372bc0eb76 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 8 Jun 2009 12:36:26 +0000 Subject: Fix bug #44665 - Add index on log_time to the log table to prevent slowdown on boards with many log entries. Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9564 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a77896c470..171a8f1fc6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -678,8 +678,14 @@ function database_update_info() // No changes from 3.0.5-RC1 to 3.0.5 '3.0.5-RC1' => array(), - // No changes from 3.0.5 - '3.0.5' => array(), + // Changes from 3.0.5 + '3.0.5' => array( + 'add_index' => array( + LOG_TABLE => array( + 'log_time' => array('log_time'), + ), + ), + ), ); } -- cgit v1.2.1 From 863d7a7614a09dac545d3c3201e67c3beddb3960 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 12 Jun 2009 14:41:03 +0000 Subject: First ATOM Feed commit/integration - Idea and original RSS Feed 2.0 MOD (Version 1.0.8/9) by leviatan21 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9575 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 64 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 171a8f1fc6..bb48b57a13 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1022,9 +1022,69 @@ function change_database_data(&$no_updates, $version) case '3.0.5-RC1': break; + // Changes from 3.0.5 to 3.0.6-RC1 case '3.0.5': - // TODO: smarter detection here; problem without GD. - set_config('captcha_plugin', 'phpbb_captcha_nogd'); + // 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_news_id', ''); + + set_config('feed_item_statistics', '1'); + set_config('feed_exclude_id', ''); + + include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); + + $_module = new acp_modules(); + + // Set the module class + $_module->module_class = 'acp'; + + $sql = 'SELECT module_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_BOARD_CONFIGURATION' + AND module_mode = '' + AND module_basename = ''"; + $result = $db->sql_query($sql); + $category_id = (int) $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + + if ($category_id) + { + $module_data = array( + 'module_basename' => 'board', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => $category_id, + 'module_class' => 'acp', + 'module_langname' => 'ACP_FEED_SETTINGS', + 'module_mode' => 'feed', + 'module_auth' => 'acl_a_board', + ); + + $_module->update_module_data($module_data, true); + } + + $_module->remove_cache_file(); $no_updates = false; break; -- cgit v1.2.1 From d843dbd046fa427d00d30ef06558043e46c6fc98 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 13 Jun 2009 14:48:45 +0000 Subject: Fix sql_column_exists for oracle (oracle uses uppercase table names) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9583 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index bb48b57a13..992db93452 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -912,7 +912,6 @@ function change_database_data(&$no_updates, $version) 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 @@ -949,6 +948,7 @@ function change_database_data(&$no_updates, $version) 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 @@ -1637,7 +1637,7 @@ class updater_db_tools case 'oracle': $sql = "SELECT column_name FROM user_tab_columns - WHERE table_name = '{$table}'"; + WHERE LOWER(table_name) = '" . strtolower($table) . "'"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { -- cgit v1.2.1 From 8d4ddc3b236a194b7f31e631e77366cd4f4adfd0 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 13 Jun 2009 14:55:30 +0000 Subject: erm, we need to check if the feed module is already there git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9584 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 992db93452..948087dd3b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1070,18 +1070,34 @@ function change_database_data(&$no_updates, $version) if ($category_id) { - $module_data = array( - 'module_basename' => 'board', - 'module_enabled' => 1, - 'module_display' => 1, - 'parent_id' => $category_id, - 'module_class' => 'acp', - 'module_langname' => 'ACP_FEED_SETTINGS', - 'module_mode' => 'feed', - 'module_auth' => 'acl_a_board', - ); + // Check if we actually need to add the feed module or if it is already added. ;) + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'board' + AND module_class = 'acp' + AND module_langname = 'ACP_FEED_SETTINGS' + AND module_mode = 'feed' + AND module_auth = 'acl_a_board' + AND parent_id = {$category_id}"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + $module_data = array( + 'module_basename' => 'board', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => $category_id, + 'module_class' => 'acp', + 'module_langname' => 'ACP_FEED_SETTINGS', + 'module_mode' => 'feed', + 'module_auth' => 'acl_a_board', + ); - $_module->update_module_data($module_data, true); + $_module->update_module_data($module_data, true); + } } $_module->remove_cache_file(); -- cgit v1.2.1 From e69fe56634225d771d4d47c2151d9828b1be2b5d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 13 Jun 2009 16:04:54 +0000 Subject: - fix sql_column_exists for firebird (had same problem as oracle) - fix sql_column_change for firebird (interbase6 only supports TYPE and SET DEFAULT, but not the same syntax ass ADD COLUMN) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9586 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 948087dd3b..7f1edf2e28 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -497,7 +497,7 @@ function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { $errored = true; $error_ary['sql'][] = $db->sql_error_sql; - $error_ary['error_code'][] = $db->_sql_error(); + $error_ary['error_code'][] = $db->sql_error_returned; } $db->sql_return_on_error(false); @@ -1671,7 +1671,7 @@ class updater_db_tools case 'firebird': $sql = "SELECT RDB\$FIELD_NAME as FNAME FROM RDB\$RELATION_FIELDS - WHERE RDB\$RELATION_NAME = '{$table}'"; + WHERE RDB\$RELATION_NAME = '" . strtoupper($table) . "'"; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { @@ -1824,10 +1824,12 @@ class updater_db_tools { case 'firebird': $sql .= " {$column_type} "; + $return_array['column_type_sql_type'] = " {$column_type} "; if (!is_null($column_data[1])) { $sql .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; + $return_array['column_type_sql_default'] = ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' '; } $sql .= 'NOT NULL'; @@ -2344,7 +2346,15 @@ class updater_db_tools { case 'firebird': // Change type... - $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql']; + if (!empty($column_data['column_type_sql_default'])) + { + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" SET DEFAULT ' . ' ' . $column_data['column_type_sql_default']; + } + else + { + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql']; + } break; case 'mssql': -- cgit v1.2.1 From d7d96223e7bae7cd60b13c6e7896d95838c3633c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 19 Jun 2009 09:51:50 +0000 Subject: - Display coloured usernames in ACP groups management screens - Changed behaviour of group_create() function to support specifying additional group columns - New groups option to excempt group leaders from group permissions git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9625 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7f1edf2e28..6f7216f82b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -13,6 +13,9 @@ $updates_to_version = '3.0.6-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; +// Which oldest version does this updater supports? +$oldest_from_version = '3.0.0'; + // Return if we "just include it" to find out for which version the database update is responsible for if (defined('IN_PHPBB') && defined('IN_INSTALL')) { @@ -685,6 +688,11 @@ function database_update_info() 'log_time' => array('log_time'), ), ), + 'add_columns' => array( + GROUPS_TABLE => array( + 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), + ), + ), ), ); } @@ -1991,23 +1999,28 @@ class updater_db_tools switch ($this->sql_layer) { case 'firebird': + // Does not support AFTER statement, only POSITION (and there you need the column position) $statements[] = 'ALTER TABLE ' . $table_name . ' ADD "' . strtoupper($column_name) . '" ' . $column_data['column_type_sql']; break; case 'mssql': + // Does not support AFTER, only through temporary table $statements[] = 'ALTER TABLE [' . $table_name . '] ADD [' . $column_name . '] ' . $column_data['column_type_sql_default']; break; case 'mysql_40': case 'mysql_41': - $statements[] = 'ALTER TABLE `' . $table_name . '` ADD COLUMN `' . $column_name . '` ' . $column_data['column_type_sql']; + $after = (!empty($column_data['after'])) ? ' AFTER ' . $column_data['after'] : ''; + $statements[] = 'ALTER TABLE `' . $table_name . '` ADD COLUMN `' . $column_name . '` ' . $column_data['column_type_sql'] . $after; break; case 'oracle': + // Does not support AFTER, only through temporary table $statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql']; break; case 'postgres': + // Does not support AFTER, only through temporary table $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; break; -- cgit v1.2.1 From 5d9cf2aa41c61dd35114223006c5e16c104c5a2b Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 19 Jun 2009 12:31:28 +0000 Subject: Make captchas stricter by oly having one entry per session; fix a bug in ucp_register that caused three captcha instances to be generated. Non-MySQL databases and garbage collecting needs extensive testing. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9626 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 6f7216f82b..150ef20ca1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -683,6 +683,11 @@ function database_update_info() // Changes from 3.0.5 '3.0.5' => array( + 'add_columns' => array( + CONFIRM_TABLE => array( + 'attempts' => array('UINT', 0), + ), + ), 'add_index' => array( LOG_TABLE => array( 'log_time' => array('log_time'), -- cgit v1.2.1 From d85a5ad036b2088fe742de29d9464678d2e19e23 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 19 Jun 2009 22:03:19 +0000 Subject: Fix bug #46785 - Hide avatars if type disabled and give global option to turn on/off Authorised by: acydburn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9632 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 150ef20ca1..3848657809 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1115,6 +1115,15 @@ function change_database_data(&$no_updates, $version) $_module->remove_cache_file(); + if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) + { + set_config('allow_avatar', '1'); + } + else + { + set_config('allow_avatar', '0'); + } + $no_updates = false; break; } -- cgit v1.2.1 From 433de350c0fa2e1e09c23e6f5f29f118222d2df8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 20 Jun 2009 18:45:16 +0000 Subject: - [Feature] New "Newly Registered Users" group for assigning permissions to newly registered users. They will be removed from this group once they reach a defineable amount of posts. - [Feature] Ability to define if the "Newly Registered Users" group will be assigned as the default group to newly registered users. As a coincidence also Bug #46535 got fixed. Additionally the error message displayed with trigger_error() if accessing the private message tab in the ucp is now displayed inline in addition to a slightly different message for newly registered users to let them know that access permissions may be lifted over time. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9636 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 141 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 136 insertions(+), 5 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3848657809..44bcf2a112 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -687,17 +687,18 @@ function database_update_info() CONFIRM_TABLE => array( 'attempts' => array('UINT', 0), ), + USERS_TABLE => array( + 'user_new' => array('BOOL', 1), + ), + GROUPS_TABLE => array( + 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), + ), ), 'add_index' => array( LOG_TABLE => array( 'log_time' => array('log_time'), ), ), - 'add_columns' => array( - GROUPS_TABLE => array( - 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), - ), - ), ), ); } @@ -1115,6 +1116,136 @@ function change_database_data(&$no_updates, $version) $_module->remove_cache_file(); + // 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) + $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 ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) { set_config('allow_avatar', '1'); -- cgit v1.2.1 From c32f49679f635175d43de7264ee09782c56c628e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 23 Jun 2009 10:48:53 +0000 Subject: - add options for quick reply (forum-based and board-wide) - add option for minimum post chars (which is a required setting for quick reply, therefore we introduce it here) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9656 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 44bcf2a112..c3f8b40de6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1200,9 +1200,19 @@ function change_database_data(&$no_updates, $version) } } - // Set every members user_new column to 0 (old users) - $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; - _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'])) @@ -1246,13 +1256,27 @@ function change_database_data(&$no_updates, $version) $auth_admin = new auth_admin(); $auth_admin->acl_clear_prefetch(); - if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) + 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'); + } + } + + // Minimum number of characters + if (!isset($config['min_post_chars'])) { - set_config('allow_avatar', '1'); + set_config('min_post_chars', '1'); } - else + + if (!isset($config['allow_quick_reply'])) { - set_config('allow_avatar', '0'); + set_config('allow_quick_reply', '1'); } $no_updates = false; -- cgit v1.2.1 From adaeec1ec9f7cd55522a5c4d0bf0538dbc0c6f99 Mon Sep 17 00:00:00 2001 From: Ruslan Uzdenov Date: Sat, 27 Jun 2009 08:36:40 +0000 Subject: Fixed Bug #45115 - Signature parsing flags are not stored in DB Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9696 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c3f8b40de6..98f0596835 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -676,6 +676,10 @@ function database_update_info() 'forum_style' => array('UINT', 0), ), ), + 'change_columns' => array( + USERS_TABLE => array( + 'user_options' => array('UINT:11', 230271), + ), ), // No changes from 3.0.5-RC1 to 3.0.5 @@ -1279,6 +1283,23 @@ function change_database_data(&$no_updates, $version) 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); + } + $no_updates = false; break; } -- cgit v1.2.1 From aeac2819e3dd632deb09de7a7fb2e479c791f5fa Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 30 Jun 2009 14:49:54 +0000 Subject: close the .4 array git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9710 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 98f0596835..85b9623ffe 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -680,6 +680,7 @@ function database_update_info() USERS_TABLE => array( 'user_options' => array('UINT:11', 230271), ), + ), ), // No changes from 3.0.5-RC1 to 3.0.5 -- cgit v1.2.1 From 55e15b4c8eea94f226a0169284bb51d7d9bcbcd4 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 8 Jul 2009 13:52:18 +0000 Subject: Fix database updater and db tools to support multiple column changes/additions/removals with SQLite git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9735 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 238 +++++++++++++++++++++++++++++++++++--- 1 file changed, 220 insertions(+), 18 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 85b9623ffe..d7398ea953 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -11,7 +11,7 @@ $updates_to_version = '3.0.6-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. -$debug_from_version = false; +$debug_from_version = '3.0.5'; // Which oldest version does this updater supports? $oldest_from_version = '3.0.0'; @@ -1292,7 +1292,7 @@ function change_database_data(&$no_updates, $version) $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)) { @@ -1631,6 +1631,14 @@ class updater_db_tools } $statements = array(); + $sqlite = false; + + // For SQLite we need to perform the schema changes in a much more different way + if ($this->db->sql_layer == 'sqlite' && $this->return_statements) + { + $sqlite_data = array(); + $sqlite = true; + } // Change columns? if (!empty($schema_changes['change_columns'])) @@ -1640,16 +1648,27 @@ class updater_db_tools foreach ($columns as $column_name => $column_data) { // If the column exists we change it, else we add it ;) - if ($this->sql_column_exists($table, $column_name)) + if ($column_exists = $this->sql_column_exists($table, $column_name)) { - $result = $this->sql_column_change($table, $column_name, $column_data); + $result = $this->sql_column_change($table, $column_name, $column_data, true); } else { - $result = $this->sql_column_add($table, $column_name, $column_data); + $result = $this->sql_column_add($table, $column_name, $column_data, true); } - if ($this->return_statements) + if ($sqlite) + { + if ($column_exists) + { + $sqlite_data[$table]['change_columns'][] = $result; + } + else + { + $sqlite_data[$table]['add_columns'][] = $result; + } + } + else if ($this->return_statements) { $statements = array_merge($statements, $result); } @@ -1665,16 +1684,27 @@ class updater_db_tools foreach ($columns as $column_name => $column_data) { // Only add the column if it does not exist yet, else change it (to be consistent) - if ($this->sql_column_exists($table, $column_name)) + if ($column_exists = $this->sql_column_exists($table, $column_name)) { - $result = $this->sql_column_change($table, $column_name, $column_data); + $result = $this->sql_column_change($table, $column_name, $column_data, true); } else { - $result = $this->sql_column_add($table, $column_name, $column_data); + $result = $this->sql_column_add($table, $column_name, $column_data, true); } - if ($this->return_statements) + if ($sqlite) + { + if ($column_exists) + { + $sqlite_data[$table]['change_columns'][] = $result; + } + else + { + $sqlite_data[$table]['add_columns'][] = $result; + } + } + else if ($this->return_statements) { $statements = array_merge($statements, $result); } @@ -1709,9 +1739,13 @@ class updater_db_tools // Only remove the column if it exists... if ($this->sql_column_exists($table, $column)) { - $result = $this->sql_column_remove($table, $column); + $result = $this->sql_column_remove($table, $column, true); - if ($this->return_statements) + if ($sqlite) + { + $sqlite_data[$table]['drop_columns'][] = $result; + } + else if ($this->return_statements) { $statements = array_merge($statements, $result); } @@ -1725,9 +1759,13 @@ class updater_db_tools { foreach ($schema_changes['add_primary_keys'] as $table => $columns) { - $result = $this->sql_create_primary_key($table, $columns); + $result = $this->sql_create_primary_key($table, $columns, true); - if ($this->return_statements) + if ($sqlite) + { + $sqlite_data[$table]['primary_key'] = $result; + } + else if ($this->return_statements) { $statements = array_merge($statements, $result); } @@ -1768,6 +1806,147 @@ class updater_db_tools } } + if ($sqlite) + { + foreach ($sqlite_data as $table_name => $sql_schema_changes) + { + // Create temporary table with original data + $statements[] = 'begin'; + + $sql = "SELECT sql + FROM sqlite_master + WHERE type = 'table' + AND name = '{$table_name}' + ORDER BY type DESC, name;"; + $result = $this->db->sql_query($sql); + + if (!$result) + { + continue; + } + + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + // Create a backup table and populate it, destroy the existing one + $statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $row['sql']); + $statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name; + $statements[] = 'DROP TABLE ' . $table_name; + + // Get the columns... + preg_match('#\((.*)\)#s', $row['sql'], $matches); + + $plain_table_cols = trim($matches[1]); + $new_table_cols = preg_split('/,(?![\s\w]+\))/m', $plain_table_cols); + $column_list = array(); + + foreach ($new_table_cols as $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if ($entities[0] == 'PRIMARY') + { + continue; + } + $column_list[] = $entities[0]; + } + + // note down the primary key notation because sqlite only supports adding it to the end for the new table + $primary_key = false; + $_new_cols = array(); + + foreach ($new_table_cols as $key => $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if ($entities[0] == 'PRIMARY') + { + $primary_key = $declaration; + continue; + } + $_new_cols[] = $declaration; + } + + $new_table_cols = $_new_cols; + + // First of all... change columns + if (!empty($sql_schema_changes['change_columns'])) + { + foreach ($sql_schema_changes['change_columns'] as $column_sql) + { + foreach ($new_table_cols as $key => $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if (strpos($column_sql, $entities[0] . ' ') === 0) + { + $new_table_cols[$key] = $column_sql; + } + } + } + } + + if (!empty($sql_schema_changes['add_columns'])) + { + foreach ($sql_schema_changes['add_columns'] as $column_sql) + { + $new_table_cols[] = $column_sql; + } + } + + // Now drop them... + if (!empty($sql_schema_changes['drop_columns'])) + { + foreach ($sql_schema_changes['drop_columns'] as $column_name) + { + // Remove from column list... + $new_column_list = array(); + foreach ($column_list as $key => $value) + { + if ($value === $column_name) + { + continue; + } + + $new_column_list[] = $value; + } + + $column_list = $new_column_list; + + // Remove from table... + $_new_cols = array(); + foreach ($new_table_cols as $key => $declaration) + { + $entities = preg_split('#\s+#', trim($declaration)); + if (strpos($column_name . ' ', $entities[0] . ' ') === 0) + { + continue; + } + $_new_cols[] = $declaration; + } + $new_table_cols = $_new_cols; + } + } + + // Primary key... + if (!empty($sql_schema_changes['primary_key'])) + { + $new_table_cols[] = 'PRIMARY KEY (' . implode(', ', $sql_schema_changes['primary_key']) . ')'; + } + // Add a new one or the old primary key + else if ($primary_key !== false) + { + $new_table_cols[] = $primary_key; + } + + $columns = implode(',', $column_list); + + // create a new table and fill it up. destroy the temp one + $statements[] = 'CREATE TABLE ' . $table_name . ' (' . implode(',', $new_table_cols) . ');'; + $statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;'; + $statements[] = 'DROP TABLE ' . $table_name . '_temp'; + + $statements[] = 'commit'; + } + } + if ($this->return_statements) { return $statements; @@ -2182,7 +2361,7 @@ class updater_db_tools /** * Add new column */ - function sql_column_add($table_name, $column_name, $column_data) + function sql_column_add($table_name, $column_name, $column_data, $inline = false) { $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); $statements = array(); @@ -2216,6 +2395,12 @@ class updater_db_tools break; case 'sqlite': + + if ($inline && $this->return_statements) + { + return $column_name . ' ' . $column_data['column_type_sql']; + } + if (version_compare(sqlite_libversion(), '3.0') == -1) { $sql = "SELECT sql @@ -2280,7 +2465,7 @@ class updater_db_tools /** * Drop column */ - function sql_column_remove($table_name, $column_name) + function sql_column_remove($table_name, $column_name, $inline = false) { $statements = array(); @@ -2308,6 +2493,12 @@ class updater_db_tools break; case 'sqlite': + + if ($inline && $this->return_statements) + { + return $column_name; + } + if (version_compare(sqlite_libversion(), '3.0') == -1) { $sql = "SELECT sql @@ -2401,7 +2592,7 @@ class updater_db_tools /** * Add primary key */ - function sql_create_primary_key($table_name, $column) + function sql_create_primary_key($table_name, $column, $inline = false) { $statements = array(); @@ -2428,6 +2619,12 @@ class updater_db_tools break; case 'sqlite': + + if ($inline && $this->return_statements) + { + return $column; + } + $sql = "SELECT sql FROM sqlite_master WHERE type = 'table' @@ -2541,7 +2738,7 @@ class updater_db_tools /** * Change column type (not name!) */ - function sql_column_change($table_name, $column_name, $column_data) + function sql_column_change($table_name, $column_name, $column_data, $inline = false) { $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); $statements = array(); @@ -2639,6 +2836,11 @@ class updater_db_tools case 'sqlite': + if ($inline && $this->return_statements) + { + return $column_name . ' ' . $column_data['column_type_sql']; + } + $sql = "SELECT sql FROM sqlite_master WHERE type = 'table' -- cgit v1.2.1 From 26bb3bbb6824166d05362f5516009fdf3477195f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 9 Jul 2009 13:28:25 +0000 Subject: print out error if users try to update phpBB versions no longer supported with the used database update script git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9743 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 53 +++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d7398ea953..249b0a8f69 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -11,7 +11,7 @@ $updates_to_version = '3.0.6-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. -$debug_from_version = '3.0.5'; +$debug_from_version = false; // Which oldest version does this updater supports? $oldest_from_version = '3.0.0'; @@ -249,28 +249,25 @@ if ($db->sql_layer == 'mysql' || $db->sql_layer == 'mysql4' || $db->sql_layer == echo '

' . $lang['ERROR'] . '


'; echo '

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

'; -?> - - - - - - - - - - - -

' . $lang['ERROR'] . '


'; + echo '

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

'; + + _print_footer(); + exit_handler(); + exit; +} + // 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) { @@ -455,8 +452,21 @@ add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $updates_to_version); // Now we purge the session table as well as all cache files $cache->purge(); -?> +_print_footer(); + +garbage_collection(); + +if (function_exists('exit_handler')) +{ + exit_handler(); +} +/** +* Print out footer +*/ +function _print_footer() +{ + echo << @@ -471,14 +481,7 @@ $cache->purge(); - - Date: Tue, 14 Jul 2009 20:25:41 +0000 Subject: Feature Bug #45375 - Add option to disable remote upload avatars Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9757 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 249b0a8f69..31d7976033 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1276,6 +1276,18 @@ function change_database_data(&$no_updates, $version) } } + 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'])) { -- cgit v1.2.1 From e3866c939d78b925844cd61d6ad567988f24e42d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 14 Jul 2009 20:35:53 +0000 Subject: Feature Bug #43375 - Ability to delete warnings and keep warnings permanently Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9758 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 31d7976033..e13bc1d546 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1122,6 +1122,49 @@ function change_database_data(&$no_updates, $version) } } + // Also install the "User Warning" module + $sql = 'SELECT module_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_USER_MANAGEMENT' + AND module_mode = '' + AND module_basename = ''"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $category_id = (int) $row['module_id']; + + // Check if we actually need to add the module or if it is already added. ;) + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_USER_WARNINGS' + AND module_mode = 'warnings' + AND module_auth = 'acl_a_user' + AND parent_id = {$category_id}"; + $result2 = $db->sql_query($sql); + $row2 = $db->sql_fetchrow($result2); + $db->sql_freeresult($result2); + + if (!$row2) + { + $module_data = array( + 'module_basename' => 'users', + 'module_enabled' => 1, + 'module_display' => 0, + 'parent_id' => $category_id, + 'module_class' => 'acp', + 'module_langname' => 'ACP_USER_WARNINGS', + 'module_mode' => 'warnings', + 'module_auth' => 'acl_a_user', + ); + + $_module->update_module_data($module_data, true); + } + } + $db->sql_freeresult($result); + $_module->remove_cache_file(); // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) -- cgit v1.2.1 From 7a5ba35cc73b31e78b844db80b8e5b52666ca51b Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Fri, 17 Jul 2009 17:21:07 +0000 Subject: - Add smilies per page config setting to the database updater git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9774 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e13bc1d546..362a379ec1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1073,6 +1073,9 @@ function change_database_data(&$no_updates, $version) set_config('feed_item_statistics', '1'); set_config('feed_exclude_id', ''); + // Entries for smiley pagination + set_config('smilies_per_page', '50'); + include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); $_module = new acp_modules(); -- cgit v1.2.1 From 6e4a7c03d14d6fcc03955fbe26c3d5f725eb929d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 21 Jul 2009 20:59:11 +0000 Subject: Users can report PMs to moderators which are then visible in a new MCP module git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9814 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 362a379ec1..3b6c614deb 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -701,11 +701,21 @@ function database_update_info() 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), + ), ), 'add_index' => array( LOG_TABLE => array( 'log_time' => array('log_time'), ), + REPORTS_TABLE => array( + 'post_id' => array('post_id'), + 'pm_id' => array('pm_id'), + ), ), ), ); @@ -1076,6 +1086,9 @@ function change_database_data(&$no_updates, $version) // Entries for smiley pagination set_config('smilies_per_page', '50'); + // Entry for reporting PMs + set_config('allow_pm_report', '1'); + include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); $_module = new acp_modules(); @@ -1168,6 +1181,58 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); + + // Also install the "PM Reports" module + $sql = 'SELECT module_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'mcp' + AND module_langname = 'MCP_REPORTS' + AND module_mode = '' + AND module_basename = ''"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $category_id = (int) $row['module_id']; + + $modes = array( + 'pm_reports' => array('title' => 'MCP_PM_REPORTS_OPEN', 'auth' => 'aclf_m_report'), + 'pm_reports_closed' => array('title' => 'MCP_PM_REPORTS_CLOSED', 'auth' => 'aclf_m_report'), + 'pm_report_details' => array('title' => 'MCP_PM_REPORT_DETAILS', 'auth' => 'aclf_m_report'), + ); + + foreach ($modes as $mode => $data) + { + // Check if we actually need to add the module or if it is already added. ;) + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_class = 'mcp' + AND module_langname = '{$data['title']}' + AND module_mode = '$mode' + AND parent_id = {$category_id}"; + $result2 = $db->sql_query($sql); + $row2 = $db->sql_fetchrow($result2); + $db->sql_freeresult($result2); + + if (!$row2) + { + $module_data = array( + 'module_basename' => 'users', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => $category_id, + 'module_class' => 'mcp', + 'module_langname' => $data['title'], + 'module_mode' => $mode, + 'module_auth' => $data['auth'], + ); + + $_module->update_module_data($module_data, true); + } + } + } + $db->sql_freeresult($result); + $_module->remove_cache_file(); // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) -- cgit v1.2.1 From 54f78a50bc6162fd49e506892a455f7bb43e31fb Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 22 Jul 2009 13:09:22 +0000 Subject: insert pm_reports module with correct basename on update git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9829 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3b6c614deb..c055449d5f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1217,7 +1217,7 @@ function change_database_data(&$no_updates, $version) if (!$row2) { $module_data = array( - 'module_basename' => 'users', + 'module_basename' => 'pm_reports', 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => $category_id, -- cgit v1.2.1 From 4739c7ba3957dfe585973dafe7465cb9fd8c6d1f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 24 Jul 2009 11:13:32 +0000 Subject: [Feature] Added new functionality to inactive users module: - Ability to set users per page. - Ability to sort by posts/number of reminders/last reminded date. - Show number of posts and ability to search posts. - Show number of reminders sent to user. - Show date of last reminder sent to user. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9845 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c055449d5f..6d596a8a00 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -11,7 +11,7 @@ $updates_to_version = '3.0.6-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. -$debug_from_version = false; +$debug_from_version = '3.0.5'; // Which oldest version does this updater supports? $oldest_from_version = '3.0.0'; @@ -696,7 +696,9 @@ function database_update_info() 'attempts' => array('UINT', 0), ), USERS_TABLE => array( - 'user_new' => array('BOOL', 1), + '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'), @@ -714,7 +716,7 @@ function database_update_info() ), REPORTS_TABLE => array( 'post_id' => array('post_id'), - 'pm_id' => array('pm_id'), + 'pm_id' => array('pm_id'), ), ), ), -- cgit v1.2.1 From fecc3383a24eafe9b84caea37720813a0f1f5cfe Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 28 Jul 2009 11:26:55 +0000 Subject: disable QR by default git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9878 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 6d596a8a00..c2b5b3d3d1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1409,7 +1409,7 @@ function change_database_data(&$no_updates, $version) if (!isset($config['allow_quick_reply'])) { - set_config('allow_quick_reply', '1'); + set_config('allow_quick_reply', '0'); } // Set every members user_options column to enable -- cgit v1.2.1 From b4f3a0eb2d20cd618a1ade5f2d38a90cb9c6d265 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 21:33:31 +0000 Subject: Fix r9696, #45115. Move column change to the correct version. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9886 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c2b5b3d3d1..a00d928a12 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -679,11 +679,6 @@ function database_update_info() 'forum_style' => array('UINT', 0), ), ), - 'change_columns' => array( - USERS_TABLE => array( - 'user_options' => array('UINT:11', 230271), - ), - ), ), // No changes from 3.0.5-RC1 to 3.0.5 @@ -710,6 +705,11 @@ function database_update_info() 'pm_id' => array('UINT', 0), ), ), + 'change_columns' => array( + USERS_TABLE => array( + 'user_options' => array('UINT:11', 230271), + ), + ), 'add_index' => array( LOG_TABLE => array( 'log_time' => array('log_time'), -- cgit v1.2.1 From 1b8a1f73d77d3df21b8404611a130bb4ee19b822 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 28 Jul 2009 22:09:46 +0000 Subject: [Feature] Ability to copy permissions from one forum to several other forums. [Fix] Add log entry when copying forum permissions. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9887 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a00d928a12..b2460009f7 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1235,6 +1235,49 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); + // Also install the "Copy forum permissions" module + $sql = 'SELECT module_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_FORUM_BASED_PERMISSIONS' + AND module_mode = '' + AND module_basename = ''"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $category_id = (int) $row['module_id']; + + // Check if we actually need to add the feed module or if it is already added. ;) + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_FORUM_PERMISSIONS_COPY' + AND module_mode = 'setting_forum_copy' + AND module_auth = 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth' + AND parent_id = {$category_id}"; + $result2 = $db->sql_query($sql); + $row2 = $db->sql_fetchrow($result2); + $db->sql_freeresult($result2); + + if (!$row2) + { + $module_data = array( + 'module_basename' => 'permissions', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => $category_id, + 'module_class' => 'acp', + 'module_langname' => 'ACP_FORUM_PERMISSIONS_COPY', + 'module_mode' => 'setting_forum_copy', + 'module_auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', + ); + + $_module->update_module_data($module_data, true); + } + } + $db->sql_freeresult($result); + $_module->remove_cache_file(); // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) -- cgit v1.2.1 From e6f133dc55095b337ad311c761e82d4f026c0ea1 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 31 Jul 2009 08:16:36 +0000 Subject: Revert r9878 - QR was already disabled by default, for admin convenience we enable the global setting but no local setting, which results in OFF by default git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9895 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b2460009f7..709836ea88 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1452,7 +1452,7 @@ function change_database_data(&$no_updates, $version) if (!isset($config['allow_quick_reply'])) { - set_config('allow_quick_reply', '0'); + set_config('allow_quick_reply', '1'); } // Set every members user_options column to enable -- cgit v1.2.1 From 1f871950d8bbefe59e18c00ea3238591c0b73807 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 3 Aug 2009 15:46:56 +0000 Subject: #48985 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9916 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 709836ea88..e692750659 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -704,6 +704,9 @@ function database_update_info() REPORTS_TABLE => array( 'pm_id' => array('UINT', 0), ), + PROFILE_FIELDS_TABLE => array( + 'field_show_on_vt' => array('BOOL', 0), + ), ), 'change_columns' => array( USERS_TABLE => array( -- cgit v1.2.1 From ee65d2147b7e672c6dfdcd695f0b6314c40e42d2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 5 Aug 2009 15:28:46 +0000 Subject: fix r9713 for #36565 Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9931 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e692750659..4380f0cb8c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -721,6 +721,9 @@ function database_update_info() 'post_id' => array('post_id'), 'pm_id' => array('pm_id'), ), + POSTS_TABLE => array( + 'post_username' => array('post_username'), + ), ), ), ); -- cgit v1.2.1 From 96a30afcca3ebd832c9b3083bb5c9a9f2a2dc54b Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 11 Aug 2009 14:49:58 +0000 Subject: do not change column if column already exists. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9956 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4380f0cb8c..8252cd4968 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1860,10 +1860,12 @@ class updater_db_tools { foreach ($columns as $column_name => $column_data) { - // Only add the column if it does not exist yet, else change it (to be consistent) + // Only add the column if it does not exist yet if ($column_exists = $this->sql_column_exists($table, $column_name)) { - $result = $this->sql_column_change($table, $column_name, $column_data, true); + continue; + // This is commented out here because it can take tremendous time on updates +// $result = $this->sql_column_change($table, $column_name, $column_data, true); } else { -- cgit v1.2.1 From 09ad10a734c0993f9465e6ac3463951251602fc6 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 12 Aug 2009 15:00:47 +0000 Subject: ok, i am very sorry, but this needs to be fixed. Generally, our config table is not really suited for holding large datasets. Because feed settings for the forums to enable news feeds and excluded forums rely on the forums itself we have decided to introduce a forum_options table where custom options can be stored. Additionally, for this to work across all DBMS we support, we added a new method to the DBAL for the bitwise AND operator. Also moved the forum/topic feed template variable to the location where they belong to (forum and topic view) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9965 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8252cd4968..e77a170240 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -707,6 +707,9 @@ function database_update_info() 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( @@ -1086,10 +1089,7 @@ function change_database_data(&$no_updates, $version) set_config('feed_forum', '1'); set_config('feed_topic', '1'); - set_config('feed_news_id', ''); - set_config('feed_item_statistics', '1'); - set_config('feed_exclude_id', ''); // Entries for smiley pagination set_config('smilies_per_page', '50'); -- cgit v1.2.1 From 4525d1cb733e893762e87a4f597f8489a9917191 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 13 Aug 2009 14:51:47 +0000 Subject: - links to send statistics after install and update - link back to ACP main from send statistics - improved language / better explanation (incl. Bug #48555) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9969 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e77a170240..76de50186d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1284,6 +1284,49 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); + // Also install the "Send statistics" module + $sql = 'SELECT module_id + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_SERVER_CONFIGURATION' + AND module_mode = '' + AND module_basename = ''"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $category_id = (int) $row['module_id']; + + // Check if we actually need to add the feed module or if it is already added. ;) + $sql = 'SELECT * + FROM ' . MODULES_TABLE . " + WHERE module_class = 'acp' + AND module_langname = 'ACP_SEND_STATISTICS' + AND module_mode = 'questionnaire' + AND module_auth = 'acl_a_server' + AND parent_id = {$category_id}"; + $result2 = $db->sql_query($sql); + $row2 = $db->sql_fetchrow($result2); + $db->sql_freeresult($result2); + + if (!$row2) + { + $module_data = array( + 'module_basename' => 'send_statistics', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => $category_id, + 'module_class' => 'acp', + 'module_langname' => 'ACP_SEND_STATISTICS', + 'module_mode' => 'send_statistics', + 'module_auth' => 'acl_a_server', + ); + + $_module->update_module_data($module_data, true); + } + } + $db->sql_freeresult($result); + $_module->remove_cache_file(); // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) -- cgit v1.2.1 From b4baa6a0941aa32db06ddabc56612616fe75605f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 13 Aug 2009 15:25:20 +0000 Subject: Lifted minimum requirement for Firebird DBMS from 2.0+ to 2.1+. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9970 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 76de50186d..dc3fcfe956 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -222,6 +222,33 @@ if (empty($config['dbms_version'])) set_config('dbms_version', $db->sql_server_info(true)); } +// Firebird update from Firebord 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'] . '

'; + + _print_footer(); + + exit_handler(); + exit; + } + + $db->sql_freeresult($result); + $db->sql_return_on_error(false); +} + // 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') { -- cgit v1.2.1 From 5ecc57b87e0444c355574b61538c08a4a1c66aad Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 18 Aug 2009 08:22:17 +0000 Subject: Tiny typo change to r9743, #46425. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10013 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index dc3fcfe956..7656ea8952 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -13,7 +13,7 @@ $updates_to_version = '3.0.6-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = '3.0.5'; -// Which oldest version does this updater supports? +// Which oldest version does this updater support? $oldest_from_version = '3.0.0'; // Return if we "just include it" to find out for which version the database update is responsible for -- cgit v1.2.1 From 9382f6ba174e55ee0b43649e40282a6cb47800ff Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 24 Aug 2009 00:29:23 +0000 Subject: Fix bug #50245 - Check for correct module name when installing the "Send statistics" module. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10049 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7656ea8952..72bad95227 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1324,12 +1324,12 @@ function change_database_data(&$no_updates, $version) { $category_id = (int) $row['module_id']; - // Check if we actually need to add the feed module or if it is already added. ;) + // Check if we need to add the module or if it is already there. ;) $sql = 'SELECT * FROM ' . MODULES_TABLE . " WHERE module_class = 'acp' AND module_langname = 'ACP_SEND_STATISTICS' - AND module_mode = 'questionnaire' + AND module_mode = 'send_statistics' AND module_auth = 'acl_a_server' AND parent_id = {$category_id}"; $result2 = $db->sql_query($sql); -- cgit v1.2.1 From 3f22f755a3a3da4f711454e25772f13c42014ecc Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 30 Aug 2009 17:22:21 +0000 Subject: correct mode is send_statistics, else installs will differ from updates. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10068 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 65 ++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 35 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 72bad95227..b9ac325778 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1181,11 +1181,11 @@ function change_database_data(&$no_updates, $version) AND module_mode = '' AND module_basename = ''"; $result = $db->sql_query($sql); + $category_id = (int) $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); - while ($row = $db->sql_fetchrow($result)) + if ($category_id) { - $category_id = (int) $row['module_id']; - // Check if we actually need to add the module or if it is already added. ;) $sql = 'SELECT * FROM ' . MODULES_TABLE . " @@ -1194,11 +1194,11 @@ function change_database_data(&$no_updates, $version) AND module_mode = 'warnings' AND module_auth = 'acl_a_user' AND parent_id = {$category_id}"; - $result2 = $db->sql_query($sql); - $row2 = $db->sql_fetchrow($result2); - $db->sql_freeresult($result2); + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); - if (!$row2) + if (!$row) { $module_data = array( 'module_basename' => 'users', @@ -1214,8 +1214,6 @@ function change_database_data(&$no_updates, $version) $_module->update_module_data($module_data, true); } } - $db->sql_freeresult($result); - // Also install the "PM Reports" module $sql = 'SELECT module_id @@ -1225,15 +1223,15 @@ function change_database_data(&$no_updates, $version) AND module_mode = '' AND module_basename = ''"; $result = $db->sql_query($sql); + $category_id = (int) $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); - while ($row = $db->sql_fetchrow($result)) + if ($category_id) { - $category_id = (int) $row['module_id']; - $modes = array( 'pm_reports' => array('title' => 'MCP_PM_REPORTS_OPEN', 'auth' => 'aclf_m_report'), - 'pm_reports_closed' => array('title' => 'MCP_PM_REPORTS_CLOSED', 'auth' => 'aclf_m_report'), - 'pm_report_details' => array('title' => 'MCP_PM_REPORT_DETAILS', 'auth' => 'aclf_m_report'), + 'pm_reports_closed' => array('title' => 'MCP_PM_REPORTS_CLOSED', 'auth' => 'aclf_m_report'), + 'pm_report_details' => array('title' => 'MCP_PM_REPORT_DETAILS', 'auth' => 'aclf_m_report'), ); foreach ($modes as $mode => $data) @@ -1245,11 +1243,11 @@ function change_database_data(&$no_updates, $version) AND module_langname = '{$data['title']}' AND module_mode = '$mode' AND parent_id = {$category_id}"; - $result2 = $db->sql_query($sql); - $row2 = $db->sql_fetchrow($result2); - $db->sql_freeresult($result2); + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); - if (!$row2) + if (!$row) { $module_data = array( 'module_basename' => 'pm_reports', @@ -1266,7 +1264,6 @@ function change_database_data(&$no_updates, $version) } } } - $db->sql_freeresult($result); // Also install the "Copy forum permissions" module $sql = 'SELECT module_id @@ -1276,11 +1273,11 @@ function change_database_data(&$no_updates, $version) AND module_mode = '' AND module_basename = ''"; $result = $db->sql_query($sql); + $category_id = (int) $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); - while ($row = $db->sql_fetchrow($result)) + if ($category_id) { - $category_id = (int) $row['module_id']; - // Check if we actually need to add the feed module or if it is already added. ;) $sql = 'SELECT * FROM ' . MODULES_TABLE . " @@ -1289,11 +1286,11 @@ function change_database_data(&$no_updates, $version) AND module_mode = 'setting_forum_copy' AND module_auth = 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth' AND parent_id = {$category_id}"; - $result2 = $db->sql_query($sql); - $row2 = $db->sql_fetchrow($result2); - $db->sql_freeresult($result2); + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); - if (!$row2) + if (!$row) { $module_data = array( 'module_basename' => 'permissions', @@ -1309,7 +1306,6 @@ function change_database_data(&$no_updates, $version) $_module->update_module_data($module_data, true); } } - $db->sql_freeresult($result); // Also install the "Send statistics" module $sql = 'SELECT module_id @@ -1319,11 +1315,11 @@ function change_database_data(&$no_updates, $version) AND module_mode = '' AND module_basename = ''"; $result = $db->sql_query($sql); + $category_id = (int) $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); - while ($row = $db->sql_fetchrow($result)) + if ($category_id) { - $category_id = (int) $row['module_id']; - // Check if we need to add the module or if it is already there. ;) $sql = 'SELECT * FROM ' . MODULES_TABLE . " @@ -1332,11 +1328,11 @@ function change_database_data(&$no_updates, $version) AND module_mode = 'send_statistics' AND module_auth = 'acl_a_server' AND parent_id = {$category_id}"; - $result2 = $db->sql_query($sql); - $row2 = $db->sql_fetchrow($result2); - $db->sql_freeresult($result2); + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); - if (!$row2) + if (!$row) { $module_data = array( 'module_basename' => 'send_statistics', @@ -1352,7 +1348,6 @@ function change_database_data(&$no_updates, $version) $_module->update_module_data($module_data, true); } } - $db->sql_freeresult($result); $_module->remove_cache_file(); -- cgit v1.2.1 From 0dc8f103c9ab170f173ca1be4c04851d1c4fa6f8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 31 Aug 2009 09:38:53 +0000 Subject: ok, now we just define the modules we want to install on update and where they should appear. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10072 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 401 +++++++++++++++++--------------------- 1 file changed, 178 insertions(+), 223 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b9ac325778..d489521a20 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -575,6 +575,127 @@ function _write_result($no_updates, $errored, $error_ary) } } +function _add_modules($modules_to_install) +{ + global $phpbb_root_path, $phpEx, $db; + + 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); + + // Ok, do we need to re-order the module, move it up or down? + if (!isset($module_data['after'])) + { + continue; + } + + $after_mode = $module_data['after'][0]; + $after_langname = $module_data['after'][1]; + + // First of all, get the module id for the module this one has to be placed after + $sql = 'SELECT left_id + FROM ' . MODULES_TABLE . " + WHERE module_class = '" . $db->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']} + ORDER BY 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); + } + } +} + /**************************************************************************** * ADD YOUR DATABASE SCHEMA CHANGES HERE * *****************************************************************************/ @@ -1124,230 +1245,64 @@ function change_database_data(&$no_updates, $version) // Entry for reporting PMs set_config('allow_pm_report', '1'); - include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); - - $_module = new acp_modules(); - - // Set the module class - $_module->module_class = 'acp'; - - $sql = 'SELECT module_id - FROM ' . MODULES_TABLE . " - WHERE module_class = 'acp' - AND module_langname = 'ACP_BOARD_CONFIGURATION' - AND module_mode = '' - AND module_basename = ''"; - $result = $db->sql_query($sql); - $category_id = (int) $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - if ($category_id) - { - // Check if we actually need to add the feed module or if it is already added. ;) - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_basename = 'board' - AND module_class = 'acp' - AND module_langname = 'ACP_FEED_SETTINGS' - AND module_mode = 'feed' - AND module_auth = 'acl_a_board' - AND parent_id = {$category_id}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $module_data = array( - 'module_basename' => 'board', - 'module_enabled' => 1, - 'module_display' => 1, - 'parent_id' => $category_id, - 'module_class' => 'acp', - 'module_langname' => 'ACP_FEED_SETTINGS', - 'module_mode' => 'feed', - 'module_auth' => 'acl_a_board', - ); - - $_module->update_module_data($module_data, true); - } - } - - // Also install the "User Warning" module - $sql = 'SELECT module_id - FROM ' . MODULES_TABLE . " - WHERE module_class = 'acp' - AND module_langname = 'ACP_USER_MANAGEMENT' - AND module_mode = '' - AND module_basename = ''"; - $result = $db->sql_query($sql); - $category_id = (int) $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - if ($category_id) - { - // Check if we actually need to add the module or if it is already added. ;) - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_class = 'acp' - AND module_langname = 'ACP_USER_WARNINGS' - AND module_mode = 'warnings' - AND module_auth = 'acl_a_user' - AND parent_id = {$category_id}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $module_data = array( - 'module_basename' => 'users', - 'module_enabled' => 1, - 'module_display' => 0, - 'parent_id' => $category_id, - 'module_class' => 'acp', - 'module_langname' => 'ACP_USER_WARNINGS', - 'module_mode' => 'warnings', - 'module_auth' => 'acl_a_user', - ); - - $_module->update_module_data($module_data, true); - } - } - - // Also install the "PM Reports" module - $sql = 'SELECT module_id - FROM ' . MODULES_TABLE . " - WHERE module_class = 'mcp' - AND module_langname = 'MCP_REPORTS' - AND module_mode = '' - AND module_basename = ''"; - $result = $db->sql_query($sql); - $category_id = (int) $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - if ($category_id) - { - $modes = array( - 'pm_reports' => array('title' => 'MCP_PM_REPORTS_OPEN', 'auth' => 'aclf_m_report'), - 'pm_reports_closed' => array('title' => 'MCP_PM_REPORTS_CLOSED', 'auth' => 'aclf_m_report'), - 'pm_report_details' => array('title' => 'MCP_PM_REPORT_DETAILS', 'auth' => 'aclf_m_report'), - ); - - foreach ($modes as $mode => $data) - { - // Check if we actually need to add the module or if it is already added. ;) - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_class = 'mcp' - AND module_langname = '{$data['title']}' - AND module_mode = '$mode' - AND parent_id = {$category_id}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $module_data = array( - 'module_basename' => 'pm_reports', - 'module_enabled' => 1, - 'module_display' => 1, - 'parent_id' => $category_id, - 'module_class' => 'mcp', - 'module_langname' => $data['title'], - 'module_mode' => $mode, - 'module_auth' => $data['auth'], - ); - - $_module->update_module_data($module_data, true); - } - } - } - - // Also install the "Copy forum permissions" module - $sql = 'SELECT module_id - FROM ' . MODULES_TABLE . " - WHERE module_class = 'acp' - AND module_langname = 'ACP_FORUM_BASED_PERMISSIONS' - AND module_mode = '' - AND module_basename = ''"; - $result = $db->sql_query($sql); - $category_id = (int) $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - if ($category_id) - { - // Check if we actually need to add the feed module or if it is already added. ;) - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_class = 'acp' - AND module_langname = 'ACP_FORUM_PERMISSIONS_COPY' - AND module_mode = 'setting_forum_copy' - AND module_auth = 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth' - AND parent_id = {$category_id}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $module_data = array( - 'module_basename' => 'permissions', - 'module_enabled' => 1, - 'module_display' => 1, - 'parent_id' => $category_id, - 'module_class' => 'acp', - 'module_langname' => 'ACP_FORUM_PERMISSIONS_COPY', - 'module_mode' => 'setting_forum_copy', - 'module_auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', - ); - - $_module->update_module_data($module_data, true); - } - } - - // Also install the "Send statistics" module - $sql = 'SELECT module_id - FROM ' . MODULES_TABLE . " - WHERE module_class = 'acp' - AND module_langname = 'ACP_SERVER_CONFIGURATION' - AND module_mode = '' - AND module_basename = ''"; - $result = $db->sql_query($sql); - $category_id = (int) $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - if ($category_id) - { - // Check if we need to add the module or if it is already there. ;) - $sql = 'SELECT * - FROM ' . MODULES_TABLE . " - WHERE module_class = 'acp' - AND module_langname = 'ACP_SEND_STATISTICS' - AND module_mode = 'send_statistics' - AND module_auth = 'acl_a_server' - AND parent_id = {$category_id}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $module_data = array( - 'module_basename' => 'send_statistics', - 'module_enabled' => 1, - 'module_display' => 1, - 'parent_id' => $category_id, - 'module_class' => 'acp', - 'module_langname' => 'ACP_SEND_STATISTICS', - 'module_mode' => 'send_statistics', - 'module_auth' => 'acl_a_server', - ); + // 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' + ), + ); - $_module->update_module_data($module_data, true); - } - } + _add_modules($modules_to_install); $_module->remove_cache_file(); -- cgit v1.2.1 From 139f1d35302fc675b5e972e55c62d36cbc42af5c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 31 Aug 2009 14:57:04 +0000 Subject: fix r10076 for #48615 - Ability to specify amount of time user is able to delete his last post in topic. Authorised by: AcydBurn git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10080 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d489521a20..48dd55ac72 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1498,6 +1498,11 @@ function change_database_data(&$no_updates, $version) _sql($sql, $errored, $error_ary); } + if (!isset($config['delete_time'])) + { + set_config('delete_time', $config['edit_time']); + } + $no_updates = false; break; } -- cgit v1.2.1 From 254dee274c0e2753edb171fcb71c71c8ed47222e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 1 Sep 2009 15:07:26 +0000 Subject: erm, wrong position git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10084 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 48dd55ac72..8ebe261d9e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -694,6 +694,8 @@ function _add_modules($modules_to_install) $_module->move_module_by($module_row, 'move_up', $steps); } } + + $_module->remove_cache_file(); } /**************************************************************************** @@ -1304,8 +1306,6 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); - $_module->remove_cache_file(); - // 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 . " -- cgit v1.2.1 From 2b5f04cf1c6987ec943ea3937e1d2c63b7982427 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 4 Sep 2009 10:25:31 +0000 Subject: changes for a little internal update test run git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10098 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8ebe261d9e..b98ebfdd5f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,10 +8,10 @@ * */ -$updates_to_version = '3.0.6-dev'; +$updates_to_version = '3.0.6-alpha'; // Enter any version to update from to test updates. The version within the db will not be updated. -$debug_from_version = '3.0.5'; +$debug_from_version = false; // Which oldest version does this updater support? $oldest_from_version = '3.0.0'; @@ -834,7 +834,7 @@ function database_update_info() // No changes from 3.0.5-RC1 to 3.0.5 '3.0.5-RC1' => array(), - // Changes from 3.0.5 + // Changes from 3.0.5 to 3.0.6-RC1 '3.0.5' => array( 'add_columns' => array( CONFIRM_TABLE => array( -- cgit v1.2.1 From 31856352be0f29fd7423cfe87bdfd791b03fb938 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 4 Sep 2009 15:19:26 +0000 Subject: Change version numbers to 3.0.6 and 3.0.6-RC1 for a final internal test run git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10105 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b98ebfdd5f..ab22c803ee 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.6-alpha'; +$updates_to_version = '3.0.6-RC1'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; -- cgit v1.2.1 From 0fe74ebceac75c559b8779f291ebb2df80309e92 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 4 Sep 2009 15:44:10 +0000 Subject: Add INDEX on user_regdate because this is the default ORDER BY in memberlist.php - thanks nickvergessen. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10106 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ab22c803ee..54586c5650 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -877,6 +877,9 @@ function database_update_info() POSTS_TABLE => array( 'post_username' => array('post_username'), ), + USERS_TABLE => array( + 'user_regdate' => array('user_regdate'), + ), ), ), ); -- cgit v1.2.1 From fc5a21e16a6502a89fd7b541683f21e216c8cf2e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 4 Sep 2009 17:27:13 +0000 Subject: Revert r10106 - Index usage is very unlikely because of WHERE IN (). :-| git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10107 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 54586c5650..ab22c803ee 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -877,9 +877,6 @@ function database_update_info() POSTS_TABLE => array( 'post_username' => array('post_username'), ), - USERS_TABLE => array( - 'user_regdate' => array('user_regdate'), - ), ), ), ); -- cgit v1.2.1 From a5ec35e185126f5366a5749ad4f57325202b10f5 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 10 Sep 2009 08:58:24 +0000 Subject: Fix database updater for PostgreSQL: Data needs to be GROUPed BY left_id, before we can ORDER BY left_id. Introduced in r10072. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10130 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ab22c803ee..41983400fc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -677,6 +677,7 @@ function _add_modules($modules_to_install) 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']} + GROUP BY left_id ORDER BY left_id"; $result = $db->sql_query($sql); $steps = (int) $db->sql_fetchfield('num_modules'); -- cgit v1.2.1 From 54c22ae52a0e18232cac8fed342ea52f2e2a793d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 24 Sep 2009 08:53:17 +0000 Subject: remove log_time index (was not used at all) At the same time the database updater now supports checking for existing indexes. The db tools will not have this in 3.0.6 (the db tools have a function to retrieve all indexes) and i need to test the updater on all DBMS today... git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10183 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 131 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 126 insertions(+), 5 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 41983400fc..d6f9348b29 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.6-RC1'; +$updates_to_version = '3.0.6-RC2'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -868,9 +868,6 @@ function database_update_info() ), ), 'add_index' => array( - LOG_TABLE => array( - 'log_time' => array('log_time'), - ), REPORTS_TABLE => array( 'post_id' => array('post_id'), 'pm_id' => array('pm_id'), @@ -880,6 +877,12 @@ function database_update_info() ), ), ), + // Changes from 3.0.6-RC1 to 3.0.6-RC2 + '3.0.6-RC1' => array( + 'drop_keys' => array( + LOG_TABLE => array('log_time'), + ), + ), ); } @@ -1506,6 +1509,16 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // Changes from 3.0.6-RC1 to 3.0.6-RC2 + case '3.0.6-RC1': + + // We check if there is an index for log_time within the logs table + + + // If so, we remove it + + break; } } @@ -1902,7 +1915,8 @@ class updater_db_tools { if ($column_exists) { - $sqlite_data[$table]['change_columns'][] = $result; + continue; +// $sqlite_data[$table]['change_columns'][] = $result; } else { @@ -1924,6 +1938,11 @@ class updater_db_tools { foreach ($indexes as $index_name) { + if (!$this->sql_index_exists($table, $index_name)) + { + continue; + } + $result = $this->sql_index_drop($table, $index_name); if ($this->return_statements) @@ -1984,6 +2003,11 @@ class updater_db_tools { foreach ($index_array as $index_name => $column) { + if ($this->sql_index_exists($table, $index_name)) + { + continue; + } + $result = $this->sql_create_unique_index($table, $index_name, $column); if ($this->return_statements) @@ -2001,6 +2025,11 @@ class updater_db_tools { foreach ($index_array as $index_name => $column) { + if ($this->sql_index_exists($table, $index_name)) + { + continue; + } + $result = $this->sql_create_index($table, $index_name, $column); if ($this->return_statements) @@ -2308,6 +2337,98 @@ class updater_db_tools } } + /** + * Check if a specified index exists in table + * + * @param string $table_name Table to check the index at + * @param string $index_name The index name to check + * + * @return bool True if index exists, else false + */ + function sql_index_exists($table_name, $index_name) + { + if ($this->sql_layer == 'mssql') + { + $sql = "EXEC sp_statistics '$table_name'"; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + if ($row['TYPE'] == 3) + { + if (strtolower($row['INDEX_NAME']) == strtolower($index_name)) + { + $this->db->sql_freeresult($result); + return true; + } + } + } + $this->db->sql_freeresult($result); + + return false; + } + + switch ($this->sql_layer) + { + case 'firebird': + $sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name + FROM RDB\$INDICES + WHERE RDB\$RELATION_NAME = " . strtoupper($table_name) . " + AND RDB\$UNIQUE_FLAG IS NULL + AND RDB\$FOREIGN_KEY IS NULL"; + $col = 'index_name'; + break; + + case 'postgres': + $sql = "SELECT ic.relname as index_name + FROM pg_class bc, pg_class ic, pg_index i + WHERE (bc.oid = i.indrelid) + AND (ic.oid = i.indexrelid) + AND (bc.relname = '" . $table_name . "') + AND (i.indisunique != 't') + AND (i.indisprimary != 't')"; + $col = 'index_name'; + break; + + case 'mysql_40': + case 'mysql_41': + $sql = 'SHOW KEYS + FROM ' . $table_name; + $col = 'Key_name'; + break; + + case 'oracle': + $sql = "SELECT index_name + FROM user_indexes + WHERE table_name = '" . $table_name . "' + AND generated = 'N'"; + break; + + case 'sqlite': + $sql = "PRAGMA index_info('" . $table_name . "');"; + $col = 'name'; + break; + } + + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && !$row['Non_unique']) + { + continue; + } + + if (strtolower($row[$col]) == strtolower($index_name)) + { + $this->db->sql_freeresult($result); + return true; + } + } + $this->db->sql_freeresult($result); + + return false; + } + /** * Private method for performing sql statements (either execute them or return them) * @access private -- cgit v1.2.1 From 023760c8b2402418310a3717db8349cac0342e42 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 24 Sep 2009 15:36:05 +0000 Subject: I think i need to check other DBMS more often. :/ - fix index check for sqlite, firebird and oracle - add check for unique index - fix changing default value for column in mssql (add constraint) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10185 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 170 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 162 insertions(+), 8 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d6f9348b29..ee4d45c57c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2003,7 +2003,7 @@ class updater_db_tools { foreach ($index_array as $index_name => $column) { - if ($this->sql_index_exists($table, $index_name)) + if ($this->sql_unique_index_exists($table, $index_name)) { continue; } @@ -2338,7 +2338,7 @@ class updater_db_tools } /** - * Check if a specified index exists in table + * Check if a specified index exists in table. Does not return PRIMARY KEY and UNIQUE indexes. * * @param string $table_name Table to check the index at * @param string $index_name The index name to check @@ -2373,7 +2373,7 @@ class updater_db_tools case 'firebird': $sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name FROM RDB\$INDICES - WHERE RDB\$RELATION_NAME = " . strtoupper($table_name) . " + WHERE RDB\$RELATION_NAME = '" . strtoupper($table_name) . "' AND RDB\$UNIQUE_FLAG IS NULL AND RDB\$FOREIGN_KEY IS NULL"; $col = 'index_name'; @@ -2400,12 +2400,14 @@ class updater_db_tools case 'oracle': $sql = "SELECT index_name FROM user_indexes - WHERE table_name = '" . $table_name . "' - AND generated = 'N'"; + WHERE table_name = '" . strtoupper($table_name) . "' + AND generated = 'N' + AND uniqueness = 'NONUNIQUE'"; + $col = 'index_name'; break; case 'sqlite': - $sql = "PRAGMA index_info('" . $table_name . "');"; + $sql = "PRAGMA index_list('" . $table_name . "');"; $col = 'name'; break; } @@ -2418,6 +2420,135 @@ class updater_db_tools continue; } + // These DBMS prefix index name with the table name + switch ($this->sql_layer) + { + case 'firebird': + case 'oracle': + case 'postgres': + case 'sqlite': + $row[$col] = substr($row[$col], strlen($table_name) + 1); + break; + } + + if (strtolower($row[$col]) == strtolower($index_name)) + { + $this->db->sql_freeresult($result); + return true; + } + } + $this->db->sql_freeresult($result); + + return false; + } + + /** + * Check if a specified UNIQUE index exists in table. + * + * @param string $table_name Table to check the index at + * @param string $index_name The index name to check + * + * @return bool True if index exists, else false + */ + function sql_unique_index_exists($table_name, $index_name) + { + if ($this->sql_layer == 'mssql') + { + $sql = "EXEC sp_statistics '$table_name'"; + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + // Usually NON_UNIQUE is the column we want to check, but we allow for both + if ($row['TYPE'] == 3) + { + if (strtolower($row['INDEX_NAME']) == strtolower($index_name)) + { + $this->db->sql_freeresult($result); + return true; + } + } + } + $this->db->sql_freeresult($result); + return false; + } + + switch ($this->sql_layer) + { + case 'firebird': + $sql = "SELECT LOWER(RDB\$INDEX_NAME) as index_name + FROM RDB\$INDICES + WHERE RDB\$RELATION_NAME = '" . strtoupper($table_name) . "' + AND RDB\$UNIQUE_FLAG IS NOT NULL + AND RDB\$FOREIGN_KEY IS NULL"; + $col = 'index_name'; + break; + + case 'postgres': + $sql = "SELECT ic.relname as index_name, i.indisunique + FROM pg_class bc, pg_class ic, pg_index i + WHERE (bc.oid = i.indrelid) + AND (ic.oid = i.indexrelid) + AND (bc.relname = '" . $table_name . "') + AND (i.indisprimary != 't')"; + $col = 'index_name'; + break; + + case 'mysql_40': + case 'mysql_41': + $sql = 'SHOW KEYS + FROM ' . $table_name; + $col = 'Key_name'; + break; + + case 'oracle': + $sql = "SELECT index_name, table_owner + FROM user_indexes + WHERE table_name = '" . strtoupper($table_name) . "' + AND generated = 'N' + AND uniqueness = 'UNIQUE' + AND index_name LIKE 'U_%'"; + $col = 'index_name'; + break; + + case 'sqlite': + $sql = "PRAGMA index_list('" . $table_name . "') WHERE unique = 1;"; + $col = 'name'; + break; + } + + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (($this->sql_layer == 'mysql_40' || $this->sql_layer == 'mysql_41') && ($row['Non_unique'] || $row[$col] == 'PRIMARY')) + { + continue; + } + + if ($this->sql_layer == 'sqlite' && !$row['unique']) + { + continue; + } + + if ($this->sql_layer == 'postgres' && $row['indisunique'] != 't') + { + continue; + } + + // These DBMS prefix index name with the table name + switch ($this->sql_layer) + { + case 'oracle': + $row[$col] = substr($row[$col], strlen('U_' . $row['table_owner']) + 1); + break; + + case 'firebird': + case 'postgres': + case 'sqlite': + $row[$col] = substr($row[$col], strlen($table_name) + 1); + break; + } + if (strtolower($row[$col]) == strtolower($index_name)) { $this->db->sql_freeresult($result); @@ -2562,11 +2693,13 @@ class updater_db_tools // For hexadecimal values do not use single quotes if (strpos($column_data[1], '0x') === 0) { - $sql_default .= 'DEFAULT (' . $column_data[1] . ') '; + $return_array['default'] = 'DEFAULT (' . $column_data[1] . ') '; + $sql_default .= $return_array['default']; } else { - $sql_default .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; + $return_array['default'] = 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; + $sql_default .= $return_array['default']; } } @@ -3086,6 +3219,27 @@ class updater_db_tools case 'mssql': $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; + + if (!empty($column_data['default'])) + { + // Using TRANSACT-SQL for this statement because we do not want to have colliding data if statements are executed at a later stage + $statements[] = "DECLARE @drop_default_name VARCHAR(100), @cmd VARCHAR(1000) + SET @drop_default_name = + (SELECT so.name FROM sysobjects so + JOIN sysconstraints sc ON so.id = sc.constid + WHERE object_name(so.parent_obj) = '{$table_name}' + AND so.xtype = 'D' + AND sc.colid = (SELECT colid FROM syscolumns + WHERE id = object_id('{$table_name}') + AND name = '{$column_name}')) + IF @drop_default_name <> '' + BEGIN + SET @cmd = 'ALTER TABLE [{$table_name}] DROP CONSTRAINT [' + @drop_default_name + ']' + EXEC(@cmd) + END + SET @cmd = 'ALTER TABLE [{$table_name}] ADD CONSTRAINT [DF_{$table_name}_{$column_name}_1] {$column_data['default']} FOR [{$column_name}]' + EXEC(@cmd)"; + } break; case 'mysql_40': -- cgit v1.2.1 From 3e0bf1f8a4c5a7c6cb39ccb52ea37f49b658c15f Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 25 Sep 2009 09:41:49 +0000 Subject: prepare for RC2 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10187 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ee4d45c57c..7ef76535d3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1510,14 +1510,8 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; - // Changes from 3.0.6-RC1 to 3.0.6-RC2 + // No changes from 3.0.6-RC1 to 3.0.6-RC2 case '3.0.6-RC1': - - // We check if there is an index for log_time within the logs table - - - // If so, we remove it - break; } } -- cgit v1.2.1 From 8525e97c285919d47b966b3c7582d79d75d84a43 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Oct 2009 11:10:16 +0000 Subject: Bug #52415 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10205 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7ef76535d3..ce223cf302 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.6-RC2'; +$updates_to_version = '3.0.6-RC3'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -883,6 +883,8 @@ function database_update_info() LOG_TABLE => array('log_time'), ), ), + // No changes from 3.0.6-RC2 to 3.0.6-RC3 + '3.0.6-RC2' => array(), ); } @@ -1513,6 +1515,19 @@ function change_database_data(&$no_updates, $version) // 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; } } -- cgit v1.2.1 From 30f3ba83e3a29373139ce6147a9c37ec09ba7d61 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 22 Oct 2009 14:35:56 +0000 Subject: sneaks in and changes the version number. Seems like we see no RC4... git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10228 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ce223cf302..8545f88e09 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.6-RC3'; +$updates_to_version = '3.0.6'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -885,6 +885,8 @@ function database_update_info() ), // 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 + '3.0.6-RC3' => array(), ); } @@ -1528,6 +1530,10 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // No changes from 3.0.6-RC3 to 3.0.6 + case '3.0.6-RC3': + break; } } -- cgit v1.2.1 From 110f81684e9a007d67c2d867f4da8228f7130d64 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 28 Oct 2009 16:05:17 +0000 Subject: I am very sorry... but the changes require (a hopefully very short) RC4 phase git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10241 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8545f88e09..e3667e3f3c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.6'; +$updates_to_version = '3.0.6-RC4'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -885,7 +885,7 @@ function database_update_info() ), // 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 + // No changes from 3.0.6-RC3 to 3.0.6-RC4 '3.0.6-RC3' => array(), ); } @@ -1531,7 +1531,7 @@ function change_database_data(&$no_updates, $version) break; - // No changes from 3.0.6-RC3 to 3.0.6 + // No changes from 3.0.6-RC3 to 3.0.6-RC4 case '3.0.6-RC3': break; } -- cgit v1.2.1 From 5553cfc2ed81ba9eb571804c431def962720b39e Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 30 Oct 2009 19:19:48 +0000 Subject: Several fixes: Fix Bug #53335 Fix wrong unique index fetch for oracle and sqlite Fix alter column definition for firebird (although the query will fail in these circumstances [primary key] because firebird (again) does not support simple things... although... mssql/oracle having the same "problems", but there you are able to do more advanced queries) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10248 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 69 +++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 18 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e3667e3f3c..e3511e89a4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -346,11 +346,15 @@ for ($i = 0; $i < sizeof($versions); $i++) $no_updates = false; - $statements = $db_tools->perform_schema_changes($schema_changes); - - foreach ($statements as $sql) + // We run one index after the other... to be consistent with schema changes... + foreach ($schema_changes as $key => $changes) { - _sql($sql, $errored, $error_ary); + $statements = $db_tools->perform_schema_changes(array($key => $changes)); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } } } @@ -716,6 +720,9 @@ function database_update_info() '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'), @@ -724,9 +731,6 @@ function database_update_info() 'group_legend_name' => array('group_legend', 'group_name'), ), ), - 'drop_keys' => array( - GROUPS_TABLE => array('group_legend'), - ), ), // No changes from 3.0.1-RC1 to 3.0.1 '3.0.1-RC1' => array(), @@ -1053,10 +1057,21 @@ function change_database_data(&$no_updates, $version) // Changes from 3.0.3-RC1 to 3.0.3 case '3.0.3-RC1': - $sql = 'UPDATE ' . LOG_TABLE . " - SET log_operation = 'LOG_DELETE_TOPIC' - WHERE log_operation = 'LOG_TOPIC_DELETED'"; - _sql($sql, $errored, $error_ary); + 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; @@ -1199,6 +1214,18 @@ function change_database_data(&$no_updates, $version) 'drop_keys' => array( ACL_OPTIONS_TABLE => array('auth_option'), ), + ); + + global $db_tools; + + $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'), @@ -1206,8 +1233,6 @@ function change_database_data(&$no_updates, $version) ), ); - global $db_tools; - $statements = $db_tools->perform_schema_changes($changes); foreach ($statements as $sql) @@ -2521,13 +2546,12 @@ class updater_db_tools FROM user_indexes WHERE table_name = '" . strtoupper($table_name) . "' AND generated = 'N' - AND uniqueness = 'UNIQUE' - AND index_name LIKE 'U_%'"; + AND uniqueness = 'UNIQUE'"; $col = 'index_name'; break; case 'sqlite': - $sql = "PRAGMA index_list('" . $table_name . "') WHERE unique = 1;"; + $sql = "PRAGMA index_list('" . $table_name . "');"; $col = 'name'; break; } @@ -2554,7 +2578,15 @@ class updater_db_tools switch ($this->sql_layer) { case 'oracle': - $row[$col] = substr($row[$col], strlen('U_' . $row['table_owner']) + 1); + // Two cases here... prefixed with U_[table_owner] and not prefixed with table_name + if (strpos($row[$col], 'U_') === 0) + { + $row[$col] = substr($row[$col], strlen('U_' . $row['table_owner']) + 1); + } + else if (strpos($row[$col], strtoupper($table_name)) === 0) + { + $row[$col] = substr($row[$col], strlen($table_name) + 1); + } break; case 'firebird': @@ -3228,7 +3260,8 @@ class updater_db_tools } else { - $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql']; + // TODO: try to change pkey without removing trigger, generator or constraints. ATM this query may fail. + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN "' . strtoupper($column_name) . '" TYPE ' . ' ' . $column_data['column_type_sql_type']; } break; -- cgit v1.2.1 From 46112228c08d1ca935eba34ddd849eb9f7de6cf8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 14 Nov 2009 20:11:38 +0000 Subject: Tag as 3.0.6 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10267 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e3511e89a4..8cac19fdbc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.6-RC4'; +$updates_to_version = '3.0.6'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -891,6 +891,8 @@ function database_update_info() '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(), ); } @@ -1559,6 +1561,10 @@ function change_database_data(&$no_updates, $version) // 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-RC3': + break; } } -- cgit v1.2.1 From e4d1addc2c74e84a737c5ca91f3f3379fb648c33 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 14 Nov 2009 21:27:24 +0000 Subject: Fix Bug #53945 - Typo in r10267. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10269 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8cac19fdbc..5eeb449019 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1563,7 +1563,7 @@ function change_database_data(&$no_updates, $version) break; // No changes from 3.0.6-RC4 to 3.0.6 - case '3.0.6-RC3': + case '3.0.6-RC4': break; } } -- cgit v1.2.1 From a5c9a2f36e569b88d0d9867f955eafc8e0606560 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 4 Dec 2009 11:50:03 +0000 Subject: Since dl() is deprecated and disabled by default in PHP 5.3, calling it will result in a fatal error for an undefined function and because of the error suppression in a blank page. Checking if dl() exists should allow most boards to continue right away. - Bug #54665 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10298 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 5eeb449019..b7cfdd36b9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -45,7 +45,7 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) } // Load Extensions -if (!empty($load_extensions)) +if (!empty($load_extensions) && function_exists('dl')) { $load_extensions = explode(',', $load_extensions); -- cgit v1.2.1 From fe6958d54f0b82a9dfd678005561d729f1ffcd44 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 6 Dec 2009 02:30:24 +0000 Subject: PHP 5.3 compatibility: Disable E_DEPRECATED on startup to keep set_magic_quotes_runtime(0) quiet. [Bug #54495] git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10299 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b7cfdd36b9..bf9c183e0c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -30,8 +30,12 @@ define('IN_INSTALL', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); -// Report all errors, except notices -//error_reporting(E_ALL ^ E_NOTICE); +// Report all errors, except notices and deprecation messages +if (!defined('E_DEPRECATED')) +{ + define('E_DEPRECATED', 8192); +} +//error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); error_reporting(E_ALL); @set_time_limit(0); -- cgit v1.2.1 From bc0cc313dfc2fc175f51af8d84f3ee21d0873dee Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 22 Dec 2009 18:13:17 +0000 Subject: Bump database updater version to 3.0.7-dev git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10362 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index bf9c183e0c..acbc241c4d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.6'; +$updates_to_version = '3.0.7-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -897,6 +897,9 @@ function database_update_info() '3.0.6-RC3' => array(), // No changes from 3.0.6-RC4 to 3.0.6 '3.0.6-RC4' => array(), + + // No changes from 3.0.6 to 3.0.7-RC1 + '3.0.6' => array(), ); } @@ -1569,6 +1572,10 @@ function change_database_data(&$no_updates, $version) // No changes from 3.0.6-RC4 to 3.0.6 case '3.0.6-RC4': break; + + // No changes from 3.0.6 to 3.0.7-RC1 + case '3.0.6': + break; } } -- cgit v1.2.1 From d0c596a5eaab7439a3b32af8b9a14c12f9ae18e2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 22 Dec 2009 19:21:41 +0000 Subject: Add ability to disable overall (aka board-wide) feed. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10363 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index acbc241c4d..2f8cb53be2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1573,8 +1573,12 @@ function change_database_data(&$no_updates, $version) case '3.0.6-RC4': break; - // No changes from 3.0.6 to 3.0.7-RC1 + // Changes from 3.0.6 to 3.0.7-RC1 case '3.0.6': + + // ATOM Feeds + set_config('feed_overall', '1'); + break; } } -- cgit v1.2.1 From a4cee51de51bfbdfe4af52ac00d9fa62857d6a92 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 23 Dec 2009 02:30:37 +0000 Subject: Split feed_limit into feed_limit_post and feed_limit_topic. Drop feed_overall_topics_limit. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10366 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 2f8cb53be2..6da4ab3f76 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1578,6 +1578,8 @@ function change_database_data(&$no_updates, $version) // ATOM Feeds set_config('feed_overall', '1'); + 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)); break; } -- cgit v1.2.1 From ad7e3ccf4c8d233744cd7408f42484405f7d9c48 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 27 Dec 2009 00:48:52 +0000 Subject: Integrate active topics feed. Some language adjustments and rearrangements. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10382 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 6da4ab3f76..41fd9a2136 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1580,6 +1580,8 @@ function change_database_data(&$no_updates, $version) set_config('feed_overall', '1'); 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')); break; } -- cgit v1.2.1 From 77af6caed7300c7498016b4b3d30d31f2bcca730 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 19 Jan 2010 19:08:51 +0000 Subject: [Feature] Ability to use HTTP authentication in ATOM feeds by passing the GET parameter auth=http git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10430 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 41fd9a2136..21767c20da 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1578,6 +1578,7 @@ function change_database_data(&$no_updates, $version) // 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')); -- cgit v1.2.1 From 5306a586b17d0c85d6a52dea994806bbb1891e50 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 25 Jan 2010 18:42:04 +0000 Subject: Revert r9564, Fix #54445, Related to #44665. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10445 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 21767c20da..31911b4a6c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -885,12 +885,9 @@ function database_update_info() ), ), ), - // Changes from 3.0.6-RC1 to 3.0.6-RC2 - '3.0.6-RC1' => array( - 'drop_keys' => array( - LOG_TABLE => array('log_time'), - ), - ), + + // 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 @@ -898,8 +895,12 @@ function database_update_info() // No changes from 3.0.6-RC4 to 3.0.6 '3.0.6-RC4' => array(), - // No changes from 3.0.6 to 3.0.7-RC1 - '3.0.6' => array(), + // Changes from 3.0.6 to 3.0.7-RC1 + '3.0.6' => array( + 'drop_keys' => array( + LOG_TABLE => array('log_time'), + ), + ), ); } -- cgit v1.2.1 From 870921c87231c1e637de76295914be53b846469a Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 26 Jan 2010 02:06:37 +0000 Subject: Database updater now separates ADD COLUMN from SET NOT NULL and SET DEFAULT, when using PostgreSQL <= 7.4 [Bug #54435] git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10446 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 31911b4a6c..36a09e5ec4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2924,7 +2924,29 @@ class updater_db_tools case 'postgres': // Does not support AFTER, only through temporary table - $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; + + if (version_compare($this->db->sql_server_info(true), '8.0', '>=')) + { + $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type_sql']; + } + else + { + // old versions cannot add columns with default and null information + $statements[] = 'ALTER TABLE ' . $table_name . ' ADD COLUMN "' . $column_name . '" ' . $column_data['column_type'] . ' ' . $column_data['constraint']; + + if (isset($column_data['null'])) + { + if ($column_data['null'] == 'NOT NULL') + { + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN ' . $column_name . ' SET NOT NULL'; + } + } + + if (isset($column_data['default'])) + { + $statements[] = 'ALTER TABLE ' . $table_name . ' ALTER COLUMN ' . $column_name . ' SET DEFAULT ' . $column_data['default']; + } + } break; case 'sqlite': -- cgit v1.2.1 From 6e31ce85733a3269261e005a90d0291bf6e0a36b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 26 Jan 2010 16:52:46 +0000 Subject: Do not store email templates in database. [Bug #54505] To explain what this is about, first a short phpBB code history lesson: ;-) r9823 originally introduced the usage of our template class for emails. The messenger class uses set_custom_template() to initialise the template object which neither disables storedb nor inheritance. These two values are set in $user->theme rather than inside a particular template instance (quite a design failure if I may add). Thus the html page that is displayed to the user also determines these settings for the email templates. This obviously causes problems because both emails and other custom templates can quite simply not be stored in the database because the db table only stores the filename, not the path and requires a template id. r9839 then generally disabled storedb and template inheritance for custom templates to fix Bug #40515. This works for custom templates, but not for emails where lots of template objects are created. In such a situation the last call to set(_custom)_template() would now determine the values of storedb and inheritance in _tpl_load. So any page sending emails would neither load its template from the database nor use template inheritance. The same revision also introduced orig_tpl_* variables in set_template() which on their own are very much pointless, but could allow resetting the storedb and inheritance values if they were used to reset $user->theme just before template execution in _tpl_load. In r10150 these orig_tpl_* variables are correctly used to access information about the template of the page being displayed - contrary to the last template used - from within the bbcode, fixing Bug #51285. However r10150 also introduces a pointless $template_mode parameter for set_custom_template(). $template_mode is really just a boolean flag (value you can be 'template' or an arbitrary other value) that if it set circumvents the unsetting of storedb and template inheritance. The very code that had been added to prevent issues with emails and custom templates. Fixing the problem introduced by r8839 but at the same time reintroducing the much greater problem from the original implementation of email templates. And now an explanation of what I did: Based on this I have now changed the set_custom_template method to always disable storedb. It can now properly use inheritance, you simply tell it the path where the parent template can be found, by default the path is false which will turn inheritance off. To make this work the template class now always overwrites $user->theme storedb and inheritance variabbles with orig_tpl_* just before rendering a template in _tpl_load. This way they are guaranteed to always contain the value they had at the time set_template/set_custom_template were called. This fixes [Bug #54505]. In summary, using global state is simply a horrible idea in object oriented programming. Always Pass values, that an object depends on, as parameters - never through magic global variables. Following this principle will safe you from a lot of headaches. Please test this patch as much as possible to make sure templates still work properly for you, focus on multiple languages, missing language files, and custom templates in systems that make use of the template class outside of phpBB itself. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10460 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 36a09e5ec4..c338df0b80 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1585,6 +1585,12 @@ function change_database_data(&$no_updates, $version) 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; } } -- cgit v1.2.1 From 2906a24122535856f5a195264dc1d9a6836e0bcd Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 28 Jan 2010 23:15:25 +0000 Subject: Bug #56545 - Speed up topic move operation by adding an index for topic_id on the topics track table. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10462 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c338df0b80..c7205de89d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -900,6 +900,11 @@ function database_update_info() 'drop_keys' => array( LOG_TABLE => array('log_time'), ), + 'add_index' => array( + TOPICS_TRACK_TABLE => array( + 'topic_id' => array('topic_id'), + ), + ), ), ); } -- cgit v1.2.1 From 5a429ee61e54f78da1120395c05d9fb5a2af7d04 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 1 Feb 2010 01:14:06 +0000 Subject: Change version numbers to 3.0.7 and 3.0.8-dev in preparation for development on next release git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10468 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index c7205de89d..4efc52088f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.7-dev'; +$updates_to_version = '3.0.8-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; -- cgit v1.2.1 From 1802b9ff9286a7fc24493e71b3432816cbdbfcd8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 11 Feb 2010 00:02:51 +0000 Subject: Support for Microsoft's Native SQL Server Driver for PHP - Patch by Chris Pucci at Microsoft [Bug #57055] If you are using SQL Server, please try to test this new dbal so we can safely include it in 3.0.8. If you want to try it on a current phpBB version you can apply the latest version of the patch to your board which you can find attached to the bug tracker ticket (look in the comments for the latest version, the one in the ticket itself is outdated): http://www.phpbb.com/bugs/phpbb3/ticket.php?ticket_id=57055 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10489 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 51 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4efc52088f..055fa78995 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1743,7 +1743,37 @@ class updater_db_tools 'VCHAR_CI' => '[varchar] (255)', 'VARBINARY' => '[varchar] (255)', ), - + + 'mssqlnative' => array( + 'INT:' => '[int]', + 'BINT' => '[float]', + 'UINT' => '[int]', + 'UINT:' => '[int]', + 'TINT:' => '[int]', + 'USINT' => '[int]', + 'BOOL' => '[int]', + 'VCHAR' => '[varchar] (255)', + 'VCHAR:' => '[varchar] (%d)', + 'CHAR:' => '[char] (%d)', + 'XSTEXT' => '[varchar] (1000)', + 'STEXT' => '[varchar] (3000)', + 'TEXT' => '[varchar] (8000)', + 'MTEXT' => '[text]', + 'XSTEXT_UNI'=> '[varchar] (100)', + 'STEXT_UNI' => '[varchar] (255)', + 'TEXT_UNI' => '[varchar] (4000)', + 'MTEXT_UNI' => '[text]', + 'TIMESTAMP' => '[int]', + 'DECIMAL' => '[float]', + 'DECIMAL:' => '[float]', + 'PDECIMAL' => '[float]', + 'PDECIMAL:' => '[float]', + 'VCHAR_UNI' => '[varchar] (255)', + 'VCHAR_UNI:'=> '[varchar] (%d)', + 'VCHAR_CI' => '[varchar] (255)', + 'VARBINARY' => '[varchar] (255)', + ), + 'oracle' => array( 'INT:' => 'number(%d)', 'BINT' => 'number(20)', @@ -1845,7 +1875,7 @@ class updater_db_tools * A list of supported DBMS. We change this class to support more DBMS, the DBMS itself only need to follow some rules. * @var array */ - var $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); + var $supported_dbms = array('firebird', 'mssql', 'mssqlnative', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); /** * This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). @@ -1890,6 +1920,10 @@ class updater_db_tools case 'mssql_odbc': $this->sql_layer = 'mssql'; break; + + case 'mssqlnative': + $this->sql_layer = 'mssqlnative'; + break; default: $this->sql_layer = $this->db->sql_layer; @@ -2322,6 +2356,7 @@ class updater_db_tools // same deal with PostgreSQL, we must perform more complex operations than // we technically could case 'mssql': + case 'mssqlnative': $sql = "SELECT c.name FROM syscolumns c LEFT JOIN sysobjects o ON c.id = o.id @@ -2425,7 +2460,7 @@ class updater_db_tools */ function sql_index_exists($table_name, $index_name) { - if ($this->sql_layer == 'mssql') + if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative') { $sql = "EXEC sp_statistics '$table_name'"; $result = $this->db->sql_query($sql); @@ -2530,7 +2565,7 @@ class updater_db_tools */ function sql_unique_index_exists($table_name, $index_name) { - if ($this->sql_layer == 'mssql') + if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative') { $sql = "EXEC sp_statistics '$table_name'"; $result = $this->db->sql_query($sql); @@ -2769,6 +2804,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $sql .= " {$column_type} "; $sql_default = " {$column_type} "; @@ -2918,6 +2954,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': // Does not support AFTER, only through temporary table $statements[] = 'ALTER TABLE [' . $table_name . '] ADD [' . $column_name . '] ' . $column_data['column_type_sql_default']; break; @@ -3042,6 +3079,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; break; @@ -3136,6 +3174,7 @@ class updater_db_tools switch ($this->sql_layer) { case 'mssql': + case 'mssqlnative': $statements[] = 'DROP INDEX ' . $table_name . '.' . $index_name; break; @@ -3172,6 +3211,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $sql = "ALTER TABLE [{$table_name}] WITH NOCHECK ADD "; $sql .= "CONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED ("; $sql .= '[' . implode("],\n\t\t[", $column) . ']'; @@ -3265,6 +3305,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; break; } @@ -3294,6 +3335,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; break; } @@ -3326,6 +3368,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; if (!empty($column_data['default'])) -- cgit v1.2.1 From 68cac354aac9df3866944685186733c4d7305aee Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 17 Feb 2010 12:58:52 +0000 Subject: Add 3.0.7-RC1 to the updater. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10497 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 055fa78995..909c390a9e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -906,6 +906,9 @@ function database_update_info() ), ), ), + + // No changes from 3.0.7-RC1 to 3.0.7 + '3.0.7-RC1' => array(), ); } @@ -1597,6 +1600,10 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // No changes from 3.0.7-RC1 to 3.0.7 + case '3.0.7-RC1': + break; } } -- cgit v1.2.1 From 30b83896a1718400307de7d531c16a152c0f6668 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 18 Feb 2010 01:17:30 +0000 Subject: Fix Bug #57755 - Make user_email_hash() function independent from system's architecture. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10499 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 909c390a9e..29d82be987 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1603,6 +1603,34 @@ function change_database_data(&$no_updates, $version) // No changes from 3.0.7-RC1 to 3.0.7 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)) + { + $user_email_hash = phpbb_email_hash($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); + break; } } -- cgit v1.2.1 From c02fedb6c7a80da0be5bd84fe512b3ba6df9f9ee Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 18 Feb 2010 02:01:32 +0000 Subject: Revising r10499, #57755 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10503 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 29d82be987..5cb2cd28cc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1601,7 +1601,7 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; - // No changes from 3.0.7-RC1 to 3.0.7 + // Changes from 3.0.7-RC1 to 3.0.7 case '3.0.7-RC1': $sql = 'SELECT user_id, user_email, user_email_hash @@ -1624,13 +1624,15 @@ function change_database_data(&$no_updates, $version) $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)); + _sql($sql, $errored, $error_ary, ($i % 100 == 0)); ++$i; } } $db->sql_freeresult($result); + $no_updates = false; + break; } } -- cgit v1.2.1 From 576722cead7f2de34db3e5a853662bca0e0601da Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 18 Feb 2010 02:06:20 +0000 Subject: Adding 3.0.7-RC2 to database updater git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10504 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 5cb2cd28cc..4db78331bd 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -907,8 +907,10 @@ function database_update_info() ), ), - // No changes from 3.0.7-RC1 to 3.0.7 + // 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(), ); } @@ -1601,7 +1603,7 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; - // Changes from 3.0.7-RC1 to 3.0.7 + // 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 @@ -1634,6 +1636,10 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // No changes from 3.0.7-RC2 to 3.0.7 + case '3.0.7-RC2': + break; } } -- cgit v1.2.1 From e8f01ff74b58d9d73ff3c32507d843b8b14d92e5 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 22 Feb 2010 19:33:27 +0000 Subject: We have to use a 'snapshot' of the function there, because it might not be available yet. - Bug #57755 git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10520 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4db78331bd..df8aadfdb2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1615,7 +1615,9 @@ function change_database_data(&$no_updates, $version) $i = 0; while ($row = $db->sql_fetchrow($result)) { - $user_email_hash = phpbb_email_hash($row['user_email']); + // 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']) { -- cgit v1.2.1