From a9ad99302a723cd00725f57b27e9d85303d48e5a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 26 Jun 2010 00:51:13 +0200 Subject: [ticket/9684] Move currently existing GAs to a selectable forum while updating. PHPBB3-9684 --- phpBB/install/database_update.php | 140 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index cf611ca951..0d3e96f342 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -177,6 +177,69 @@ $database_update_info = database_update_info(); $error_ary = array(); $errored = false; +$sql = 'SELECT topic_id + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; +$result = $db->sql_query_limit($sql, 1); +$has_global = (int) $db->sql_fetchfield('topic_id'); +$db->sql_freeresult($result); +$ga_forum_id = request_var('ga_forum_id', 0); + +if ($has_global && !$ga_forum_id) +{ + ?> + + + + + + + + + + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> + + + + + + +
+ + +
+
+
+ +
+
+ +

+ +
+ +
+ + + + +
+ @@ -1962,6 +2025,83 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Localise Global Announcements + $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = 0 + AND topic_type = ' . POST_GLOBAL; + $result = $db->sql_query($sql); + + $global_announcements = $update_lastpost_data = array(); + $update_lastpost_data['forum_last_post_time'] = 0; + $update_forum_data = array( + 'forum_posts' => 0, + 'forum_topics' => 0, + 'forum_topics_real' => 0, + ); + + while ($row = $db->sql_fetchrow($result)) + { + $global_announcements[] = (int) $row['topic_id']; + + $update_forum_data['forum_posts'] += (int) $row['topic_posts']; + $update_forum_data['forum_topics_real']++; + if ($row['topic_approved']) + { + $update_forum_data['forum_topics']++; + } + + if ($update_lastpost_data['forum_last_post_time'] < $row['topic_last_post_time']) + { + $update_lastpost_data = array( + 'forum_last_post_id' => (int) $row['topic_last_post_id'], + 'forum_last_post_subject' => $row['topic_last_post_subject'], + 'forum_last_post_time' => (int) $row['topic_last_post_time'], + 'forum_last_poster_id' => (int) $row['topic_last_poster_id'], + 'forum_last_poster_name' => $row['topic_last_poster_name'], + 'forum_last_poster_colour' => $row['topic_last_poster_colour'], + ); + } + } + $db->sql_freeresult($result); + + if (!empty($global_announcements)) + { + // Update the post/topic-count for the forum and the last-post if needed + $ga_forum_id = request_var('ga_forum_id', 0); + + $sql = 'SELECT forum_last_post_time + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $ga_forum_id; + $result = $db->sql_query($sql); + $lastpost = (int) $db->sql_fetchfield('forum_last_post_time'); + $db->sql_freeresult($result); + + $sql_update = 'forum_posts = forum_posts + ' . $update_forum_data['forum_posts'] . ', '; + $sql_update .= 'forum_topics_real = forum_topics_real + ' . $update_forum_data['forum_topics_real'] . ', '; + $sql_update .= 'forum_topics = forum_topics + ' . $update_forum_data['forum_topics']; + if ($lastpost < $update_lastpost_data['forum_last_post_time']) + { + $sql_update .= ', ' . $db->sql_build_array('UPDATE', $update_lastpost_data); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $sql_update . ' + WHERE forum_id = ' . $ga_forum_id; + _sql($sql, $errored, $error_ary); + + // Update some forum_ids + $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $ga_forum_id + WHERE " . $db->sql_in_set('topic_id', $global_announcements); + _sql($sql, $errored, $error_ary); + } + unset($table_ary); + } + $no_updates = false; break; } -- cgit v1.2.1 From 85055ac97fa57ca339924cef719115d85bdf6c2e Mon Sep 17 00:00:00 2001 From: David M Date: Thu, 3 Jan 2008 17:00:40 +0000 Subject: oh boy... - Migrate code base to PHP 5.1+ git-svn-id: file:///svn/phpbb/trunk@8295 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 942 +------------------------------------- 1 file changed, 2 insertions(+), 940 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fc9ce65dac..82a491fc08 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -83,7 +83,7 @@ else } $user = new user(); -$cache = new cache(); +$cache = new acm(); $db = new $sql_db(); // Add own hook handler, if present. :o @@ -92,7 +92,7 @@ if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); - foreach ($cache->obtain_hooks() as $hook) + foreach (cache::obtain_hooks() as $hook) { @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); } @@ -337,142 +337,6 @@ $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), - ), - ), - ), ); // Determine mapping database type @@ -581,440 +445,6 @@ else // Checks/Operations that have to be completed prior to starting the update itself $exit = false; -if (version_compare($current_version, '3.0.RC8', '<=')) -{ - // 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', - )); - } -?> -

- -

- -
- - '')); - $new_usernames = request_var('new_usernames', array(0 => ''), true); - - if (!class_exists('utf_new_normalizer')) - { - 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); - } - - // the admin decided to change some usernames - if (sizeof($modify_users) && $submit) - { - $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); - - $users = 0; - while ($row = $db->sql_fetchrow($result)) - { - $users++; - $user_id = (int) $row['user_id']; - - if (isset($modify_users[$user_id])) - { - $row['action'] = $modify_users[$user_id]; - $modify_users[$user_id] = $row; - } - } - $db->sql_freeresult($result); - - // 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; - } - } - } - } -?> - -

-

:: - -sql_query($sql); - - $colliding_users = $found_names = array(); - $echos = 0; - - 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); - - $user_ids = array($user_id); - while ($row = $db->sql_fetchrow($result2)) - { - // For not trimmed entries this could happen, yes. ;) - if ($row['user_id'] == $user_id) - { - continue; - } - - // 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); - - // 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; - } - } - } - - if (($echos % 1000) == 0) - { - echo '.'; - flush(); - } - $echos++; - } - $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); - - $sql = 'SELECT * - FROM ' . USERS_TABLE . ' - WHERE ' . $db->sql_in_set('user_id', $user_ids); - $result = $db->sql_query($sql); - - $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) { @@ -1178,374 +608,6 @@ 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; -} - -if (version_compare($current_version, '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); - } - - $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'); - } - - // 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; -} - -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; -} _write_result($no_updates, $errored, $error_ary); -- cgit v1.2.1 From 57645ad5bc2469e166cb3e5d54628d87ffa74c42 Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 6 Jan 2008 02:21:44 +0000 Subject: the end of an era... - MySQL < 4.1.3 support is removed - renamed mysql4 to mysql, no need to cause confusion - changed the cfg cacher, reduces file system lookups and include count by two on every page load git-svn-id: file:///svn/phpbb/trunk@8307 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 86 ++++++++------------------------------- 1 file changed, 16 insertions(+), 70 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 82a491fc08..d0dbada4b4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -142,7 +142,7 @@ $inline_update = (request_var('type', 0)) ? true : false; // Database column types mapping $dbms_type_map = array( - 'mysql_41' => array( + 'mysql' => array( 'INT:' => 'int(%d)', 'BINT' => 'bigint(20)', 'UINT' => 'mediumint(8) UNSIGNED', @@ -169,33 +169,6 @@ $dbms_type_map = array( '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', @@ -342,26 +315,11 @@ $database_update_info = array( // Determine mapping database type switch ($db->sql_layer) { - case 'mysql': - $map_dbms = 'mysql_40'; - break; - - case 'mysql4': - if (version_compare($db->mysql_version, '4.1.3', '>=')) - { - $map_dbms = 'mysql_41'; - } - else - { - $map_dbms = 'mysql_40'; - } - break; case 'mysqli': - $map_dbms = 'mysql_41'; + $map_dbms = 'mysql'; break; - case 'mssql': case 'mssql_odbc': $map_dbms = 'mssql'; break; @@ -643,7 +601,6 @@ switch ($db->sql_layer) { case 'mysql': case 'mysqli': - case 'mysql4': $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; _sql($sql, $errored, $error_ary); break; @@ -792,8 +749,7 @@ function column_exists($dbms, $table, $column_name) switch ($dbms) { - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = "SHOW COLUMNS FROM $table"; $result = $db->sql_query($sql); @@ -1037,8 +993,7 @@ function prepare_column_data($dbms, $column_data, $table_name, $column_name) $return_array['column_type_sql_default'] = $sql_default; break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql .= " {$column_type} "; // For hexadecimal values do not use single quotes @@ -1054,7 +1009,7 @@ function prepare_column_data($dbms, $column_data, $table_name, $column_name) { $sql .= ' auto_increment'; } - else if ($dbms === 'mysql_41' && $column_data[2] == 'true_sort') + else if ($column_data[2] == 'true_sort') { $sql .= ' COLLATE utf8_unicode_ci'; } @@ -1144,8 +1099,7 @@ function sql_column_add($dbms, $table_name, $column_name, $column_data) _sql($sql, $errored, $error_ary); break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'ALTER TABLE `' . $table_name . '` ADD COLUMN `' . $column_name . '` ' . $column_data['column_type_sql']; _sql($sql, $errored, $error_ary); break; @@ -1241,8 +1195,7 @@ function sql_column_remove($dbms, $table_name, $column_name) _sql($sql, $errored, $error_ary); break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'ALTER TABLE `' . $table_name . '` DROP COLUMN `' . $column_name . '`'; _sql($sql, $errored, $error_ary); break; @@ -1331,8 +1284,7 @@ function sql_index_drop($dbms, $index_name, $table_name) _sql($sql, $errored, $error_ary); break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'DROP INDEX ' . $index_name . ' ON ' . $table_name; _sql($sql, $errored, $error_ary); break; @@ -1368,8 +1320,7 @@ function sql_create_primary_key($dbms, $table_name, $column) _sql($sql, $errored, $error_ary); break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'ALTER TABLE ' . $table_name . ' ADD PRIMARY KEY (' . implode(', ', $column) . ')'; _sql($sql, $errored, $error_ary); break; @@ -1445,8 +1396,7 @@ function sql_create_unique_index($dbms, $index_name, $table_name, $column) _sql($sql, $errored, $error_ary); break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; _sql($sql, $errored, $error_ary); break; @@ -1473,8 +1423,7 @@ function sql_create_index($dbms, $index_name, $table_name, $column) _sql($sql, $errored, $error_ary); break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; _sql($sql, $errored, $error_ary); break; @@ -1534,8 +1483,7 @@ function sql_list_index($dbms, $table_name) $col = 'index_name'; break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'SHOW KEYS FROM ' . $table_name; $col = 'Key_name'; @@ -1557,7 +1505,7 @@ function sql_list_index($dbms, $table_name) $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - if (($dbms == 'mysql_40' || $dbms == 'mysql_41') && !$row['Non_unique']) + if ($dbms == 'mysql' && !$row['Non_unique']) { continue; } @@ -1628,8 +1576,7 @@ function sql_list_fake($dbms, $table_name) $col = 'index_name'; break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'SHOW KEYS FROM ' . $table_name; $col = 'Key_name'; @@ -1651,7 +1598,7 @@ function sql_list_fake($dbms, $table_name) $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { - if (($dbms == 'mysql_40' || $dbms == 'mysql_41') && !$row['Non_unique']) + if ($dbms == 'mysql' && !$row['Non_unique']) { continue; } @@ -1687,8 +1634,7 @@ function sql_column_change($dbms, $table_name, $column_name, $column_data) _sql($sql, $errored, $error_ary); break; - case 'mysql_40': - case 'mysql_41': + case 'mysql': $sql = 'ALTER TABLE `' . $table_name . '` CHANGE `' . $column_name . '` `' . $column_name . '` ' . $column_data['column_type_sql']; _sql($sql, $errored, $error_ary); break; -- cgit v1.2.1 From 2f08a3606203c1a2c7aad96e2eb65f6fa882d9a8 Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 6 Jan 2008 13:46:20 +0000 Subject: - add DB2 support /me takes a nap git-svn-id: file:///svn/phpbb/trunk@8308 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 d0dbada4b4..1ab63dd321 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -250,6 +250,33 @@ $dbms_type_map = array( 'VARBINARY' => 'raw(255)', ), + 'db2' => array( + 'INT:' => 'integer', + 'BINT' => 'float', + 'UINT' => 'integer', + 'UINT:' => 'integer', + 'TINT:' => 'smallint', + 'USINT' => 'smallint', + 'BOOL' => 'smallint', + 'VCHAR' => 'varchar(255)', + 'VCHAR:' => 'varchar(%d)', + 'CHAR:' => 'char(%d)', + 'XSTEXT' => 'clob(65K)', + 'STEXT' => 'varchar(3000)', + 'TEXT' => 'clob(65K)', + 'MTEXT' => 'clob(16M)', + 'XSTEXT_UNI'=> 'varchar(100)', + 'STEXT_UNI' => 'varchar(255)', + 'TEXT_UNI' => 'clob(65K)', + 'MTEXT_UNI' => 'clob(16M)', + 'TIMESTAMP' => 'integer', + 'DECIMAL' => 'float', + 'VCHAR_UNI' => 'varchar(255)', + 'VCHAR_UNI:'=> 'varchar(%d)', + 'VCHAR_CI' => 'varchar(255)', + 'VARBINARY' => 'varchar(255)', + ), + 'sqlite' => array( 'INT:' => 'int(%d)', 'BINT' => 'bigint(20)', -- cgit v1.2.1 From 5dddcb42aee429bcd77f18ec1ae94677a01b1c3a 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/trunk@8310 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 36 ------------------------------------ 1 file changed, 36 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1ab63dd321..d7cbfea28f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1787,40 +1787,4 @@ function sql_column_change($dbms, $table_name, $column_name, $column_data) } } -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 2928574ed46334bb8dbbb6612a62db3c3654ba12 Mon Sep 17 00:00:00 2001 From: David M Date: Mon, 7 Jan 2008 15:19:38 +0000 Subject: - a few tiny clean ups - a new MS SQL DBAL, it does not work so hot because of issues with the extension it depends on git-svn-id: file:///svn/phpbb/trunk@8313 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index d7cbfea28f..40666c29dc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -340,21 +340,7 @@ $database_update_info = array( ); // Determine mapping database type -switch ($db->sql_layer) -{ - - case 'mysqli': - $map_dbms = 'mysql'; - break; - - case 'mssql_odbc': - $map_dbms = 'mssql'; - break; - - default: - $map_dbms = $db->sql_layer; - break; -} +$map_dbms = $db->dbms_type; $error_ary = array(); $errored = false; @@ -624,10 +610,9 @@ _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 -switch ($db->sql_layer) +switch ($db->dbms_type) { case 'mysql': - case 'mysqli': $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; _sql($sql, $errored, $error_ary); break; -- cgit v1.2.1 From 370e189f156730f3ea602052737fb6995c85c23c Mon Sep 17 00:00:00 2001 From: David M Date: Tue, 8 Jan 2008 06:44:05 +0000 Subject: - make viewforum work again - remove the lower case functions, they were stupid anyway - added some indexes - added a group_name_clean column git-svn-id: file:///svn/phpbb/trunk@8315 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 40666c29dc..1ead7b1a32 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -310,7 +310,7 @@ $dbms_type_map = array( 'UINT' => 'INT4', // unsigned 'UINT:' => 'INT4', // unsigned 'USINT' => 'INT2', // unsigned - 'BOOL' => 'INT2', // unsigned + 'BOOL' => 'boolean', // unsigned 'TINT:' => 'INT2', 'VCHAR' => 'varchar(255)', 'VCHAR:' => 'varchar(%d)', @@ -327,7 +327,7 @@ $dbms_type_map = array( 'DECIMAL' => 'decimal(5,2)', 'VCHAR_UNI' => 'varchar(255)', 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar_ci', + 'VCHAR_CI' => 'varchar(255)', 'VARBINARY' => 'bytea', ), ); -- cgit v1.2.1 From b9b46a8b454b2ad34ff1a15b0cfd7bd9eb969cb6 Mon Sep 17 00:00:00 2001 From: David M Date: Wed, 9 Jan 2008 00:21:29 +0000 Subject: - phpBB now uses a less ancient version of Oracle git-svn-id: file:///svn/phpbb/trunk@8317 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1ead7b1a32..0fa308ceab 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -231,22 +231,25 @@ $dbms_type_map = array( 'TINT:' => 'number(%d)', 'USINT' => 'number(4)', 'BOOL' => 'number(1)', - 'VCHAR' => 'varchar2(255)', - 'VCHAR:' => 'varchar2(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'varchar2(1000)', - 'STEXT' => 'varchar2(3000)', + 'VCHAR' => 'varchar2(255 char)', + 'VCHAR:' => 'varchar2(%d char)', + 'CHAR:' => 'char(%d char)', + 'XSTEXT' => 'varchar2(1000 char)', + 'STEXT' => 'varchar2(3000 char)', 'TEXT' => 'clob', 'MTEXT' => 'clob', - 'XSTEXT_UNI'=> 'varchar2(300)', - 'STEXT_UNI' => 'varchar2(765)', + 'XSTEXT_UNI'=> 'varchar2(100 char)', + 'STEXT_UNI' => 'varchar2(255 char)', '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)', + 'DECIMAL:' => 'number(%d, 2)', + 'PDECIMAL' => 'number(6, 3)', + 'PDECIMAL:' => 'number(%d, 3)', + 'VCHAR_UNI' => 'varchar2(255 char)', + 'VCHAR_UNI:'=> 'varchar2(%d char)', + 'VCHAR_CI' => 'varchar2(255 char)', 'VARBINARY' => 'raw(255)', ), -- cgit v1.2.1 From 2cedbbac0944da85a01f3a3afbac65756610f29d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 23 Feb 2008 14:23:34 +0000 Subject: merge revisions #r8384, #r8387, #r8388, #r8389 and #r8390 git-svn-id: file:///svn/phpbb/trunk@8391 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 0fa308ceab..06eeecbc71 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.1.0'; // Return if we "just include it" to find out for which version the database update is responsuble for if (defined('IN_PHPBB') && defined('IN_INSTALL')) -- cgit v1.2.1 From 3e42df098cedbd4c70f893ea23de7f06df519fe2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 31 Mar 2008 14:58:14 +0000 Subject: merging some changes git-svn-id: file:///svn/phpbb/trunk@8484 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 438 +++++++++++++++++++++++++++++++++++++- 1 file changed, 433 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 06eeecbc71..c0b59ecd5c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -460,16 +460,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; } @@ -581,7 +588,25 @@ flush(); $no_updates = true; +$versions = array( + '3.0.RC2', '3.0.RC3', '3.0.RC4', '3.0.RC5', '3.0.0' +); + // some code magic +for ($i = 0; $i < sizeof($versions); $i++) +{ + $version = $versions[$i]; + $next_version = (isset($versions[$i + 1])) ? $versions[$i + 1] : $updates_to_version; + + // If the installed version to be updated to is < than the current version, and if the current version is >= as the version to be updated to next, we will skip the process + if (version_compare($version, $current_version, '<') && version_compare($current_version, $next_version, '>=')) + { + continue; + } + + $no_updates = false; + change_database_data($version); +} _write_result($no_updates, $errored, $error_ary); @@ -607,7 +632,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 @@ -639,6 +665,8 @@ _write_result($no_updates, $errored, $error_ary); if (!$inline_update) { + // Purge the cache... + $cache->purge(); ?>

@@ -690,6 +718,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 91b4fe1868ca2c4d81111943f781e3cfd0262ef2 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 28 May 2008 13:05:45 +0000 Subject: Merging mime and referer checks into the Trunk git-svn-id: file:///svn/phpbb/trunk@8571 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 9 +++++++-- 1 file changed, 7 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 c0b59ecd5c..277fc055df 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1112,10 +1112,15 @@ function change_database_data($version) _sql($sql, $errored, $error_ary); } } - - // TODO: remove all form token min times break; + + 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 2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 29 May 2008 12:25:56 +0000 Subject: ok... i hope i haven't messed too much with the code and everything is still working. Changes: - Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed. - A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added. git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 443 +++----------------------------------- 1 file changed, 25 insertions(+), 418 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 277fc055df..627049f941 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -21,8 +21,8 @@ if (defined('IN_PHPBB') && defined('IN_INSTALL')) define('IN_PHPBB', true); define('IN_INSTALL', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); +if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './../'); +if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); // Report all errors, except notices //error_reporting(E_ALL ^ E_NOTICE); @@ -31,7 +31,7 @@ error_reporting(E_ALL); @set_time_limit(0); // Include essential scripts -include($phpbb_root_path . 'config.' . $phpEx); +include(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); if (!isset($dbms)) { @@ -50,23 +50,23 @@ if (!empty($load_extensions)) } // Include files -require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx); -require($phpbb_root_path . 'includes/cache.' . $phpEx); -require($phpbb_root_path . 'includes/template.' . $phpEx); -require($phpbb_root_path . 'includes/session.' . $phpEx); -require($phpbb_root_path . 'includes/auth.' . $phpEx); +require(PHPBB_ROOT_PATH . 'includes/acm/acm_' . $acm_type . '.' . PHP_EXT); +require(PHPBB_ROOT_PATH . 'includes/cache.' . PHP_EXT); +require(PHPBB_ROOT_PATH . 'includes/template.' . PHP_EXT); +require(PHPBB_ROOT_PATH . 'includes/session.' . PHP_EXT); +require(PHPBB_ROOT_PATH . 'includes/auth.' . PHP_EXT); -require($phpbb_root_path . 'includes/functions.' . $phpEx); +require(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT); -if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx)) +if (file_exists(PHPBB_ROOT_PATH . 'includes/functions_content.' . PHP_EXT)) { - require($phpbb_root_path . 'includes/functions_content.' . $phpEx); + require(PHPBB_ROOT_PATH . 'includes/functions_content.' . PHP_EXT); } -require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); -require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); -require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); +require(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT); +require(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT); +require(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT); +require(PHPBB_ROOT_PATH . 'includes/utf/utf_tools.' . PHP_EXT); // If we are on PHP >= 6.0.0 we do not need some code if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) @@ -87,14 +87,14 @@ $cache = new acm(); $db = new $sql_db(); // Add own hook handler, if present. :o -if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) +if (file_exists(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT)) { - require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); + require(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); foreach (cache::obtain_hooks() as $hook) { - @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); + @include(PHPBB_ROOT_PATH . 'includes/hooks/' . $hook . '.' . PHP_EXT); } } else @@ -124,15 +124,15 @@ if (!$language) $language = $row['config_value']; } -if (!file_exists($phpbb_root_path . 'language/' . $language)) +if (!file_exists(PHPBB_ROOT_PATH . 'language/' . $language)) { die('No language found!'); } // And finally, load the relevant language files -include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); +include(PHPBB_ROOT_PATH . 'language/' . $language . '/common.' . PHP_EXT); +include(PHPBB_ROOT_PATH . 'language/' . $language . '/acp/common.' . PHP_EXT); +include(PHPBB_ROOT_PATH . 'language/' . $language . '/install.' . PHP_EXT); // Set PHP error handler to ours //set_error_handler('msg_handler'); @@ -589,7 +589,6 @@ flush(); $no_updates = true; $versions = array( - '3.0.RC2', '3.0.RC3', '3.0.RC4', '3.0.RC5', '3.0.0' ); // some code magic @@ -681,7 +680,7 @@ else

-

" class="button1">

+

" class="button1">

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); - } - } - + default: break; - - 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 ad739a358ca7b593fc5f2bfc77e2058b4ea59163 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 23 Jun 2008 18:22:44 +0000 Subject: merge? merge. git-svn-id: file:///svn/phpbb/trunk@8672 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 627049f941..a98bb7e314 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.1.0'; +$updates_to_version = '3.0.2-RC2'; // Return if we "just include it" to find out for which version the database update is responsuble for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -699,7 +699,7 @@ $cache->purge();
- + -- cgit v1.2.1 From c903b453fa00871a11ea988b5e348c3a2741b251 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 2 Nov 2008 11:22:30 +0000 Subject: i had these changes sitting... must've been a merge not committed (and because we do not use svn 1.5 as the client version i am not able to say which they were) git-svn-id: file:///svn/phpbb/trunk@9042 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 a98bb7e314..b0b6efe62c 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.3-RC1'; // Return if we "just include it" to find out for which version the database update is responsuble for if (defined('IN_PHPBB') && defined('IN_INSTALL')) -- cgit v1.2.1 From d46e8e6f98054fc58a126c865184369198d9a2ed Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 22 Nov 2008 19:38:25 +0000 Subject: merge revisions i missed... hopefully not breaking things - did not check every change. git-svn-id: file:///svn/phpbb/trunk@9077 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 b0b6efe62c..e43e8ad142 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 responsuble for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -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); } @@ -340,6 +340,9 @@ $unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP'); // Only an example, but also commented out $database_update_info = array( + + // No changes from 3.0.3-RC1 to 3.0.3 + '3.0.3-RC1' => array(), ); // Determine mapping database type -- cgit v1.2.1 From 3cd007c49d776b4e76f939dbd7d7c328bd09abe9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 24 Dec 2008 14:44:19 +0000 Subject: change cache:: to phpbb_cache:: git-svn-id: file:///svn/phpbb/trunk@9226 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e43e8ad142..583ec0861f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -86,22 +86,6 @@ $user = new user(); $cache = new acm(); $db = new $sql_db(); -// Add own hook handler, if present. :o -if (file_exists(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT)) -{ - require(PHPBB_ROOT_PATH . 'includes/hooks/index.' . PHP_EXT); - $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); - - foreach (cache::obtain_hooks() as $hook) - { - @include(PHPBB_ROOT_PATH . 'includes/hooks/' . $hook . '.' . PHP_EXT); - } -} -else -{ - $phpbb_hook = false; -} - // Connect to DB $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); -- cgit v1.2.1 From 889fa871402814874d5d4f01b2f1c829d8206eb9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 28 Dec 2008 13:27:58 +0000 Subject: implement new phpbb::$acm object, replacing $cache global git-svn-id: file:///svn/phpbb/trunk@9240 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 5 ++--- 1 file changed, 2 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 583ec0861f..996deb0339 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -83,7 +83,6 @@ else } $user = new user(); -$cache = new acm(); $db = new $sql_db(); // Connect to DB @@ -652,7 +651,7 @@ _write_result($no_updates, $errored, $error_ary); if (!$inline_update) { // Purge the cache... - $cache->purge(); + phpbb::$acm->purge(); ?>

@@ -676,7 +675,7 @@ else 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(); +phpbb::$acm->purge(); ?> -- cgit v1.2.1 From 19aed179e53f9660a7202e2e50816e1cef0f7be9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 28 Dec 2008 23:30:09 +0000 Subject: $config to phpbb::$config git-svn-id: file:///svn/phpbb/trunk@9242 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 20 ++++++-------------- 1 file changed, 6 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 996deb0339..67794221a6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -371,23 +371,15 @@ header('Content-type: text/html; charset=UTF-8'); sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $config[$row['config_name']] = $row['config_value']; -} -$db->sql_freeresult($result); +phpbb::$acm->destroy('#config'); +$config = phpbb_cache::obtain_config(); -echo $lang['PREVIOUS_VERSION'] . ' :: ' . $config['version'] . '
'; +echo $lang['PREVIOUS_VERSION'] . ' :: ' . phpbb::$config['version'] . '
'; echo $lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . '

'; -$current_version = str_replace('rc', 'RC', strtolower($config['version'])); +$current_version = str_replace('rc', 'RC', strtolower(phpbb::$config['version'])); $latest_version = str_replace('rc', 'RC', strtolower($updates_to_version)); -$orig_version = $config['version']; +$orig_version = phpbb::$config['version']; // 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) @@ -708,7 +700,7 @@ if (function_exists('exit_handler')) */ function change_database_data($version) { - global $db, $map_dbms, $errored, $error_ary, $config; + global $db, $map_dbms, $errored, $error_ary; switch ($version) { -- cgit v1.2.1 From 14eb46cda05d75e0e3d4f8190b1b7661d8b72793 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 19 Jan 2009 15:24:24 +0000 Subject: Adjust some files to support new methods... git-svn-id: file:///svn/phpbb/trunk@9279 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 1517 ++----------------------------------- 1 file changed, 58 insertions(+), 1459 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 67794221a6..0b495cf995 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.1.0'; // Return if we "just include it" to find out for which version the database update is responsuble for if (defined('IN_PHPBB') && defined('IN_INSTALL')) @@ -23,304 +23,32 @@ define('IN_INSTALL', true); if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './../'); if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); - -// Report all errors, except notices -//error_reporting(E_ALL ^ E_NOTICE); -error_reporting(E_ALL); +include PHPBB_ROOT_PATH . 'common.' . PHP_EXT; @set_time_limit(0); -// Include essential scripts -include(PHPBB_ROOT_PATH . 'config.' . PHP_EXT); - -if (!isset($dbms)) -{ - die("Please read: INSTALL.html before attempting to update."); -} - -// Load Extensions -if (!empty($load_extensions)) -{ - $load_extensions = explode(',', $load_extensions); - - foreach ($load_extensions as $extension) - { - @dl(trim($extension)); - } -} - -// Include files -require(PHPBB_ROOT_PATH . 'includes/acm/acm_' . $acm_type . '.' . PHP_EXT); -require(PHPBB_ROOT_PATH . 'includes/cache.' . PHP_EXT); -require(PHPBB_ROOT_PATH . 'includes/template.' . PHP_EXT); -require(PHPBB_ROOT_PATH . 'includes/session.' . PHP_EXT); -require(PHPBB_ROOT_PATH . 'includes/auth.' . PHP_EXT); - -require(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT); - -if (file_exists(PHPBB_ROOT_PATH . 'includes/functions_content.' . PHP_EXT)) -{ - require(PHPBB_ROOT_PATH . 'includes/functions_content.' . PHP_EXT); -} - -require(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT); -require(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT); -require(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT); -require(PHPBB_ROOT_PATH . 'includes/utf/utf_tools.' . PHP_EXT); +// Start session management +phpbb::$user->session_begin(); +phpbb::$acl->init(phpbb::$user->data); +phpbb::$user->setup('install'); -// If we are on PHP >= 6.0.0 we do not need some code -if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) -{ - /** - * @ignore - */ - define('STRIP', false); -} -else +if (!phpbb::$user->is_registered) { - @set_magic_quotes_runtime(0); - define('STRIP', (get_magic_quotes_gpc()) ? true : false); + login_box(); } -$user = new user(); -$db = new $sql_db(); - -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); - -// We do not need this any longer, unset for safety purposes -unset($dbpasswd); - -$user->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; - -$sql = "SELECT config_value - FROM " . CONFIG_TABLE . " - WHERE config_name = 'default_lang'"; -$result = $db->sql_query($sql); -$row = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -$language = basename(request_var('language', '')); - -if (!$language) +if (!phpbb::$acl->acl_get('a_board')) { - $language = $row['config_value']; + trigger_error('NO_AUTH'); } -if (!file_exists(PHPBB_ROOT_PATH . 'language/' . $language)) -{ - die('No language found!'); -} +include PHPBB_ROOT_PATH . 'includes/db/db_tools.' . PHP_EXT; -// And finally, load the relevant language files -include(PHPBB_ROOT_PATH . 'language/' . $language . '/common.' . PHP_EXT); -include(PHPBB_ROOT_PATH . 'language/' . $language . '/acp/common.' . PHP_EXT); -include(PHPBB_ROOT_PATH . 'language/' . $language . '/install.' . PHP_EXT); - -// Set PHP error handler to ours -//set_error_handler('msg_handler'); +$db_tools = new phpbb_db_tools(phpbb::$db, true); // Define some variables for the database update $inline_update = (request_var('type', 0)) ? true : false; -// Database column types mapping -$dbms_type_map = array( - 'mysql' => 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)', - ), - - '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 char)', - 'VCHAR:' => 'varchar2(%d char)', - 'CHAR:' => 'char(%d char)', - 'XSTEXT' => 'varchar2(1000 char)', - 'STEXT' => 'varchar2(3000 char)', - 'TEXT' => 'clob', - 'MTEXT' => 'clob', - 'XSTEXT_UNI'=> 'varchar2(100 char)', - 'STEXT_UNI' => 'varchar2(255 char)', - '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(255 char)', - 'VCHAR_UNI:'=> 'varchar2(%d char)', - 'VCHAR_CI' => 'varchar2(255 char)', - 'VARBINARY' => 'raw(255)', - ), - - 'db2' => array( - 'INT:' => 'integer', - 'BINT' => 'float', - 'UINT' => 'integer', - 'UINT:' => 'integer', - 'TINT:' => 'smallint', - 'USINT' => 'smallint', - 'BOOL' => 'smallint', - 'VCHAR' => 'varchar(255)', - 'VCHAR:' => 'varchar(%d)', - 'CHAR:' => 'char(%d)', - 'XSTEXT' => 'clob(65K)', - 'STEXT' => 'varchar(3000)', - 'TEXT' => 'clob(65K)', - 'MTEXT' => 'clob(16M)', - 'XSTEXT_UNI'=> 'varchar(100)', - 'STEXT_UNI' => 'varchar(255)', - 'TEXT_UNI' => 'clob(65K)', - 'MTEXT_UNI' => 'clob(16M)', - 'TIMESTAMP' => 'integer', - 'DECIMAL' => 'float', - 'VCHAR_UNI' => 'varchar(255)', - 'VCHAR_UNI:'=> 'varchar(%d)', - 'VCHAR_CI' => 'varchar(255)', - 'VARBINARY' => 'varchar(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' => 'boolean', // 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(255)', - '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( @@ -328,9 +56,6 @@ $database_update_info = array( '3.0.3-RC1' => array(), ); -// Determine mapping database type -$map_dbms = $db->dbms_type; - $error_ary = array(); $errored = false; @@ -338,15 +63,15 @@ header('Content-type: text/html; charset=UTF-8'); ?> - + - + -<?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> +<?php echo phpbb::$user->lang['UPDATING_TO_LATEST_STABLE']; ?> @@ -363,19 +88,19 @@ header('Content-type: text/html; charset=UTF-8');
-

+

lang['UPDATING_TO_LATEST_STABLE']; ?>


-

:: sql_layer; ?>
+

lang['DATABASE_TYPE']; ?> :: sql_layer; ?>
destroy('#config'); $config = phpbb_cache::obtain_config(); -echo $lang['PREVIOUS_VERSION'] . ' :: ' . phpbb::$config['version'] . '
'; -echo $lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . '

'; +echo phpbb::$user->lang['PREVIOUS_VERSION'] . ' :: ' . phpbb::$config['version'] . '
'; +echo phpbb::$user->lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . '

'; $current_version = str_replace('rc', 'RC', strtolower(phpbb::$config['version'])); $latest_version = str_replace('rc', 'RC', strtolower($updates_to_version)); @@ -392,51 +117,24 @@ if ($inline_update) else { // If not called from the update script, we will actually remove the traces - $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); -} - -// Checks/Operations that have to be completed prior to starting the update itself -$exit = false; - -if ($exit) -{ -?> - -
-
- -
-
-
- - - - - - - -sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); } // Schema updates ?>

-

+

lang['UPDATE_DATABASE_SCHEMA']; ?>


-

:: +

lang['PROGRESS']; ?> :: = 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; } - $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'])) + if (!sizeof($schema_changes)) { - foreach ($schema_changes['drop_columns'] as $table => $columns) - { - foreach ($columns as $column) - { - sql_column_remove($map_dbms, $table, $column); - } - } + continue; } - // 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); - } - } + // Get statements for schema updates + $statements = $db_tools->sql_schema_changes($schema_changes); - // Add unqiue indexes? - if (!empty($schema_changes['add_unique_index'])) + if (sizeof($statements)) { - 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); - } - } - } + $no_updates = false; - // Add indexes? - if (!empty($schema_changes['add_index'])) - { - foreach ($schema_changes['add_index'] as $table => $index_array) + foreach ($statements as $sql) { - foreach ($index_array as $index_name => $column) - { - sql_create_index($map_dbms, $index_name, $table, $column); - } + _sql($sql, $errored, $error_ary); } } } @@ -556,9 +180,9 @@ $errored = $no_updates = false; ?>

-

+

lang['UPDATING_DATA']; ?>


-

:: +

lang['PROGRESS']; ?> ::

-

+

lang['UPDATE_VERSION_OPTIMIZE']; ?>


-

:: +

lang['PROGRESS']; ?> ::
-

+

lang['UPDATE_COMPLETED']; ?>


@@ -646,9 +269,9 @@ if (!$inline_update) phpbb::$acm->purge(); ?> -

+

lang['UPDATE_FILES_NOTICE']; ?>

-

+

lang['COMPLETE_LOGIN_TO_BOARD']; ?>

-

+

lang['INLINE_UPDATE_SUCCESSFUL'])) ? phpbb::$user->lang['INLINE_UPDATE_SUCCESSFUL'] : 'The database update was successful. Now you need to continue the update process.'); ?>

-

" class="button1">

+

" class="button1">lang['CONTINUE_UPDATE_NOW'])) ? phpbb::$user->lang['CONTINUE_UPDATE_NOW'] : 'Continue the update process now'; ?>

\n{$sql}\n
"; } - $db->sql_return_on_error(true); + phpbb::$db->sql_return_on_error(true); - $result = $db->sql_query($sql); - if ($db->sql_error_triggered) + $result = phpbb::$db->sql_query($sql); + if (phpbb::$db->sql_error_triggered) { $errored = true; - $error_ary['sql'][] = $db->sql_error_sql; - $error_ary['error_code'][] = $db->_sql_error(); + $error_ary['sql'][] = phpbb::$db->sql_error_sql; + $error_ary['error_code'][] = phpbb::$db->_sql_error(); } - $db->sql_return_on_error(false); + phpbb::$db->sql_return_on_error(false); if ($echo_dot) { @@ -744,1052 +365,30 @@ function _sql($sql, &$errored, &$error_ary, $echo_dot = true) function _write_result($no_updates, $errored, $error_ary) { - global $lang; - if ($no_updates) { - echo ' ' . $lang['NO_UPDATES_REQUIRED'] . '

'; + echo ' ' . phpbb::$user->lang['NO_UPDATES_REQUIRED'] . '

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

' . $lang['RESULT'] . ' :: '; + echo ' ' . phpbb::$user->lang['DONE'] . '

' . phpbb::$user->lang['RESULT'] . ' :: '; if ($errored) { - echo ' ' . $lang['SOME_QUERIES_FAILED'] . '
    '; + echo ' ' . phpbb::$user->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': - $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; - } + echo '
  • ' . phpbb::$user->lang['ERROR'] . ' :: ' . htmlspecialchars($error_ary['error_code'][$i]['message']) . '
    '; + echo phpbb::$user->lang['SQL'] . ' :: ' . htmlspecialchars($error_ary['sql'][$i]) . '

  • '; } - $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); + echo '


' . phpbb::$user->lang['SQL_FAILURE_EXPLAIN'] . '

'; } 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; - } - } + echo '' . phpbb::$user->lang['NO_ERRORS'] . '

'; } - $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': - $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 ($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': - $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': - $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': - $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': - $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': - $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': - $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': - $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' && !$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': - $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' && !$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': - $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; } } -- cgit v1.2.1 From cd4091af43fa2d7d3dbe5ad0d583c63f1d96c903 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 20 Jan 2009 16:54:15 +0000 Subject: i am not sure if people will like the config layout i test here... it requires the framework at least being present git-svn-id: file:///svn/phpbb/trunk@9281 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 0b495cf995..f72f963bff 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -337,7 +337,7 @@ function change_database_data($version) */ function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { - if (defined('DEBUG_EXTRA')) + if (phpbb::$base_config['debug_extra']) { echo "
\n{$sql}\n
"; } -- cgit v1.2.1 From 84f795e9fbd172924280593d575bf4587c9b40e5 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 18:06:05 +0000 Subject: $db-> to phpbb::$db-> git-svn-id: file:///svn/phpbb/trunk@9336 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 f72f963bff..c9dd0a523f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -239,7 +239,7 @@ _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 -switch ($db->dbms_type) +switch (phpbb::$db->dbms_type) { case 'mysql': $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; -- cgit v1.2.1 From 4cbf6bc703bdadf716197b68a89b3438247ff022 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Mar 2009 16:34:26 +0000 Subject: Merge most changes from 3.0.x branch since the 25th december. (Captcha changes for refreshing captcha image not included) git-svn-id: file:///svn/phpbb/trunk@9404 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 26 +++++++++++++++++++------- 1 file changed, 19 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 c9dd0a523f..2eef013742 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -10,7 +10,10 @@ $updates_to_version = '3.1.0'; -// Return if we "just include it" to find out for which version the database update is responsuble for +// 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')) { return; @@ -86,7 +89,7 @@ header('Content-type: text/html; charset=UTF-8');
-
+

lang['UPDATING_TO_LATEST_STABLE']; ?>

@@ -106,6 +109,12 @@ $current_version = str_replace('rc', 'RC', strtolower(phpbb::$config['version']) $latest_version = str_replace('rc', 'RC', strtolower($updates_to_version)); $orig_version = phpbb::$config['version']; +// Fill DB version +if (empty(phpbb::$config['dbms_version'])) +{ + set_config('dbms_version', phpbb::$db->sql_server_info(true)); +} + // 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) { @@ -224,11 +233,14 @@ $errored = $no_updates = false; flush(); -// update the version -$sql = "UPDATE " . CONFIG_TABLE . " - SET config_value = '$updates_to_version' - WHERE config_name = 'version'"; -_sql($sql, $errored, $error_ary); +if ($debug_from_version === false) +{ + // update the version + $sql = "UPDATE " . CONFIG_TABLE . " + SET config_value = '$updates_to_version' + WHERE config_name = 'version'"; + _sql($sql, $errored, $error_ary); +} // Reset permissions $sql = 'UPDATE ' . USERS_TABLE . " -- cgit v1.2.1 From 1042152a55ab2d0764c446949a77f085ab7a77f3 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 18 Apr 2009 15:09:19 +0000 Subject: Merge changes made in revisions #r9405 to #r9467 2009-04-18 git-svn-id: file:///svn/phpbb/trunk@9468 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 9 ++++++--- 1 file changed, 6 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 2eef013742..0be2e0f5b8 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.1.0'; +$updates_to_version = '3.1.0-dev1'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -55,8 +55,8 @@ $inline_update = (request_var('type', 0)) ? true : false; // Only an example, but also commented out $database_update_info = array( - // No changes from 3.0.3-RC1 to 3.0.3 - '3.0.3-RC1' => array(), + // Changes from 3.0.5 to 3.1.0-dev1 + '3.0.5' => array(), ); $error_ary = array(); @@ -340,6 +340,9 @@ function change_database_data($version) switch ($version) { default: + // Changes from 3.0.5 to 3.1.0-dev1 + case '3.0.5': + break; break; } } -- cgit v1.2.1 From bf8ac19eaa8d74f9dfd6d597190f5664e7339382 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Oct 2009 18:13:59 +0000 Subject: Move trunk/phpBB to old_trunk/phpBB git-svn-id: file:///svn/phpbb/trunk@10210 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 410 -------------------------------------- 1 file changed, 410 deletions(-) delete mode 100644 phpBB/install/database_update.php (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php deleted file mode 100644 index 0be2e0f5b8..0000000000 --- a/phpBB/install/database_update.php +++ /dev/null @@ -1,410 +0,0 @@ -session_begin(); -phpbb::$acl->init(phpbb::$user->data); -phpbb::$user->setup('install'); - -if (!phpbb::$user->is_registered) -{ - login_box(); -} - -if (!phpbb::$acl->acl_get('a_board')) -{ - trigger_error('NO_AUTH'); -} - -include PHPBB_ROOT_PATH . 'includes/db/db_tools.' . PHP_EXT; - -$db_tools = new phpbb_db_tools(phpbb::$db, true); - -// Define some variables for the database update -$inline_update = (request_var('type', 0)) ? true : false; - -// Only an example, but also commented out -$database_update_info = array( - - // Changes from 3.0.5 to 3.1.0-dev1 - '3.0.5' => array(), -); - -$error_ary = array(); -$errored = false; - -header('Content-type: text/html; charset=UTF-8'); - -?> - - - - - - - - - -<?php echo phpbb::$user->lang['UPDATING_TO_LATEST_STABLE']; ?> - - - - - - -
- - -
-
-
- -
-
- -

lang['UPDATING_TO_LATEST_STABLE']; ?>

- -
- -

lang['DATABASE_TYPE']; ?> :: sql_layer; ?>
-destroy('#config'); -$config = phpbb_cache::obtain_config(); - -echo phpbb::$user->lang['PREVIOUS_VERSION'] . ' :: ' . phpbb::$config['version'] . '
'; -echo phpbb::$user->lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . '

'; - -$current_version = str_replace('rc', 'RC', strtolower(phpbb::$config['version'])); -$latest_version = str_replace('rc', 'RC', strtolower($updates_to_version)); -$orig_version = phpbb::$config['version']; - -// Fill DB version -if (empty(phpbb::$config['dbms_version'])) -{ - set_config('dbms_version', phpbb::$db->sql_server_info(true)); -} - -// 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) -{ - if ($current_version !== $latest_version) - { - set_config('version_update_from', $orig_version); - } -} -else -{ - // If not called from the update script, we will actually remove the traces - phpbb::$db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); -} - -// Schema updates -?> -

- -

lang['UPDATE_DATABASE_SCHEMA']; ?>

- -
-

lang['PROGRESS']; ?> :: - -= 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 (!sizeof($schema_changes)) - { - continue; - } - - // Get statements for schema updates - $statements = $db_tools->sql_schema_changes($schema_changes); - - if (sizeof($statements)) - { - $no_updates = false; - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } - } -} - -_write_result($no_updates, $errored, $error_ary); - -// Data updates -$error_ary = array(); -$errored = $no_updates = false; - -?> - -

-

lang['UPDATING_DATA']; ?>

-
-

lang['PROGRESS']; ?> :: - -= 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; - } - - change_database_data($no_updates, $version); -} - -_write_result($no_updates, $errored, $error_ary); - -$error_ary = array(); -$errored = $no_updates = false; - -?> - -

-

lang['UPDATE_VERSION_OPTIMIZE']; ?>

-
-

lang['PROGRESS']; ?> :: - -dbms_type) -{ - case 'mysql': - $sql = 'OPTIMIZE TABLE ' . $table_prefix . 'auth_access, ' . $table_prefix . 'banlist, ' . $table_prefix . 'categories, ' . $table_prefix . 'config, ' . $table_prefix . 'disallow, ' . $table_prefix . 'forum_prune, ' . $table_prefix . 'forums, ' . $table_prefix . 'groups, ' . $table_prefix . 'posts, ' . $table_prefix . 'posts_text, ' . $table_prefix . 'privmsgs, ' . $table_prefix . 'privmsgs_text, ' . $table_prefix . 'ranks, ' . $table_prefix . 'search_results, ' . $table_prefix . 'search_wordlist, ' . $table_prefix . 'search_wordmatch, ' . $table_prefix . 'sessions_keys' . $table_prefix . 'smilies, ' . $table_prefix . 'themes, ' . $table_prefix . 'themes_name, ' . $table_prefix . 'topics, ' . $table_prefix . 'topics_watch, ' . $table_prefix . 'user_group, ' . $table_prefix . 'users, ' . $table_prefix . 'vote_desc, ' . $table_prefix . 'vote_results, ' . $table_prefix . 'vote_voters, ' . $table_prefix . 'words'; - _sql($sql, $errored, $error_ary); - break; - - case 'postgresql': - _sql("VACUUM ANALYZE", $errored, $error_ary); - break; -} -*/ - -_write_result($no_updates, $errored, $error_ary); - -?> - -
-

lang['UPDATE_COMPLETED']; ?>

- -
- -purge(); -?> - -

lang['UPDATE_FILES_NOTICE']; ?>

- -

lang['COMPLETE_LOGIN_TO_BOARD']; ?>

- - - -

lang['INLINE_UPDATE_SUCCESSFUL'])) ? phpbb::$user->lang['INLINE_UPDATE_SUCCESSFUL'] : 'The database update was successful. Now you need to continue the update process.'); ?>

- -

" class="button1">lang['CONTINUE_UPDATE_NOW'])) ? phpbb::$user->lang['CONTINUE_UPDATE_NOW'] : 'Continue the update process now'; ?>

- -purge(); - -?> - -
-
- -
-
-
- - -
- - - - -\n{$sql}\n
"; - } - - phpbb::$db->sql_return_on_error(true); - - $result = phpbb::$db->sql_query($sql); - if (phpbb::$db->sql_error_triggered) - { - $errored = true; - $error_ary['sql'][] = phpbb::$db->sql_error_sql; - $error_ary['error_code'][] = phpbb::$db->_sql_error(); - } - - phpbb::$db->sql_return_on_error(false); - - if ($echo_dot) - { - echo ". \n"; - flush(); - } - - return $result; -} - -function _write_result($no_updates, $errored, $error_ary) -{ - if ($no_updates) - { - echo ' ' . phpbb::$user->lang['NO_UPDATES_REQUIRED'] . '

'; - } - else - { - echo ' ' . phpbb::$user->lang['DONE'] . '

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

  • '; - } - - echo '


' . phpbb::$user->lang['SQL_FAILURE_EXPLAIN'] . '

'; - } - else - { - echo '' . phpbb::$user->lang['NO_ERRORS'] . '

'; - } - } -} - -?> \ No newline at end of file -- cgit v1.2.1 From 2e17e448deed073f8614bb555a8ef20c57291c2a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Oct 2009 18:14:59 +0000 Subject: Copy 3.0.x branch to trunk git-svn-id: file:///svn/phpbb/trunk@10211 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 3387 +++++++++++++++++++++++++++++++++++++ 1 file changed, 3387 insertions(+) create mode 100644 phpBB/install/database_update.php (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php new file mode 100644 index 0000000000..ce223cf302 --- /dev/null +++ b/phpBB/install/database_update.php @@ -0,0 +1,3387 @@ +INSTALL.html before attempting to update."); +} + +// Load Extensions +if (!empty($load_extensions)) +{ + $load_extensions = explode(',', $load_extensions); + + foreach ($load_extensions as $extension) + { + @dl(trim($extension)); + } +} + +// Include files +require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx); +require($phpbb_root_path . 'includes/cache.' . $phpEx); +require($phpbb_root_path . 'includes/template.' . $phpEx); +require($phpbb_root_path . 'includes/session.' . $phpEx); +require($phpbb_root_path . 'includes/auth.' . $phpEx); + +require($phpbb_root_path . 'includes/functions.' . $phpEx); + +if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx)) +{ + require($phpbb_root_path . 'includes/functions_content.' . $phpEx); +} + +require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); +require($phpbb_root_path . 'includes/constants.' . $phpEx); +require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); +require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); + +// If we are on PHP >= 6.0.0 we do not need some code +if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) +{ + /** + * @ignore + */ + define('STRIP', false); +} +else +{ + @set_magic_quotes_runtime(0); + define('STRIP', (get_magic_quotes_gpc()) ? true : false); +} + +$user = new user(); +$cache = new cache(); +$db = new $sql_db(); + +// Add own hook handler, if present. :o +if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) +{ + require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); + $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); + + foreach ($cache->obtain_hooks() as $hook) + { + @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); + } +} +else +{ + $phpbb_hook = false; +} + +// Connect to DB +$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); + +// We do not need this any longer, unset for safety purposes +unset($dbpasswd); + +$user->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; + +$sql = "SELECT config_value + FROM " . CONFIG_TABLE . " + WHERE config_name = 'default_lang'"; +$result = $db->sql_query($sql); +$row = $db->sql_fetchrow($result); +$db->sql_freeresult($result); + +$language = basename(request_var('language', '')); + +if (!$language) +{ + $language = $row['config_value']; +} + +if (!file_exists($phpbb_root_path . 'language/' . $language)) +{ + die('No language found!'); +} + +// And finally, load the relevant language files +include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx); +include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx); +include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); + +// Set PHP error handler to ours +//set_error_handler('msg_handler'); + +// Define some variables for the database update +$inline_update = (request_var('type', 0)) ? true : false; + +// To let set_config() calls succeed, we need to make the config array available globally +$config = array(); + +$sql = 'SELECT * + FROM ' . CONFIG_TABLE; +$result = $db->sql_query($sql); + +while ($row = $db->sql_fetchrow($result)) +{ + $config[$row['config_name']] = $row['config_value']; +} +$db->sql_freeresult($result); + +// 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(); + +$error_ary = array(); +$errored = false; + +header('Content-type: text/html; charset=UTF-8'); + +?> + + + + + + + + + +<?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> + + + + + + +
+ + +
+
+
+ +
+
+ +

+ +
+ +

:: sql_layer; ?>
+' . $config['version'] . '

'; +echo $lang['UPDATED_VERSION'] . ' :: ' . $updates_to_version . '

'; + +$current_version = str_replace('rc', 'RC', strtolower($config['version'])); +$latest_version = str_replace('rc', 'RC', strtolower($updates_to_version)); +$orig_version = $config['version']; + +// Fill DB version +if (empty($config['dbms_version'])) +{ + set_config('dbms_version', $db->sql_server_info(true)); +} + +// Firebird update from 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') +{ + // Verify by fetching column... if the column type matches the new type we update dbms_version... + $sql = "SHOW COLUMNS FROM " . CONFIG_TABLE; + $result = $db->sql_query($sql); + + $column_type = ''; + while ($row = $db->sql_fetchrow($result)) + { + $field = strtolower($row['Field']); + + if ($field == 'config_value') + { + $column_type = strtolower($row['Type']); + break; + } + } + $db->sql_freeresult($result); + + // If column type is blob, but mysql version says we are on > 4.1.3, then the schema needs an update + if (strpos($column_type, 'blob') !== false && version_compare($db->sql_server_info(true), '4.1.3', '>=')) + { + echo '

'; + echo '

' . $lang['ERROR'] . '


'; + + echo '

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

'; + + _print_footer(); + + exit_handler(); + exit; + } +} + +// Now check if the user wants to update from a version we no longer support updates from +if (version_compare($current_version, $oldest_from_version, '<')) +{ + echo '

' . $lang['ERROR'] . '


'; + echo '

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

'; + + _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) +{ + if ($current_version !== $latest_version) + { + set_config('version_update_from', $orig_version); + } +} +else +{ + // If not called from the update script, we will actually remove the traces + $db->sql_query('DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from'"); +} + +// Schema updates +?> +

+ +

+ +
+

:: + += as the version to be updated to next, we will skip the process + if (version_compare($version, $current_version, '<') && version_compare($current_version, $next_version, '>=')) + { + continue; + } + + if (!sizeof($schema_changes)) + { + continue; + } + + $no_updates = false; + + $statements = $db_tools->perform_schema_changes($schema_changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } +} + +_write_result($no_updates, $errored, $error_ary); + +// Data updates +$error_ary = array(); +$errored = $no_updates = false; + +?> + +

+

+
+

:: + += 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; + } + + change_database_data($no_updates, $version); +} + +_write_result($no_updates, $errored, $error_ary); + +$error_ary = array(); +$errored = $no_updates = false; + +?> + +

+

+
+

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

+ +
+ + + +

+ +

+ + + +

+ +

" class="button1">

+ +purge(); + +_print_footer(); + +garbage_collection(); + +if (function_exists('exit_handler')) +{ + exit_handler(); +} + +/** +* Print out footer +*/ +function _print_footer() +{ + echo << +
+ +
+
+
+ + +
+ + + +EOF; +} + +/** +* Function for triggering an sql statement +*/ +function _sql($sql, &$errored, &$error_ary, $echo_dot = true) +{ + global $db; + + if (defined('DEBUG_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_returned; + } + + $db->sql_return_on_error(false); + + if ($echo_dot) + { + echo ". \n"; + flush(); + } + + return $result; +} + +function _write_result($no_updates, $errored, $error_ary) +{ + global $lang; + + if ($no_updates) + { + echo ' ' . $lang['NO_UPDATES_REQUIRED'] . '

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

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

  • '; + } + + echo '


' . $lang['SQL_FAILURE_EXPLAIN'] . '

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

'; + } + } +} + +function _add_modules($modules_to_install) +{ + global $phpbb_root_path, $phpEx, $db; + + 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']} + GROUP BY 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); + } + } + + $_module->remove_cache_file(); +} + +/**************************************************************************** +* ADD YOUR DATABASE SCHEMA CHANGES HERE * +*****************************************************************************/ +function database_update_info() +{ + return array( + // Changes from 3.0.0 to the next version + '3.0.0' => array( + // Add the following columns + 'add_columns' => array( + FORUMS_TABLE => array( + 'display_subforum_list' => array('BOOL', 1), + ), + SESSIONS_TABLE => array( + 'session_forum_id' => array('UINT', 0), + ), + ), + '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('UINT', 0), + ), + USERS_TABLE => array( + 'user_style' => array('UINT', 0), + ), + ), + ), + + // Changes from 3.0.4-RC1 to 3.0.4 + '3.0.4-RC1' => array(), + + // Changes from 3.0.4 to 3.0.5-RC1 + '3.0.4' => array( + 'change_columns' => array( + FORUMS_TABLE => array( + 'forum_style' => array('UINT', 0), + ), + ), + ), + + // No changes from 3.0.5-RC1 to 3.0.5 + '3.0.5-RC1' => array(), + + // Changes from 3.0.5 to 3.0.6-RC1 + '3.0.5' => array( + 'add_columns' => array( + CONFIRM_TABLE => array( + 'attempts' => array('UINT', 0), + ), + USERS_TABLE => array( + 'user_new' => array('BOOL', 1), + 'user_reminded' => array('TINT:4', 0), + 'user_reminded_time'=> array('TIMESTAMP', 0), + ), + GROUPS_TABLE => array( + 'group_skip_auth' => array('BOOL', 0, 'after' => 'group_founder_manage'), + ), + PRIVMSGS_TABLE => array( + 'message_reported' => array('BOOL', 0), + ), + REPORTS_TABLE => array( + 'pm_id' => array('UINT', 0), + ), + PROFILE_FIELDS_TABLE => array( + 'field_show_on_vt' => array('BOOL', 0), + ), + FORUMS_TABLE => array( + 'forum_options' => array('UINT:20', 0), + ), + ), + 'change_columns' => array( + USERS_TABLE => array( + 'user_options' => array('UINT:11', 230271), + ), + ), + 'add_index' => array( + REPORTS_TABLE => array( + 'post_id' => array('post_id'), + 'pm_id' => array('pm_id'), + ), + POSTS_TABLE => array( + 'post_username' => array('post_username'), + ), + ), + ), + // 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-RC2 to 3.0.6-RC3 + '3.0.6-RC2' => array(), + ); +} + +/**************************************************************************** +* 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 . " + SET topic_last_view_time = topic_last_post_time + WHERE topic_last_view_time = 0"; + _sql($sql, $errored, $error_ary); + + // Update smiley sizes + $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif'); + + foreach ($smileys as $smiley) + { + if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley)) + { + list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley); + + $sql = 'UPDATE ' . SMILIES_TABLE . ' + SET smiley_width = ' . $width . ', smiley_height = ' . $height . " + WHERE smiley_url = '" . $db->sql_escape($smiley) . "'"; + + _sql($sql, $errored, $error_ary); + } + } + + $no_updates = false; + break; + + // No changes from 3.0.1-RC1 to 3.0.1 + case '3.0.1-RC1': + break; + + // changes from 3.0.1 to 3.0.2-RC1 + case '3.0.1': + + set_config('referer_validation', '1'); + set_config('check_attachment_content', '1'); + set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title'); + + $no_updates = false; + break; + + // No changes from 3.0.2-RC1 to 3.0.2-RC2 + case '3.0.2-RC1': + break; + + // No changes from 3.0.2-RC2 to 3.0.2 + case '3.0.2-RC2': + break; + + // Changes from 3.0.2 to 3.0.3-RC1 + case '3.0.2': + set_config('enable_queue_trigger', '0'); + set_config('queue_trigger_posts', '3'); + + set_config('pm_max_recipients', '0'); + + // Set maximum number of recipients for the registered users, bots, guests group + $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5 + WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS')); + _sql($sql, $errored, $error_ary); + + // Not prefilling yet + set_config('dbms_version', ''); + + // Add new permission u_masspm_group and duplicate settings from u_masspm + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $auth_admin = new auth_admin(); + + // Only add the new permission if it does not already exist + if (empty($auth_admin->acl_options['id']['u_masspm_group'])) + { + $auth_admin->acl_add_option(array('global' => array('u_masspm_group'))); + + // Now the tricky part, filling the permission + $old_id = $auth_admin->acl_options['id']['u_masspm']; + $new_id = $auth_admin->acl_options['id']['u_masspm_group']; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = _sql($sql, $errored, $error_ary); + + $sql_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $db->sql_multi_insert($table, $sql_ary); + } + } + + // Remove any old permission entries + $auth_admin->acl_clear_prefetch(); + } + + /** + * Do not resync post counts here. An admin may do this later from the ACP + $start = 0; + $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0'; + _sql($sql, $errored, $error_ary); + + do + { + $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id + FROM ' . POSTS_TABLE . ' + WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . ' + AND post_postcount = 1 AND post_approved = 1 + GROUP BY poster_id'; + $result = _sql($sql, $errored, $error_ary); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}"; + _sql($sql, $errored, $error_ary); + } + while ($row = $db->sql_fetchrow($result)); + + $start += $step; + } + else + { + $start = 0; + } + $db->sql_freeresult($result); + } + while ($start); + */ + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'acl_a_email && cfg_email_enable\' + WHERE module_class = \'acp\' + AND module_basename = \'email\''; + _sql($sql, $errored, $error_ary); + + $no_updates = false; + break; + + // Changes from 3.0.3-RC1 to 3.0.3 + case '3.0.3-RC1': + $sql = 'UPDATE ' . LOG_TABLE . " + SET log_operation = 'LOG_DELETE_TOPIC' + WHERE log_operation = 'LOG_TOPIC_DELETED'"; + _sql($sql, $errored, $error_ary); + + $no_updates = false; + break; + + // Changes from 3.0.3 to 3.0.4-RC1 + case '3.0.3': + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide + FROM ' . PROFILE_FIELDS_TABLE; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + $sql_ary = array( + 'field_required' => 0, + 'field_show_on_reg' => 0, + 'field_hide' => 0, + 'field_show_profile'=> 0, + ); + + if ($row['field_required']) + { + $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_show_on_reg']) + { + $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1; + } + else if ($row['field_hide']) + { + // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module + $sql_ary['field_hide'] = 1; + } + else + { + // equivelant to "none", which is the "Display in user control panel" option + $sql_ary['field_show_profile'] = 1; + } + + _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary); + } + $no_updates = false; + + break; + + // Changes from 3.0.4-RC1 to 3.0.4 + case '3.0.4-RC1': + break; + + // Changes from 3.0.4 to 3.0.5-RC1 + case '3.0.4': + + // Captcha config variables + set_config('captcha_gd_wave', 0); + set_config('captcha_gd_3d_noise', 1); + set_config('captcha_gd_fonts', 1); + set_config('confirm_refresh', 1); + + // Maximum number of keywords + set_config('max_num_search_keywords', 10); + + // Remove static config var and put it back as dynamic variable + $sql = 'UPDATE ' . CONFIG_TABLE . " + SET is_dynamic = 1 + WHERE config_name = 'search_indexing_state'"; + _sql($sql, $errored, $error_ary); + + // Hash old MD5 passwords + $sql = 'SELECT user_id, user_password + FROM ' . USERS_TABLE . ' + WHERE user_pass_convert = 1'; + $result = _sql($sql, $errored, $error_ary); + + while ($row = $db->sql_fetchrow($result)) + { + if (strlen($row['user_password']) == 32) + { + $sql_ary = array( + 'user_password' => phpbb_hash($row['user_password']), + ); + + _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary); + } + } + $db->sql_freeresult($result); + + // Adjust bot entry + $sql = 'UPDATE ' . BOTS_TABLE . " + SET bot_agent = 'ichiro/' + WHERE bot_agent = 'ichiro/2'"; + _sql($sql, $errored, $error_ary); + + + // Before we are able to add a unique key to auth_option, we need to remove duplicate entries + + // We get duplicate entries first + $sql = 'SELECT auth_option + FROM ' . ACL_OPTIONS_TABLE . ' + GROUP BY auth_option + HAVING COUNT(*) >= 2'; + $result = $db->sql_query($sql); + + $auth_options = array(); + while ($row = $db->sql_fetchrow($result)) + { + $auth_options[] = $row['auth_option']; + } + $db->sql_freeresult($result); + + // Remove specific auth options + if (!empty($auth_options)) + { + foreach ($auth_options as $option) + { + // Select auth_option_ids... the largest id will be preserved + $sql = 'SELECT auth_option_id + FROM ' . ACL_OPTIONS_TABLE . " + WHERE auth_option = '" . $db->sql_escape($option) . "' + ORDER BY auth_option_id DESC"; + // sql_query_limit not possible here, due to bug in postgresql layer + $result = $db->sql_query($sql); + + // Skip first row, this is our original auth option we want to preserve + $row = $db->sql_fetchrow($result); + + while ($row = $db->sql_fetchrow($result)) + { + // Ok, remove this auth option... + _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary); + } + $db->sql_freeresult($result); + } + } + + // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one. + $changes = array( + 'drop_keys' => array( + ACL_OPTIONS_TABLE => array('auth_option'), + ), + '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; + + // No changes from 3.0.5-RC1 to 3.0.5 + case '3.0.5-RC1': + break; + + // Changes from 3.0.5 to 3.0.6-RC1 + case '3.0.5': + // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled... + if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) + { + set_config('captcha_plugin', 'phpbb_captcha_gd'); + } + else if (!isset($config['captcha_plugin'])) + { + set_config('captcha_plugin', 'phpbb_captcha_nogd'); + } + + // Entries for the Feed Feature + set_config('feed_enable', '0'); + set_config('feed_limit', '10'); + + set_config('feed_overall_forums', '1'); + set_config('feed_overall_forums_limit', '15'); + + set_config('feed_overall_topics', '0'); + set_config('feed_overall_topics_limit', '15'); + + set_config('feed_forum', '1'); + set_config('feed_topic', '1'); + set_config('feed_item_statistics', '1'); + + // Entries for smiley pagination + set_config('smilies_per_page', '50'); + + // Entry for reporting PMs + set_config('allow_pm_report', '1'); + + // Install modules + $modules_to_install = array( + 'feed' => array( + 'base' => 'board', + 'class' => 'acp', + 'title' => 'ACP_FEED_SETTINGS', + 'auth' => 'acl_a_board', + 'cat' => 'ACP_BOARD_CONFIGURATION', + 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS') + ), + 'warnings' => array( + 'base' => 'users', + 'class' => 'acp', + 'title' => 'ACP_USER_WARNINGS', + 'auth' => 'acl_a_user', + 'display' => 0, + 'cat' => 'ACP_CAT_USERS', + 'after' => array('feedback', 'ACP_USER_FEEDBACK') + ), + 'send_statistics' => array( + 'base' => 'send_statistics', + 'class' => 'acp', + 'title' => 'ACP_SEND_STATISTICS', + 'auth' => 'acl_a_server', + 'cat' => 'ACP_SERVER_CONFIGURATION' + ), + 'setting_forum_copy' => array( + 'base' => 'permissions', + 'class' => 'acp', + 'title' => 'ACP_FORUM_PERMISSIONS_COPY', + 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', + 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', + 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS') + ), + 'pm_reports' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORTS_OPEN', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + 'pm_reports_closed' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORTS_CLOSED', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + 'pm_report_details' => array( + 'base' => 'pm_reports', + 'class' => 'mcp', + 'title' => 'MCP_PM_REPORT_DETAILS', + 'auth' => 'aclf_m_report', + 'cat' => 'MCP_REPORTS' + ), + ); + + _add_modules($modules_to_install); + + // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema) + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'NEWLY_REGISTERED'"; + $result = $db->sql_query($sql); + $group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + if (!$group_id) + { + $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)"; + _sql($sql, $errored, $error_ary); + + $group_id = $db->sql_nextid(); + } + + // Insert new user role... at the end of the chain + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_USER_NEW_MEMBER' + AND role_type = 'u_'"; + $result = $db->sql_query($sql); + $u_role = (int) $db->sql_fetchfield('role_id'); + $db->sql_freeresult($result); + + if (!$u_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'u_'"; + $result = $db->sql_query($sql); + $next_order_id = (int) $db->sql_fetchfield('max_order_id'); + $db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', $next_order_id)"; + _sql($sql, $errored, $error_ary); + $u_role = $db->sql_nextid(); + + if (!$errored) + { + // Now add the correct data to the roles... + // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $u_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')"; + _sql($sql, $errored, $error_ary); + + // Add user role to group + $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ($group_id, 0, 0, $u_role, 0)"; + _sql($sql, $errored, $error_ary); + } + } + + // Insert new forum role + $sql = 'SELECT role_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_name = 'ROLE_FORUM_NEW_MEMBER' + AND role_type = 'f_'"; + $result = $db->sql_query($sql); + $f_role = (int) $db->sql_fetchfield('role_id'); + $db->sql_freeresult($result); + + if (!$f_role) + { + $sql = 'SELECT MAX(role_order) as max_order_id + FROM ' . ACL_ROLES_TABLE . " + WHERE role_type = 'f_'"; + $result = $db->sql_query($sql); + $next_order_id = (int) $db->sql_fetchfield('max_order_id'); + $db->sql_freeresult($result); + + $next_order_id++; + + $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', $next_order_id)"; + _sql($sql, $errored, $error_ary); + $f_role = $db->sql_nextid(); + + if (!$errored) + { + $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT $f_role, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')"; + _sql($sql, $errored, $error_ary); + } + } + + // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once) + $sql = 'SELECT 1 + FROM ' . USERS_TABLE . ' + WHERE user_new = 0'; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0'; + _sql($sql, $errored, $error_ary); + } + + // Newly registered users limit + if (!isset($config['new_member_post_limit'])) + { + set_config('new_member_post_limit', (!empty($config['enable_queue_trigger'])) ? $config['queue_trigger_posts'] : 0); + } + + if (!isset($config['new_member_group_default'])) + { + set_config('new_member_group_default', 0); + } + + // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts... + // Check if the role is already assigned... + $sql = 'SELECT forum_id + FROM ' . ACL_GROUPS_TABLE . ' + WHERE group_id = ' . $group_id . ' + AND auth_role_id = ' . $f_role; + $result = $db->sql_query($sql); + $is_options = (int) $db->sql_fetchfield('forum_id'); + $db->sql_freeresult($result); + + // Not assigned at all... :/ + if (!$is_options) + { + // Get postable forums + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type != ' . FORUM_LINK; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary); + } + $db->sql_freeresult($result); + } + + // Clear permissions... + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $auth_admin = new auth_admin(); + $auth_admin->acl_clear_prefetch(); + + if (!isset($config['allow_avatar'])) + { + if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) + { + set_config('allow_avatar', '1'); + } + else + { + set_config('allow_avatar', '0'); + } + } + + if (!isset($config['allow_avatar_remote_upload'])) + { + if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) + { + set_config('allow_avatar_remote_upload', '1'); + } + else + { + set_config('allow_avatar_remote_upload', '0'); + } + } + + // Minimum number of characters + if (!isset($config['min_post_chars'])) + { + set_config('min_post_chars', '1'); + } + + if (!isset($config['allow_quick_reply'])) + { + set_config('allow_quick_reply', '1'); + } + + // Set every members user_options column to enable + // bbcode, smilies and URLs for signatures by default + $sql = 'SELECT user_options + FROM ' . USERS_TABLE . ' + WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')'; + $result = $db->sql_query_limit($sql, 1); + $user_option = (int) $db->sql_fetchfield('user_options'); + $db->sql_freeresult($result); + + // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option + if (!($user_option & 1 << 15)) + { + // 229376 is the added value to enable all three signature options + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376'; + _sql($sql, $errored, $error_ary); + } + + if (!isset($config['delete_time'])) + { + set_config('delete_time', $config['edit_time']); + } + + $no_updates = false; + break; + + // No changes from 3.0.6-RC1 to 3.0.6-RC2 + case '3.0.6-RC1': + break; + + // Changes from 3.0.6-RC2 to 3.0.6-RC3 + case '3.0.6-RC2': + + // Update the Custom Profile Fields based on previous settings to the new format + $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . ' + SET field_show_on_vt = 1 + WHERE field_hide = 0 + AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)'; + _sql($sql, $errored, $error_ary); + $no_updates = false; + + break; + } +} + + +/** +* 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(); + $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'])) + { + 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 ($column_exists = $this->sql_column_exists($table, $column_name)) + { + $result = $this->sql_column_change($table, $column_name, $column_data, true); + } + else + { + $result = $this->sql_column_add($table, $column_name, $column_data, true); + } + + 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); + } + } + } + } + + // 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 = $this->sql_column_exists($table, $column_name)) + { + 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 + { + $result = $this->sql_column_add($table, $column_name, $column_data, true); + } + + if ($sqlite) + { + if ($column_exists) + { + continue; +// $sqlite_data[$table]['change_columns'][] = $result; + } + else + { + $sqlite_data[$table]['add_columns'][] = $result; + } + } + else 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) + { + if (!$this->sql_index_exists($table, $index_name)) + { + continue; + } + + $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, true); + + if ($sqlite) + { + $sqlite_data[$table]['drop_columns'][] = $result; + } + else 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, true); + + if ($sqlite) + { + $sqlite_data[$table]['primary_key'] = $result; + } + else 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) + { + if ($this->sql_unique_index_exists($table, $index_name)) + { + continue; + } + + $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) + { + if ($this->sql_index_exists($table, $index_name)) + { + continue; + } + + $result = $this->sql_create_index($table, $index_name, $column); + + if ($this->return_statements) + { + $statements = array_merge($statements, $result); + } + } + } + } + + 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; + } + } + + /** + * 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 LOWER(table_name) = '" . strtolower($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 = '" . strtoupper($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; + } + } + + /** + * 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 + * + * @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 = '" . strtoupper($table_name) . "' + AND generated = 'N' + AND uniqueness = 'NONUNIQUE'"; + $col = 'index_name'; + break; + + case 'sqlite': + $sql = "PRAGMA index_list('" . $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; + } + + // 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); + return true; + } + } + $this->db->sql_freeresult($result); + + return false; + } + + /** + * 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} "; + $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'; + + // 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) + { + $return_array['default'] = 'DEFAULT (' . $column_data[1] . ') '; + $sql_default .= $return_array['default']; + } + else + { + $return_array['default'] = 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') '; + $sql_default .= $return_array['default']; + } + } + + 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, $inline = false) + { + $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); + $statements = array(); + + 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': + $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; + + 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 + 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, $inline = false) + { + $statements = array(); + + switch ($this->sql_layer) + { + case 'firebird': + $statements[] = 'ALTER TABLE ' . $table_name . ' DROP "' . strtoupper($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 ($inline && $this->return_statements) + { + return $column_name; + } + + 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, $inline = false) + { + $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': + + if ($inline && $this->return_statements) + { + return $column; + } + + $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, $inline = false) + { + $column_data = $this->sql_prepare_column_data($table_name, $column_name, $column_data); + $statements = array(); + + switch ($this->sql_layer) + { + case 'firebird': + // Change type... + 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': + $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': + 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': + + if ($inline && $this->return_statements) + { + return $column_name . ' ' . $column_data['column_type_sql']; + } + + $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 b68de2323d6444b4b3685a98bbcb9500a38e45cb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 16 Dec 2009 15:48:23 +0000 Subject: merge changes from 3.0.x branch git-svn-id: file:///svn/phpbb/trunk@10342 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/install/database_update.php | 93 ++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 22 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index ce223cf302..bf9c183e0c 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; @@ -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); @@ -45,7 +49,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); @@ -346,11 +350,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 +724,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 +735,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(), @@ -885,6 +893,10 @@ 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-RC4 + '3.0.6-RC3' => array(), + // No changes from 3.0.6-RC4 to 3.0.6 + '3.0.6-RC4' => array(), ); } @@ -1051,10 +1063,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; @@ -1197,6 +1220,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'), @@ -1204,8 +1239,6 @@ function change_database_data(&$no_updates, $version) ), ); - global $db_tools; - $statements = $db_tools->perform_schema_changes($changes); foreach ($statements as $sql) @@ -1528,6 +1561,14 @@ function change_database_data(&$no_updates, $version) $no_updates = false; break; + + // No changes from 3.0.6-RC3 to 3.0.6-RC4 + case '3.0.6-RC3': + break; + + // No changes from 3.0.6-RC4 to 3.0.6 + case '3.0.6-RC4': + break; } } @@ -2515,13 +2556,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; } @@ -2548,7 +2588,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': @@ -3222,7 +3270,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 76e530196bb99d02b3d6d7736fde027fa5e2bae8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 11 Mar 2010 15:46:14 +0100 Subject: [feature/request-class] Use the request class in the installer & updater. Just like common.php database_update.php and install/index.php need to include the request class files and create an instance for use in request_var. PHPBB3-9716 --- phpBB/install/database_update.php | 13 ++++++++++--- 1 file changed, 10 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 ca4ef817be..d571d41be4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -66,6 +66,9 @@ require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); +require($phpbb_root_path . 'includes/request/deactivated_super_global.' . $phpEx); +require($phpbb_root_path . 'includes/request/request_interface.' . $phpEx); +require($phpbb_root_path . 'includes/request/request.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx)) @@ -92,10 +95,14 @@ else define('STRIP', (get_magic_quotes_gpc()) ? true : false); } +$request = new phpbb_request(); $user = new user(); $cache = new cache(); $db = new $sql_db(); +// make sure request_var uses this request instance +request_var($request, 0); // "dependency injection" for a function + // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) { @@ -1947,7 +1954,7 @@ class updater_db_tools 'VCHAR_CI' => '[varchar] (255)', 'VARBINARY' => '[varchar] (255)', ), - + 'mssqlnative' => array( 'INT:' => '[int]', 'BINT' => '[float]', @@ -1977,7 +1984,7 @@ class updater_db_tools 'VCHAR_CI' => '[varchar] (255)', 'VARBINARY' => '[varchar] (255)', ), - + 'oracle' => array( 'INT:' => 'number(%d)', 'BINT' => 'number(20)', @@ -2124,7 +2131,7 @@ class updater_db_tools case 'mssql_odbc': $this->sql_layer = 'mssql'; break; - + case 'mssqlnative': $this->sql_layer = 'mssqlnative'; break; -- cgit v1.2.1 From 0ae7df8a51129f2ece86f959e2e155d988feb081 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 13 Mar 2010 11:28:41 +0100 Subject: [feature/request-class] Request class test now uses a type cast helper mock. Removed the dependency of the request class test on having an actual phpbb_type_cast_helper instance, by replacing it with an object mocking the phpbb_type_cast_helper_interface. PHPBB3-9716 --- 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 d571d41be4..483f24f3e5 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -66,6 +66,8 @@ require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); +require($phpbb_root_path . 'includes/request/type_cast_helper_interface.' . $phpEx); +require($phpbb_root_path . 'includes/request/type_cast_helper.' . $phpEx); require($phpbb_root_path . 'includes/request/deactivated_super_global.' . $phpEx); require($phpbb_root_path . 'includes/request/request_interface.' . $phpEx); require($phpbb_root_path . 'includes/request/request.' . $phpEx); @@ -95,13 +97,13 @@ else define('STRIP', (get_magic_quotes_gpc()) ? true : false); } -$request = new phpbb_request(); +$request = new phpbb_request(new phpbb_type_cast_helper()); $user = new user(); $cache = new cache(); $db = new $sql_db(); // make sure request_var uses this request instance -request_var($request, 0); // "dependency injection" for a function +request_var('', 0, false, false, $request); // "dependency injection" for a function // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) -- cgit v1.2.1 From 456de639123ae3da6320bed6140ab69ac9925e74 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 31 Aug 2010 21:26:50 +0200 Subject: [feature/request-class] Refactor request classes to use autoloading All class names have been adjusted to use a phpbb_request prefix, allowing them to be autoloaded. Also introduces some improvements to autoloading in general. PHPBB3-9716 --- phpBB/install/database_update.php | 13 ++++++------- 1 file changed, 6 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 483f24f3e5..69f5f58563 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -66,11 +66,6 @@ require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); -require($phpbb_root_path . 'includes/request/type_cast_helper_interface.' . $phpEx); -require($phpbb_root_path . 'includes/request/type_cast_helper.' . $phpEx); -require($phpbb_root_path . 'includes/request/deactivated_super_global.' . $phpEx); -require($phpbb_root_path . 'includes/request/request_interface.' . $phpEx); -require($phpbb_root_path . 'includes/request/request.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); if (file_exists($phpbb_root_path . 'includes/functions_content.' . $phpEx)) @@ -97,9 +92,13 @@ else define('STRIP', (get_magic_quotes_gpc()) ? true : false); } -$request = new phpbb_request(new phpbb_type_cast_helper()); -$user = new user(); $cache = new cache(); + +$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache); +$class_loader->register(); + +$request = new phpbb_request(); +$user = new user(); $db = new $sql_db(); // make sure request_var uses this request instance -- cgit v1.2.1 From 30b57332e3b0a07294bacba8df26b309818662f9 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 5 Oct 2010 22:53:06 +0200 Subject: [feature/request-class] Fix missing include in database_update install/database_update.php was missing the include for the class loader. PHPBB3-9716 --- 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 69f5f58563..211e194c73 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -60,6 +60,7 @@ if (!empty($load_extensions) && function_exists('dl')) } // Include files +require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx); require($phpbb_root_path . 'includes/cache.' . $phpEx); require($phpbb_root_path . 'includes/template.' . $phpEx); -- cgit v1.2.1 From af5b9a96409d788733fcb1ff367e0c7fb0583702 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 9 Nov 2010 08:59:25 +0100 Subject: [ticket/9556] Drop php closing tags, add trailing newline Closing tags converted using Oleg's script. remove-php-end-tags.py -a . Trailing newlines added using the following where $ext is file extension. find . -type f -name "*.$ext" -print | xargs printf "e %s\nw\n" | ed -s; Extensions: php, css, html, js, xml. PHPBB3-9556 --- phpBB/install/database_update.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a1c3239cbf..30ca8333c2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -3805,5 +3805,3 @@ class updater_db_tools return $this->_sql_run_sql($statements); } } - -?> -- cgit v1.2.1 From 3c713b5e7d883d7414538de0557c68195cd73018 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 3 Aug 2010 11:41:01 +0200 Subject: [ticket/9746] Adding some more calls to phpbb_ip_normalise(). PHPBB3-9746 --- 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 9aa7a34f6b..b33c0f4a11 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -127,8 +127,11 @@ $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); // We do not need this any longer, unset for safety purposes unset($dbpasswd); -$user->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; -$user->ip = (stripos($user->ip, '::ffff:') === 0) ? substr($user->ip, 7) : $user->ip; +$user->ip = ''; +if (!empty($_SERVER['REMOTE_ADDR'])) +{ + $user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($_SERVER['REMOTE_ADDR']) : htmlspecialchars($_SERVER['REMOTE_ADDR']); +} $sql = "SELECT config_value FROM " . CONFIG_TABLE . " -- cgit v1.2.1 From 9329b16ab13f3a4caf107df358c3c58bda2dcd8a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 3 Nov 2010 18:35:31 +0100 Subject: [task/acm-refactor] Refactor the ACM classes to have a common interface. They are now refered to as cache drivers rather than ACM classes. The additional utility functions from the original cache class have been moved to the cache_service. The class loader is now instantiated without a cache instance and passed one as soon as it is constructed to allow autoloading the cache classes. PHPBB3-9983 --- phpBB/install/database_update.php | 11 ++++++----- 1 file changed, 6 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 b33c0f4a11..961edd589f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -61,8 +61,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx); -require($phpbb_root_path . 'includes/cache.' . $phpEx); require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); @@ -93,11 +91,14 @@ else define('STRIP', (get_magic_quotes_gpc()) ? true : false); } -$cache = new cache(); - -$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx, $cache); +$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx); $class_loader->register(); +// set up caching +$acm = phpbb_cache_factory::create($acm_type)->get_acm(); +$class_loader->set_acm($acm); +$cache = new phpbb_cache_service($acm); + $request = new phpbb_request(); $user = new user(); $db = new $sql_db(); -- cgit v1.2.1 From 1aef7eb20ee195c7f21d6c5b78653b7c43e669ec Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 9 Jan 2011 21:09:56 +0100 Subject: [task/acm-refactor] Cleaning up left over mentions of ACM and fixing tests. PHPBB3-9983 --- 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 961edd589f..f73f7472f0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -95,9 +95,9 @@ $class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx); $class_loader->register(); // set up caching -$acm = phpbb_cache_factory::create($acm_type)->get_acm(); -$class_loader->set_acm($acm); -$cache = new phpbb_cache_service($acm); +$cache_factory = new phpbb_cache_factory($acm_type); +$class_loader->set_cache($cache_factory->get_driver()); +$cache = $cache_factory->get_service(); $request = new phpbb_request(); $user = new user(); -- cgit v1.2.1 From fb2642bbc6360dacfd4a3cc9f7e9447b02cb46a1 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 10 Jan 2011 02:27:18 +0100 Subject: [task/config-class] Implemented a config class to replace the global array. There is a phpbb_config class which simply holds an array and does not persist any data. It implements ArrayAccess, Countable and IteratorAggregate to allow regular use of configuration as if it was still an array. The phpbb_config_db class depends on an instance of the dbal and a cache driver. It obtains the configuration data from cache and database as necessary and persists data to the database. The functions set_config and set_config_count remain for backward compatability but they only call methods on the new config class now instead of directly manipulating the database and cache. PHPBB3-9988 --- phpBB/install/database_update.php | 14 +++----------- 1 file changed, 3 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 f73f7472f0..cecd565fa5 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -165,17 +165,9 @@ include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); $inline_update = (request_var('type', 0)) ? true : false; // To let set_config() calls succeed, we need to make the config array available globally -$config = array(); - -$sql = 'SELECT * - FROM ' . CONFIG_TABLE; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $config[$row['config_name']] = $row['config_value']; -} -$db->sql_freeresult($result); +$config = new phpbb_config_db($db, $cache_factory->get_driver()); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config); // 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) -- cgit v1.2.1 From 6b1e343d8dae618afd0cb04173749f005c10e376 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 11 Jan 2011 23:25:51 +0100 Subject: [task/config-class] Always specify the config table to use. PHPBB3-9988 --- 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 cecd565fa5..0969654084 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -165,7 +165,7 @@ include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); $inline_update = (request_var('type', 0)) ? true : false; // To let set_config() calls succeed, we need to make the config array available globally -$config = new phpbb_config_db($db, $cache_factory->get_driver()); +$config = new phpbb_config_db($db, $cache_factory->get_driver(), CONFIG_TABLE); set_config(null, null, null, $config); set_config_count(null, null, null, $config); -- cgit v1.2.1 From f11579549d0250733f4a2bd1759adc2db6d587d3 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Wed, 12 Jan 2011 00:28:12 +0100 Subject: [task/config-class] Do not create multiple cache driver instances. Retrieve the driver from the service instead of creating new ones over and over from the factory. PHPBB3-9988 --- 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 0969654084..4eedf7aa33 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -96,8 +96,8 @@ $class_loader->register(); // set up caching $cache_factory = new phpbb_cache_factory($acm_type); -$class_loader->set_cache($cache_factory->get_driver()); $cache = $cache_factory->get_service(); +$class_loader->set_cache($cache->get_driver()); $request = new phpbb_request(); $user = new user(); @@ -165,7 +165,7 @@ include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); $inline_update = (request_var('type', 0)) ? true : false; // To let set_config() calls succeed, we need to make the config array available globally -$config = new phpbb_config_db($db, $cache_factory->get_driver(), CONFIG_TABLE); +$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); set_config(null, null, null, $config); set_config_count(null, null, null, $config); -- cgit v1.2.1 From 451198b4671b8feb05c644f9172212cdc6b32df5 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 25 Apr 2010 12:51:45 -0400 Subject: [feature/system-cron] Set use_system_cron config value during upgrade. PHPBB3-9596 --- 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 06b37bfcca..c47e9b790a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1863,6 +1863,10 @@ function change_database_data(&$no_updates, $version) // No changes from 3.0.8-RC1 to 3.0.8 case '3.0.8-RC1': break; + + case '3.0.9-dev': + set_config('use_system_cron', 0); + break; } } -- cgit v1.2.1 From 528c54f0f73eb73bfc347b4fc448c6dbba0e0460 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Feb 2011 11:29:49 +0100 Subject: [ticket/10045] Database updater version for 3.1-changes should be 3.1.0-dev PHPBB3-10045 --- 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 c47e9b790a..0c17c18b5e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2,13 +2,12 @@ /** * * @package install -* @version $Id$ * @copyright (c) 2006 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ -$updates_to_version = '3.0.9-dev'; +$updates_to_version = '3.1.0-dev'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -921,6 +920,8 @@ function database_update_info() '3.0.7-PL1' => array(), // No changes from 3.0.8-RC1 to 3.0.8 '3.0.8-RC1' => array(), + // No changes from 3.1.0-dev to 3.1.0-A1 + '3.1.0-dev' => array(), ); } @@ -1864,7 +1865,8 @@ function change_database_data(&$no_updates, $version) case '3.0.8-RC1': break; - case '3.0.9-dev': + // Changes from 3.1.0-dev to 3.1.0-A1 + case '3.1.0-dev': set_config('use_system_cron', 0); break; } -- cgit v1.2.1 From 023a10208216a78c32994a5d7997299cf3b5fdae Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 9 Feb 2011 21:03:37 +0100 Subject: [ticket/9549] Update database with the new config values and columns PHPBB3-9549 --- phpBB/install/database_update.php | 65 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 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 0c17c18b5e..9e8a063f44 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -920,8 +920,19 @@ function database_update_info() '3.0.7-PL1' => array(), // No changes from 3.0.8-RC1 to 3.0.8 '3.0.8-RC1' => array(), - // No changes from 3.1.0-dev to 3.1.0-A1 - '3.1.0-dev' => array(), + // Changes from 3.1.0-dev to 3.1.0-A1 + '3.1.0-dev' => array( + 'add_columns' => array( + GROUPS_TABLE => array( + 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), + ), + ), + 'change_columns' => array( + GROUPS_TABLE => array( + 'group_legend' => array('UINT', 0), + ), + ), + ), ); } @@ -1868,6 +1879,56 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': set_config('use_system_cron', 0); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 1 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'ADMINISTRATORS'"; + _sql($sql, $errored, $error_ary); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 2 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'GLOBAL_MODERATORS'"; + _sql($sql, $errored, $error_ary); + + set_config('legend_sort_groupname', '1'); + set_config('teampage_multiple', '1'); + set_config('teampage_forums', '1'); + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + WHERE group_legend = 1 + ORDER BY group_name ASC'; + $result = $db->sql_query($sql); + + $next_legend = 1; + while ($row = $db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_legend = ' . $next_legend . ' + WHERE group_id = ' . (int) $row['group_id']; + _sql($sql, $errored, $error_ary); + + $next_legend++; + } + $db->sql_freeresult($result); + unset($next_legend); + + // Install modules + $modules_to_install = array( + 'position' => array( + 'base' => 'groups', + 'class' => 'acp', + 'title' => 'ACP_GROUPS_POSITION', + 'auth' => 'acl_a_group', + 'cat' => 'ACP_GROUPS', + ), + ); + + _add_modules($modules_to_install); + + $no_updates = false; break; } } -- cgit v1.2.1 From 8d12838aedeaa23cccf128e98e93d05507edda4d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 14 Feb 2011 16:09:09 +0100 Subject: [ticket/9549] Make the class non static and extend delete_group function. delete_group() can now be used, so it does not update the actual group. This can save a query, when you update the group anyway. PHPBB3-9549 --- 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 9e8a063f44..792e33245e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -920,6 +920,7 @@ function database_update_info() '3.0.7-PL1' => array(), // No changes from 3.0.8-RC1 to 3.0.8 '3.0.8-RC1' => array(), + // Changes from 3.1.0-dev to 3.1.0-A1 '3.1.0-dev' => array( 'add_columns' => array( -- cgit v1.2.1 From fd7daf2a2b04463deb07b350ffb99d2c99e982c4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 24 Feb 2011 02:05:48 +0100 Subject: [ticket/9549] Change default value of "sort legend by group name" to false. PHPBB3-9549 --- 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 792e33245e..b3d575ef63 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1893,7 +1893,7 @@ function change_database_data(&$no_updates, $version) AND group_name = 'GLOBAL_MODERATORS'"; _sql($sql, $errored, $error_ary); - set_config('legend_sort_groupname', '1'); + set_config('legend_sort_groupname', '0'); set_config('teampage_multiple', '1'); set_config('teampage_forums', '1'); -- cgit v1.2.1 From d811820bc11bac61076d5a92d741d22df9944af8 Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 11 Apr 2011 19:59:50 +0800 Subject: [feature/attachment-management-no-reassignment] Further feature adjustments. -add database update entry; - add files statistics checks; - improve files deletion procedure; - improve reversed order for pagination; - adjust template file; - add missing comma for orphan key in info module; - change module mode name; - fix module explanation text; - add files comments output; - change attachments per page amount from posts to topics per page value. PHPBB3-9721 --- 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 cf611ca951..4f2a5966ee 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1958,6 +1958,13 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_group', 'cat' => 'ACP_GROUPS', ), + 'manage' => array( + 'base' => 'attachments', + 'class' => 'acp', + 'title' => 'ACP_MANAGE_ATTACHMENTS', + 'auth' => 'acl_a_attach', + 'cat' => 'ACP_ATTACHMENTS', + ), ); _add_modules($modules_to_install); -- cgit v1.2.1 From 8fa44cc3b9778f84ca20eab1c1d404c4f848eab4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 19 Oct 2010 17:06:23 +0200 Subject: [ticket/8542] Display custom profile fields in private messages Introduce an option to display the cpf in the PM view. PHPBB3-8542 --- 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 cf611ca951..d646e200a3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -936,6 +936,9 @@ function database_update_info() GROUPS_TABLE => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), ), + PROFILE_FIELDS_TABLE => array( + 'field_show_on_pm' => array('BOOL', 0), + ), ), 'change_columns' => array( GROUPS_TABLE => array( @@ -1962,6 +1965,9 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Allow custom profile fields in pm templates + set_config('load_cpf_pm', '0'); + $no_updates = false; break; } -- cgit v1.2.1 From 766537035ea2f04c5aa3c59c15edc15f4ecd050f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 9 Jul 2011 15:28:33 +0200 Subject: [ticket/10258] Change the DOCTYPE to HTML5 PHPBB3-10258 --- phpBB/install/database_update.php | 19 ++++++++----------- 1 file changed, 8 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 fc205d4e56..09e2417efa 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -205,13 +205,12 @@ $ga_forum_id = request_var('ga_forum_id', 0); if ($has_global && !$ga_forum_id) { ?> - - + + - - - + + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> @@ -259,13 +258,11 @@ if ($has_global && !$ga_forum_id) header('Content-type: text/html; charset=UTF-8'); ?> - - + + - - - - + + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> -- cgit v1.2.1 From f7b06ca12db9da519d49ce334eaf96573d003c0f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 9 Jul 2011 23:33:44 +0200 Subject: [feature/template-engine] Move template.php to includes/template This allows making use of autoloading. PHPBB3-9726 --- phpBB/install/database_update.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0d3e96f342..ca7ac8aad5 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -60,7 +60,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/template.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); -- cgit v1.2.1 From 854c14f9f6ae78318e159e27724178579ff48dcc Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 10 Jul 2011 23:04:14 +0200 Subject: [ticket/10258] Remove X-UA-Compatible and imagetoolbar meta tags These meta tags are IE specific and do not validate as HTML5. PHPBB3-10258 --- phpBB/install/database_update.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 09e2417efa..b8fe493ab8 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -210,8 +210,6 @@ if ($has_global && !$ga_forum_id) - - <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> @@ -262,8 +260,6 @@ header('Content-type: text/html; charset=UTF-8'); - - <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> -- cgit v1.2.1 From 136a932303d7d7a427043d1834b6df40dc219b0e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 12 Jul 2011 01:32:00 +0200 Subject: [ticket/10258] Remove the meta charset tag The charset tag is useless, because if a charset content-type header is present it takes precedence. And phpBB always sends such a header. PHPBB3-10258 --- 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 b8fe493ab8..3f3ff59c5d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -209,8 +209,6 @@ if ($has_global && !$ga_forum_id) - - <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> @@ -259,7 +257,6 @@ header('Content-type: text/html; charset=UTF-8'); - <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> -- cgit v1.2.1 From 0bf6966c5228d446c4f0d3862619db0f619c7369 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 13 Jul 2011 19:20:16 +0200 Subject: [feature/request-class] Add server(), header() and is_ajax() to request Extend the request class with helpers for reading server vars (server()) and HTTP request headers (header()). Refactor the existing code base to make use of these helpers, make $_SERVER a deactivated super global. Also introduce an is_ajax() method, which checks the X-Requested-With header for the value 'XMLHttpRequest', which is sent by JavaScript libraries, such as jQuery. PHPBB3-9716 --- 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 615122da4f..d38802e380 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -144,9 +144,9 @@ $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); unset($dbpasswd); $user->ip = ''; -if (!empty($_SERVER['REMOTE_ADDR'])) +if ($request->server('REMOTE_ADDR')) { - $user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($_SERVER['REMOTE_ADDR']) : htmlspecialchars($_SERVER['REMOTE_ADDR']); + $user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($request->server('REMOTE_ADDR')) : $request->server('REMOTE_ADDR', '', true); } $sql = "SELECT config_value -- cgit v1.2.1 From 681c4a478d6eff7dbcebadca04f4afa28da750a8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 29 Jul 2011 16:32:22 +0200 Subject: [ticket/10258] Add HTML5 meta charset tag This allows knowing the charset when saving web pages to disk. Also, this is supported by all browsers. PHPBB3-10258 --- 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 bf3dec5bab..79aa57aea0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -208,6 +208,7 @@ if ($has_global && !$ga_forum_id) + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> @@ -257,6 +258,7 @@ header('Content-type: text/html; charset=UTF-8'); + <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> -- cgit v1.2.1 From c5cef773c4811d2041c56a9c34da94a30f8190e1 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 18 Aug 2011 23:38:39 +0200 Subject: [feature/request-class] Adjust code base to do html decoding manually PHPBB3-9716 --- 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 cd060a0b2b..b69d44d7be 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -145,7 +145,7 @@ unset($dbpasswd); $user->ip = ''; if ($request->server('REMOTE_ADDR')) { - $user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($request->server('REMOTE_ADDR')) : $request->server('REMOTE_ADDR', '', true); + $user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($request->server('REMOTE_ADDR')) : $request->server('REMOTE_ADDR'); } $sql = "SELECT config_value -- cgit v1.2.1 From 33adfd633b6fa92bbc6e0b4fd303e942d2923b6e Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 3 Sep 2011 18:55:30 +0300 Subject: [feature/remove-imagesets] Changing database structure Removing imagesets. Changing database structure PHPBB3-10336 --- phpBB/install/database_update.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index b69d44d7be..7f542974d9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1061,6 +1061,15 @@ function database_update_info() 'group_legend' => array('UINT', 0), ), ), + 'drop_columns' => array( + STYLES_TABLE => array( + 'imageset_id', + ), + ), + 'drop_tables' => array( + STYLES_IMAGESET_TABLE, + STYLES_IMAGESET_DATA_TABLE, + ), ), ); } @@ -2128,6 +2137,10 @@ function change_database_data(&$no_updates, $version) ); _add_modules($modules_to_install); + + $sql = 'DELETE FROM ' . MODULES_TABLE . " + WHERE module_basename = 'styles' AND module_mode = 'imageset'"; + _sql($sql, $errored, $error_ary); // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour -- cgit v1.2.1 From cb245f5d04bcd36dd1ad8d3a95d7718ef5b15858 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Tue, 20 Sep 2011 21:04:17 +0100 Subject: [feature/remove-db-styles] Add schema changes sinces 3.0.x. PHPBB3-9741 --- 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 7f542974d9..18741191d8 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1062,13 +1062,22 @@ function database_update_info() ), ), 'drop_columns' => array( - STYLES_TABLE => array( + STYLES_TABLE => array( 'imageset_id', ), + STYLES_TEMPLATE_TABLE => array( + 'template_storedb', + ), + STYLES_THEME_TABLE => array( + 'theme_storedb', + 'theme_mtime', + 'theme_data', + ), ), 'drop_tables' => array( STYLES_IMAGESET_TABLE, STYLES_IMAGESET_DATA_TABLE, + STYLES_TEMPLATE_DATA_TABLE, ), ), ); -- cgit v1.2.1 From 56c6476233646e7c735aa4e3b98c4a6b62df5c7d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 25 Sep 2011 15:12:56 -0700 Subject: [ticket/10390] Allow option for jQuery to be hosted by a remote CDN Add an option to the ACP so admins can choose to host jQuery from the local version shipped with phpBB, or via a popular CDN. PHPBB3-10390 --- 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 18741191d8..1a47e2a656 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2090,6 +2090,7 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': + set_config('load_jquery_host', 'localhost'); set_config('use_system_cron', 0); $sql = 'UPDATE ' . GROUPS_TABLE . ' -- cgit v1.2.1 From 2dca3c3c278e99cfd6cdbea7149063d160e4cc11 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 26 Sep 2011 20:26:32 -0700 Subject: [ticket/10390] Serve jQuery from Google CDN Yes/No button in ACP jQuery will now be available via remote CDN from Google. Microsoft and jQuery CDNs have been removed, so we can simplify this option for the user. Default mode is NO so the copy of jQuery included with phpBB is served by default. PHPBB3-10390 --- phpBB/install/database_update.php | 3 ++- 1 file changed, 2 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 1a47e2a656..1fa01a534d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2090,7 +2090,8 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': - set_config('load_jquery_host', 'localhost'); + set_config('load_jquery_cdn', 0); + set_config('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); set_config('use_system_cron', 0); $sql = 'UPDATE ' . GROUPS_TABLE . ' -- cgit v1.2.1 From 14f1e581faa3b66e7689c55c1e9c0485c0872b1e Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 9 Jun 2011 05:13:26 +0200 Subject: [feature/extension-manager] Extension Manager & Finder Extensions RFC: http://area51.phpbb.com/phpBB/viewtopic.php?f=84&t=41499 Ticket: http://tracker.phpbb.com/browse/PHPBB3-10323 PHPBB3-10323 --- phpBB/install/database_update.php | 18 +++++++++++++++++- 1 file changed, 17 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 18741191d8..b2419df3c9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -104,8 +104,12 @@ if (!defined('LOGIN_ATTEMPT_TABLE')) { define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); } +if (!defined('EXT_TABLE')) +{ + define('EXT_TABLE', $table_prefix . 'ext'); +} -$class_loader = new phpbb_class_loader($phpbb_root_path, '.' . $phpEx); +$class_loader = new phpbb_class_loader($phpbb_root_path . 'includes/', $phpbb_root_path . 'ext/', '.' . $phpEx); $class_loader->register(); // set up caching @@ -1048,6 +1052,18 @@ function database_update_info() // Changes from 3.1.0-dev to 3.1.0-A1 '3.1.0-dev' => array( + 'add_tables' => array( + EXT_TABLE => array( + 'COLUMNS' => array( + 'ext_name' => array('VCHAR', ''), + 'ext_active' => array('BOOL', 0), + ), + 'KEYS' => array( + 'ext_name' => array('UNIQUE', 'ext_name'), + 'ext_active' => array('INDEX', 'ext_active'), + ), + ), + ), 'add_columns' => array( GROUPS_TABLE => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), -- cgit v1.2.1 From dcc5ca53778184f0719b9ac0c221688ad03bd57e Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 15 Aug 2011 20:00:47 -0400 Subject: [feature/extension-manager] Make search backends loadable from extensions Search backends are now required to be autoloadable. The database updater to 3.1 tries to guess the class name as phpbb_search_ which works for the default backends we ship. PHPBB3-10323 --- 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 b2419df3c9..1f3c01ee3e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2106,6 +2106,10 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': + // try to guess the new auto loaded search class name + // works for native and mysql fulltext + set_config('search_type', 'phpbb_search_' . $config['search_type']); + set_config('use_system_cron', 0); $sql = 'UPDATE ' . GROUPS_TABLE . ' -- cgit v1.2.1 From 96209e022477d97b581b79cabace4caddd19501b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 15 Aug 2011 21:38:47 -0400 Subject: [feature/extension-manager] The class loader no longer knows about extensions Instead the class loader is instantiated twice. Once with the phpbb_ prefix and once with the phpbb_ext_ prefix. PHPBB3-10323 --- phpBB/install/database_update.php | 9 ++++++--- 1 file changed, 6 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 1f3c01ee3e..64dea37ef8 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -109,13 +109,16 @@ if (!defined('EXT_TABLE')) define('EXT_TABLE', $table_prefix . 'ext'); } -$class_loader = new phpbb_class_loader($phpbb_root_path . 'includes/', $phpbb_root_path . 'ext/', '.' . $phpEx); -$class_loader->register(); +$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); +$phpbb_class_loader_ext->register(); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); +$phpbb_class_loader->register(); // set up caching $cache_factory = new phpbb_cache_factory($acm_type); $cache = $cache_factory->get_service(); -$class_loader->set_cache($cache->get_driver()); +$phpbb_class_loader_ext->set_cache($cache->get_driver()); +$phpbb_class_loader->set_cache($cache->get_driver()); $request = new phpbb_request(); $user = new user(); -- cgit v1.2.1 From 60ad0e21b5d4f940740650df69b7134a573f2a97 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 21 Aug 2011 03:06:56 -0400 Subject: [feature/extension-manager] Remove the ext_active index for lack of specificity PHPBB3-10323 --- phpBB/install/database_update.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 64dea37ef8..45de19c918 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1063,7 +1063,6 @@ function database_update_info() ), 'KEYS' => array( 'ext_name' => array('UNIQUE', 'ext_name'), - 'ext_active' => array('INDEX', 'ext_active'), ), ), ), -- cgit v1.2.1 From c7a986eccdac183cc81b3da486092f4ab82109ba Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 29 Aug 2011 17:17:40 -0400 Subject: [feature/extension-manager] Use an incremental process for enable and purge The enable or purge operation of an extension could take a long time if an expensive operation needs to be executed on a large set of data. To allow this to succeed from a web interface with max_execution_time set in the webserver's php configuration, subsequent requests must continue the operation started earlier. So individual enable and purge implementations must be able to spread their work across multiple steps. PHPBB3-10323 --- 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 45de19c918..9a7231040b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1060,6 +1060,7 @@ function database_update_info() 'COLUMNS' => array( 'ext_name' => array('VCHAR', ''), 'ext_active' => array('BOOL', 0), + 'ext_state' => array('TEXT', ''), ), 'KEYS' => array( 'ext_name' => array('UNIQUE', 'ext_name'), -- cgit v1.2.1 From 48391d2dde8f40e3c7e7d4a41b8ff1c32508ffc1 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 29 Aug 2011 20:05:46 -0400 Subject: [feature/extension-manager] Create an extension manager on update and install It's required when adding modules PHPBB3-10323 --- 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 9a7231040b..2635396af0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -678,7 +678,13 @@ function _write_result($no_updates, $errored, $error_ary) function _add_modules($modules_to_install) { - global $phpbb_root_path, $phpEx, $db; + global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager; + + // modules require an extension manager + if (empty($phpbb_extension_manager)) + { + $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx"); + } include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); -- cgit v1.2.1 From fe4b8818ec1f448d5625534e5027cfbc1177ab9a Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 29 Aug 2011 20:54:42 -0400 Subject: [feature/extension-manager] Always store the full class name as module basename The updater swaps out all basenames. PHPBB3-10323 --- phpBB/install/database_update.php | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 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 2635396af0..221f6b1344 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2115,6 +2115,37 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': + + // rename all module basenames to full classname + $sql = 'SELECT module_id, module_basename, module_class + FROM ' . MODULES_TABLE; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $module_id = (int) $row['module_id']; + unset($row['module_id']); + + if (!empty($row['module_basename']) && !empty($row['module_class'])) + { + // all the class names start with class name or with phpbb_ for auto loading + if (strpos($row['module_basename'], $row['module_class'] . '_') !== 0 && + strpos($row['module_basename'], 'phpbb_') !== 0) + { + $row['module_basename'] = $row['module_class'] . '_' . $row['module_basename']; + + $sql_update = $db->sql_build_array('UPDATE', $row); + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET ' . $sql_update . ' + WHERE module_id = ' . $module_id; + _sql($sql, $errored, $error_ary); + } + } + } + + $db->sql_freeresult($result); + // try to guess the new auto loaded search class name // works for native and mysql fulltext set_config('search_type', 'phpbb_search_' . $config['search_type']); @@ -2159,14 +2190,14 @@ function change_database_data(&$no_updates, $version) // Install modules $modules_to_install = array( 'position' => array( - 'base' => 'groups', + 'base' => 'acp_groups', 'class' => 'acp', 'title' => 'ACP_GROUPS_POSITION', 'auth' => 'acl_a_group', 'cat' => 'ACP_GROUPS', ), 'manage' => array( - 'base' => 'attachments', + 'base' => 'acp_attachments', 'class' => 'acp', 'title' => 'ACP_MANAGE_ATTACHMENTS', 'auth' => 'acl_a_attach', -- cgit v1.2.1 From 1df2148bf4d12405018fcbe93cdbff7b9bf4174e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 13 Oct 2011 23:29:52 +0200 Subject: [ticket/10409] Running database_update.php multiple times breaks the update PHPBB3-10409 --- phpBB/install/database_update.php | 85 ++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 28 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 18741191d8..4507e5c371 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2090,42 +2090,68 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': - set_config('use_system_cron', 0); - - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 1 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'ADMINISTRATORS'"; - _sql($sql, $errored, $error_ary); - - $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_teampage = 2 - WHERE group_type = ' . GROUP_SPECIAL . " - AND group_name = 'GLOBAL_MODERATORS'"; - _sql($sql, $errored, $error_ary); - - set_config('legend_sort_groupname', '0'); - set_config('teampage_multiple', '1'); - set_config('teampage_forums', '1'); + if (!isset($config['use_system_cron'])) + { + set_config('use_system_cron', 0); + } - $sql = 'SELECT group_id + $sql = 'SELECT group_teampage FROM ' . GROUPS_TABLE . ' - WHERE group_legend = 1 - ORDER BY group_name ASC'; - $result = $db->sql_query($sql); + WHERE group_teampage > 0'; + $result = $db->sql_query_limit($sql, 1); + $added_groups_teampage = (bool) $db->sql_fetchfield('group_teampage'); + $db->sql_freeresult($result); - $next_legend = 1; - while ($row = $db->sql_fetchrow($result)) + if (!$added_groups_teampage) { $sql = 'UPDATE ' . GROUPS_TABLE . ' - SET group_legend = ' . $next_legend . ' - WHERE group_id = ' . (int) $row['group_id']; + SET group_teampage = 1 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'ADMINISTRATORS'"; + _sql($sql, $errored, $error_ary); + + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_teampage = 2 + WHERE group_type = ' . GROUP_SPECIAL . " + AND group_name = 'GLOBAL_MODERATORS'"; _sql($sql, $errored, $error_ary); + } - $next_legend++; + if (!isset($config['use_system_cron'])) + { + set_config('legend_sort_groupname', '0'); + set_config('teampage_multiple', '1'); + set_config('teampage_forums', '1'); } + + $sql = 'SELECT group_legend + FROM ' . GROUPS_TABLE . ' + WHERE group_teampage > 1'; + $result = $db->sql_query_limit($sql, 1); + $updated_group_legend = (bool) $db->sql_fetchfield('group_teampage'); $db->sql_freeresult($result); - unset($next_legend); + + if (!$updated_group_legend) + { + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . ' + WHERE group_legend = 1 + ORDER BY group_name ASC'; + $result = $db->sql_query($sql); + + $next_legend = 1; + while ($row = $db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . GROUPS_TABLE . ' + SET group_legend = ' . $next_legend . ' + WHERE group_id = ' . (int) $row['group_id']; + _sql($sql, $errored, $error_ary); + + $next_legend++; + } + $db->sql_freeresult($result); + unset($next_legend); + } // Install modules $modules_to_install = array( @@ -2229,7 +2255,10 @@ function change_database_data(&$no_updates, $version) } // Allow custom profile fields in pm templates - set_config('load_cpf_pm', '0'); + if (!isset($config['load_cpf_pm'])) + { + set_config('load_cpf_pm', '0'); + } $no_updates = false; break; -- cgit v1.2.1 From 65a34fd047f4ac1ff3638a568f44d3fe7d664d88 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 14 Oct 2011 00:54:11 +0200 Subject: [ticket/10410] Add option to display users in their first teampage group PHPBB3-10410 --- 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 4507e5c371..8450cc4ab7 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2117,10 +2117,9 @@ function change_database_data(&$no_updates, $version) _sql($sql, $errored, $error_ary); } - if (!isset($config['use_system_cron'])) + if (!isset($config['legend_sort_groupname'])) { set_config('legend_sort_groupname', '0'); - set_config('teampage_multiple', '1'); set_config('teampage_forums', '1'); } @@ -2260,6 +2259,11 @@ function change_database_data(&$no_updates, $version) set_config('load_cpf_pm', '0'); } + if (!isset($config['teampage_memberships'])) + { + set_config('teampage_memberships', '1'); + } + $no_updates = false; break; } -- cgit v1.2.1 From 7a04c9048c110f0bd21ea3e9e869e17b408d640e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 31 Dec 2011 13:32:52 +0000 Subject: [ticket/9916] Updating header license and removing Version $Id$ PHPBB3-9916 --- 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 2b5ce4bf31..da906f0023 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -3,7 +3,7 @@ * * @package install * @copyright (c) 2006 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -- cgit v1.2.1 From e02d92ac62fbe1dc08994444c18a7447d72c56e6 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 11 Mar 2012 15:14:13 +0100 Subject: [feature/event-dispatcher] Use real EventDispatcher through composer * replace the copy-pasta EventDispatcher with the real one from Symfony2 * use composer for managing this dependency, use composer autoloading PHPBB3-9550 --- 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 843e8c2f23..a1c8fe1ef9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -82,6 +82,8 @@ if (!empty($load_extensions) && function_exists('dl')) } } +require($phpbb_root_path . 'vendor/.composer/autoload.php'); + // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); -- cgit v1.2.1 From ae3b0f736d45690d37a10a453a98e598166e8506 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 14 Mar 2012 23:18:18 +0200 Subject: [feature/merging-style-components] Updating database and acp modules Removing theme and template tables, adding new columns to styles table, deleting acp modules, deleting code that updates theme in updater PHPBB3-10632 --- phpBB/install/database_update.php | 47 +++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 843e8c2f23..995f4c9a95 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1088,6 +1088,12 @@ function database_update_info() PROFILE_FIELDS_TABLE => array( 'field_show_on_pm' => array('BOOL', 0), ), + STYLES_TABLE => array( + 'style_path' => array('VCHAR:100', ''), + 'bbcode_bitfield' => array('VCHAR:255', 'kNg='), + 'style_parent_id' => array('UINT:4', 0), + 'style_parent_tree' => array('TEXT', ''), + ), ), 'change_columns' => array( GROUPS_TABLE => array( @@ -1097,20 +1103,16 @@ function database_update_info() 'drop_columns' => array( STYLES_TABLE => array( 'imageset_id', + 'template_id', + 'theme_id', ), - STYLES_TEMPLATE_TABLE => array( - 'template_storedb', - ), - STYLES_THEME_TABLE => array( - 'theme_storedb', - 'theme_mtime', - 'theme_data', - ), ), 'drop_tables' => array( STYLES_IMAGESET_TABLE, STYLES_IMAGESET_DATA_TABLE, + STYLES_TEMPLATE_TABLE, STYLES_TEMPLATE_DATA_TABLE, + STYLES_THEME_TABLE, ), ), ); @@ -2267,12 +2269,33 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_attach', 'cat' => 'ACP_ATTACHMENTS', ), + 'install' => array( + 'base' => 'acp_styles' + 'class' => 'acp', + 'title' => 'ACP_STYLES_INSTALL', + 'auth' => 'acl_a_styles', + 'cat' => 'ACP_STYLE_MANAGEMENT', + ), + 'edit' => array( + 'base' => 'acp_styles' + 'class' => 'acp', + 'title' => 'ACP_STYLES_EDIT', + 'auth' => 'acl_a_styles', + 'cat' => 'ACP_STYLE_MANAGEMENT', + ), + 'cache' => array( + 'base' => 'acp_styles' + 'class' => 'acp', + 'title' => 'ACP_STYLES_CACHE', + 'auth' => 'acl_a_styles', + 'cat' => 'ACP_STYLE_MANAGEMENT', + ), ); _add_modules($modules_to_install); $sql = 'DELETE FROM ' . MODULES_TABLE . " - WHERE module_basename = 'styles' AND module_mode = 'imageset'"; + WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); // Localise Global Announcements @@ -2362,7 +2385,13 @@ function change_database_data(&$no_updates, $version) { set_config('teampage_memberships', '1'); } + + // Clear styles table and add prosilver entry + _sql('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); + $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; + _sql($sql, $errored, $error_ary); + $no_updates = false; break; -- cgit v1.2.1 From b672fc7ae113c0e01f1d7ce4ffae3eb26e57b586 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 26 Apr 2011 22:11:45 -0400 Subject: [feature/new-tz-handling] Started on database updater changes. The changes are tricky since we need to drop user_dst column from users table, but we need it during the data migration process to properly calculate effective timezones for all users. The change here converts user_timezone to vchar and computes timezone identifiers from the offsets. It uses database-specific functions for building SQL conditionals and concatenations which need to be implemented, probably in a separate ticket. As a result the current code is not functional. PHPBB3-9558 --- phpBB/install/database_update.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fa0fba9dc7..9d550cf938 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1090,6 +1090,9 @@ function database_update_info() GROUPS_TABLE => array( 'group_legend' => array('UINT', 0), ), + USERS_TABLE => array( + 'user_timezone' => array('VCHAR:100', ''), + ), ), 'drop_columns' => array( STYLES_TABLE => array( @@ -2352,6 +2355,25 @@ function change_database_data(&$no_updates, $version) set_config('teampage_memberships', '1'); } + // Update timezones + // user_dst is 0 if not in dst and 1 if in dst; + // this happens to be exactly the correction that should be added to the timezone offset + // to obtain dst offset. + // Parenthesize here because we operate on this value later. + $active_offset = '(user_timezone + user_dst)'; + // Now we have a tricky problem of forcing the plus sign into the expression. + // Build it via a conditional since there cannot be a portable printf equivalent in databases. + // Note that active offset is not an absolute value here - it is an expression that will + // be evaluated by the database during query execution. + // We don't print - here because it will come from active offset. + $sign = $db->conditional_sql("$active_offset < 0", '', '+'); + // Use database-specific escaping because strings are quoted differently by different databases. + $new_value = $db->concatenate_sql($db->sql_escape('GMT'), $sign, $active_offset); + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_timezone = ' . $new_value; + _sql($sql, $errored, $error_ary); + // After we have calculated the timezones we can delete user_dst column from user table. + $no_updates = false; break; } -- cgit v1.2.1 From 0af7d610c08307fbe8df20e0d44e54dcb9429d64 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 17 Mar 2012 22:45:27 -0400 Subject: [feature/event-dispatcher] Delete hard dependency on composer. Applications should not depend on package managers. PHPBB3-9550 --- phpBB/install/database_update.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a1c8fe1ef9..843e8c2f23 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -82,8 +82,6 @@ if (!empty($load_extensions) && function_exists('dl')) } } -require($phpbb_root_path . 'vendor/.composer/autoload.php'); - // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); -- cgit v1.2.1 From 95b5109c622f8acd2d57343b97e3c2b6b157863a Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 25 Jan 2012 14:30:52 +0000 Subject: [feature/save-post-on-report] The complete changes for this feature This covers all the changes so that when a report is made, the post itself is copied and displayed in the MCP instead of the current post. Unfortunatly, I made all commits in the wrong way and they were lost. Now I have only the final files. --- 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 843e8c2f23..0a2c3998c4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1088,6 +1088,9 @@ function database_update_info() PROFILE_FIELDS_TABLE => array( 'field_show_on_pm' => array('BOOL', 0), ), + REPORTS_TABLE => array( + 'reported_post' => array('TEXT', ''), + ), ), 'change_columns' => array( GROUPS_TABLE => array( -- cgit v1.2.1 From 6f5c0dddfcd2a1b56fe1e8cf783f48ecfc8561e9 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 14 Feb 2012 07:58:30 +0000 Subject: [feature/save-post-on-report] Bug fix table name There was a bug in the previous commit. I changed the name of the colon of the table and forgot to update the database_update.php now it's fixed. PHPBB3-10600 --- 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 0a2c3998c4..7240e899a6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1089,7 +1089,7 @@ function database_update_info() 'field_show_on_pm' => array('BOOL', 0), ), REPORTS_TABLE => array( - 'reported_post' => array('TEXT', ''), + 'reported_text' => array('TEXT', ''), ), ), 'change_columns' => array( -- cgit v1.2.1 From 18373035c3299e80b2c075cfc3d475c89af3cc73 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 15 Feb 2012 22:03:32 +0000 Subject: [feature/save-post-on-report] Changed the name of the column The name of the column was changed from reported_post AND reported_text to reported_post_text. This change was made by request PHPBB3-10600 --- 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 7240e899a6..2fdbd16e4a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1089,7 +1089,7 @@ function database_update_info() 'field_show_on_pm' => array('BOOL', 0), ), REPORTS_TABLE => array( - 'reported_text' => array('TEXT', ''), + 'reported_post_text' => array('TEXT', ''), ), ), 'change_columns' => array( -- cgit v1.2.1 From 165a2d1aa879f1fc65448721da5f6d143aff91fe Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 8 Mar 2012 09:16:36 +0000 Subject: [feature/save-post-on-report] Change the column type of reported text What ever it said. I changed the type of data in the column reported_post_text to match what was requested by p PHPBB3-10600 --- 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 2fdbd16e4a..8a7ec1004e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1089,7 +1089,7 @@ function database_update_info() 'field_show_on_pm' => array('BOOL', 0), ), REPORTS_TABLE => array( - 'reported_post_text' => array('TEXT', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), ), ), 'change_columns' => array( -- cgit v1.2.1 From 7f1abaa318cb7008c9eab259003d67790e346094 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 28 Mar 2012 21:45:56 +0200 Subject: [feature/event-dispatcher] Add empty dispatcher to installer and db updater PHPBB3-9550 --- 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 843e8c2f23..c2b36f5992 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -120,6 +120,7 @@ $cache = $cache_factory->get_service(); $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); +$phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new user(); $db = new $sql_db(); -- cgit v1.2.1 From 1be5bd8e1311a9dd859e6e685cdfa5979adf69a4 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 18:38:37 +0300 Subject: [feature/merging-style-components] Fixing typo in database updater Fixing typo in database_update.php PHPBB3-10632 --- 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 18ca4870fb..3235731d28 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2274,7 +2274,7 @@ function change_database_data(&$no_updates, $version) 'cat' => 'ACP_ATTACHMENTS', ), 'install' => array( - 'base' => 'acp_styles' + 'base' => 'acp_styles', 'class' => 'acp', 'title' => 'ACP_STYLES_INSTALL', 'auth' => 'acl_a_styles', -- cgit v1.2.1 From 550ee7309a1d83711e4b9cf4abe3468807d84996 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 18:53:49 +0300 Subject: [feature/merging-style-components] Fixing typos in database updater Yes, I failed... again. Fixing 2 more typos in database_update.php PHPBB3-10632 --- 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 3235731d28..583574a245 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2281,14 +2281,14 @@ function change_database_data(&$no_updates, $version) 'cat' => 'ACP_STYLE_MANAGEMENT', ), 'edit' => array( - 'base' => 'acp_styles' + 'base' => 'acp_styles', 'class' => 'acp', 'title' => 'ACP_STYLES_EDIT', 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), 'cache' => array( - 'base' => 'acp_styles' + 'base' => 'acp_styles', 'class' => 'acp', 'title' => 'ACP_STYLES_CACHE', 'auth' => 'acl_a_styles', -- cgit v1.2.1 From 6deb7b3671c29ab7ce1db6e11b5c6be0950d265f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 02:50:19 +0200 Subject: [feature/class-prefix] Rename user and session to phpbb_* PHPBB-10609 --- phpBB/install/database_update.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 18ca4870fb..fb5e79358d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -84,7 +84,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); @@ -122,7 +121,7 @@ $phpbb_class_loader->set_cache($cache->get_driver()); $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); -$user = new user(); +$user = new phpbb_user(); $db = new $sql_db(); // make sure request_var uses this request instance -- cgit v1.2.1 From 9236dd4c471a6f7655bd00ae422a13013a400ac4 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 02:54:39 +0200 Subject: [feature/class-prefix] Rename auth => phpbb_auth PHPBB3-10609 --- phpBB/install/database_update.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fb5e79358d..96d984c04c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -84,7 +84,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/auth.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); -- cgit v1.2.1 From f32547c2150a3e6201edf0f856a93229040c73be Mon Sep 17 00:00:00 2001 From: Rahul Date: Sat, 24 Mar 2012 12:57:28 +0530 Subject: [ticket/10650] Displaying last topic on forum list The most recent topic title of the forum can now be displayed on the board index. An option is provided in the ACP under the 'General Forum Setting' which allows the admin to enable or disable this feature. PHPBB3-10650 --- 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 a84136388c..509e991c81 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1084,6 +1084,9 @@ function database_update_info() GROUPS_TABLE => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), ), + FORUMS_TABLE => array( + 'display_last_subject' => array('BOOL', 1), + ), PROFILE_FIELDS_TABLE => array( 'field_show_on_pm' => array('BOOL', 0), ), -- cgit v1.2.1 From 98964a913cb22761553d04170aa4830e324f7488 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 4 Apr 2012 18:28:36 -0400 Subject: [ticket/10650] Revert merge of 'rahulr92/ticket/10650' into develop The pull request (#654) was merged a little too quickly. In particular, display_last_subject per-forum option needs consensus. This reverts commit b1fb34a4d7e446768b9f66ba6dd359173cd2a5fb, reversing changes made to 7d6b289671c51694f17dd5f9849abf2534b55e59. PHPBB3-10650 --- 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 509e991c81..a84136388c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1084,9 +1084,6 @@ function database_update_info() GROUPS_TABLE => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), ), - FORUMS_TABLE => array( - 'display_last_subject' => array('BOOL', 1), - ), PROFILE_FIELDS_TABLE => array( 'field_show_on_pm' => array('BOOL', 0), ), -- cgit v1.2.1 From 9b30bd639201ffbbf1d1b3ae32fda7e75d3253dd Mon Sep 17 00:00:00 2001 From: Rahul Date: Sat, 24 Mar 2012 12:57:28 +0530 Subject: [ticket/10650] Displaying last topic on forum list The most recent topic title of the forum can now be displayed on the board index. An option is provided in the ACP under the 'General Forum Setting' which allows the admin to enable or disable this feature. PHPBB3-10650 --- 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 a84136388c..509e991c81 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1084,6 +1084,9 @@ function database_update_info() GROUPS_TABLE => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), ), + FORUMS_TABLE => array( + 'display_last_subject' => array('BOOL', 1), + ), PROFILE_FIELDS_TABLE => array( 'field_show_on_pm' => array('BOOL', 0), ), -- cgit v1.2.1 From c524236ef6d84f6ef78f684aeb7bb469ca844db4 Mon Sep 17 00:00:00 2001 From: Rahul R Date: Fri, 6 Apr 2012 01:07:23 +0530 Subject: [ticket/10650] Changed acp option from per forum to global Changed the display last subject acp toggle option from per forum to global. Modified associated database entries. New option is available in ACP General->Board Features. Also corrected
in forumlist_body.html. PHPBB3-10650 --- phpBB/install/database_update.php | 10 +++++++--- 1 file changed, 7 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 509e991c81..89b252e3fa 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1084,9 +1084,6 @@ function database_update_info() GROUPS_TABLE => array( 'group_teampage' => array('UINT', 0, 'after' => 'group_legend'), ), - FORUMS_TABLE => array( - 'display_last_subject' => array('BOOL', 1), - ), PROFILE_FIELDS_TABLE => array( 'field_show_on_pm' => array('BOOL', 0), ), @@ -2397,8 +2394,15 @@ function change_database_data(&$no_updates, $version) $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; _sql($sql, $errored, $error_ary); + //Create config value for displaying last subject on forum list + if(!isset($config['display_last_subject'])) + { + $config->set("display_last_subject", '1'); + } + $no_updates = false; break; } } + -- cgit v1.2.1 From b6957aa5252544fe0b52af94e35bc93b47e3518e Mon Sep 17 00:00:00 2001 From: Rahul R Date: Fri, 6 Apr 2012 01:15:12 +0530 Subject: [ticket/10650]Removed incorrect newline Deleted additional line in the end of database_update.php PHPBB3-10650 --- phpBB/install/database_update.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 89b252e3fa..4f5fe142c9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2405,4 +2405,3 @@ function change_database_data(&$no_updates, $version) break; } } - -- cgit v1.2.1 From 303748b02db2aa76391f60770c292edf45cee360 Mon Sep 17 00:00:00 2001 From: Rahul R Date: Mon, 9 Apr 2012 01:43:44 +0530 Subject: [ticket/10650] Added space after if and comment Added space in proper places in database_update.php. Also corrected language entry of ELLIPSIS to utf8 PHPBB3-10650 --- 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 4f5fe142c9..5c70a07f1e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2394,10 +2394,10 @@ function change_database_data(&$no_updates, $version) $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; _sql($sql, $errored, $error_ary); - //Create config value for displaying last subject on forum list - if(!isset($config['display_last_subject'])) + // Create config value for displaying last subject on forum list + if (!isset($config['display_last_subject'])) { - $config->set("display_last_subject", '1'); + $config->set('display_last_subject', '1'); } $no_updates = false; -- cgit v1.2.1 From 5665e82616fd12fbec36e7a1d42713a75ed85e22 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 11 Apr 2012 14:28:12 +0100 Subject: [ticket/10783] Added ?assets_version to assets. PHPBB3-10783 --- 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 be39b12d12..5368ec06bb 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -189,6 +189,12 @@ $config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); set_config(null, null, null, $config); set_config_count(null, null, null, $config); +// Update asset_version +if (isset($config['assets_version'])) +{ + set_config('assets_version', $config['assets_version'] + 1); +} + // phpbb_db_tools will be taken from new files (under install/update/new) // if possible, falling back to the board's copy. $db_tools = new phpbb_db_tools($db, true); @@ -2424,6 +2430,11 @@ function change_database_data(&$no_updates, $version) $no_updates = false; + if (!isset($config['assets_version'])) + { + $config->set('assets_version', '1'); + } + break; } } -- cgit v1.2.1 From b3e42635ca201eea2fa82fb057f021768daf6786 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Tue, 10 Apr 2012 22:41:59 +0300 Subject: [ticket/10759] Fixing style in database updater Fixing error in database updater caused by style components merge PHPBB3-10759 --- phpBB/install/database_update.php | 155 +++++++++++++++++++++++++++++++------- 1 file changed, 127 insertions(+), 28 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 5368ec06bb..0b33168496 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1110,20 +1110,6 @@ function database_update_info() 'group_legend' => array('UINT', 0), ), ), - 'drop_columns' => array( - STYLES_TABLE => array( - 'imageset_id', - 'template_id', - 'theme_id', - ), - ), - 'drop_tables' => array( - STYLES_IMAGESET_TABLE, - STYLES_IMAGESET_DATA_TABLE, - STYLES_TEMPLATE_TABLE, - STYLES_TEMPLATE_DATA_TABLE, - STYLES_THEME_TABLE, - ), ), ); } @@ -1135,7 +1121,7 @@ function database_update_info() *****************************************************************************/ function change_database_data(&$no_updates, $version) { - global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx; + global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx, $db_tools; switch ($version) { @@ -2312,13 +2298,6 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), - 'edit' => array( - 'base' => 'acp_styles', - 'class' => 'acp', - 'title' => 'ACP_STYLES_EDIT', - 'auth' => 'acl_a_styles', - 'cat' => 'ACP_STYLE_MANAGEMENT', - ), 'cache' => array( 'base' => 'acp_styles', 'class' => 'acp', @@ -2421,13 +2400,133 @@ function change_database_data(&$no_updates, $version) { set_config('teampage_memberships', '1'); } - - // Clear styles table and add prosilver entry - _sql('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); - $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; - _sql($sql, $errored, $error_ary); - + // Check if styles table was already updated + if ($db_tools->sql_table_exists(STYLES_THEME_TABLE)) + { + // Get list of valid installed styles + $available_styles = array('prosilver'); + + $iterator = new DirectoryIterator($phpbb_root_path . 'styles'); + $skip_dirs = array('.', '..', 'prosilver'); + foreach ($iterator as $fileinfo) + { + if ($fileinfo->isDir() && !in_array($fileinfo->getFilename(), $skip_dirs) && file_exists($fileinfo->getPathname() . '/style.cfg')) + { + $style_cfg = parse_cfg_file($fileinfo->getPathname() . '/style.cfg'); + if (isset($style_cfg['phpbb_version']) && version_compare($style_cfg['phpbb_version'], '3.1.0-dev', '>=')) + { + // 3.1 style + $available_styles[] = $fileinfo->getFilename(); + } + } + } + + // Get all installed styles + if ($db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path, i.imageset_id + FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id + AND i.imageset_id = s.imageset_id"; + } + else + { + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id + FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . " c + WHERE t.template_id = s.template_id + AND c.theme_id = s.theme_id"; + } + $result = $db->sql_query($sql); + + $styles = array(); + while ($row = $db->sql_fetchrow($result)) + { + $styles[] = $row; + } + $db->sql_freeresult($result); + + // Check each style + $valid_styles = array(); + foreach ($styles as $style_row) + { + if ( + // Ignore styles with parent style + $style_row['template_inherits_id'] == 0 && + // Check if components match + $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && + // Check if components are valid + in_array($style_row['template_path'], $available_styles) + ) + { + // Valid style. Keep it + $sql_ary = array( + 'style_path' => $style_row['template_path'], + 'bbcode_bitfield' => $style_row['bbcode_bitfield'], + 'style_parent_id' => 0, + 'style_parent_tree' => '', + ); + _sql('UPDATE ' . STYLES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE style_id = ' . $style_row['style_id'], $errored, $error_ary); + $valid_styles[] = $style_row['style_id']; + } + } + + // Remove old styles tables + $changes = array( + 'drop_columns' => array( + STYLES_TABLE => array( + 'imageset_id', + 'template_id', + 'theme_id', + ), + ), + + 'drop_tables' => array( + STYLES_IMAGESET_TABLE, + STYLES_IMAGESET_DATA_TABLE, + STYLES_TEMPLATE_TABLE, + STYLES_TEMPLATE_DATA_TABLE, + STYLES_THEME_TABLE, + ) + ); + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + + // Remove old entries from styles table + if (!sizeof($valid_styles)) + { + // No valid styles: remove everything and add prosilver + _sql('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); + + $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_id, style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES (1, 'prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; + _sql($sql, $errored, $error_ary); + + set_config('default_style', '1'); + + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; + _sql($sql, $errored, $error_ary); + } + else + { + // There are valid styles in styles table. Remove styles that are outdated + _sql('DELETE FROM ' . STYLES_TABLE . ' WHERE ' . $db->sql_in_set('style_id', $valid_styles, true), $errored, $error_ary); + + // Change default style + if (!in_array($config['default_style'], $valid_styles)) + { + set_config('default_style', $valid_styles[0]); + } + + // Reset styles for users + _sql('UPDATE ' . USERS_TABLE . ' SET user_style = 0 WHERE ' . $db->sql_in_set('user_style', $valid_styles, true), $errored, $error_ary); + } + } + $no_updates = false; if (!isset($config['assets_version'])) -- cgit v1.2.1 From ea8f83de6f87af8fc9413e1be557953cabe8811e Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 19 Apr 2012 03:06:40 +0200 Subject: [ticket/10759] Fix whitespace in database_update.php PHPBB3-10759 --- phpBB/install/database_update.php | 8 ++++---- 1 file changed, 4 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 0b33168496..cddc1c4164 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2310,7 +2310,7 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); $sql = 'DELETE FROM ' . MODULES_TABLE . " - WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; + WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); // Localise Global Announcements @@ -2474,15 +2474,15 @@ function change_database_data(&$no_updates, $version) // Remove old styles tables $changes = array( - 'drop_columns' => array( - STYLES_TABLE => array( + 'drop_columns' => array( + STYLES_TABLE => array( 'imageset_id', 'template_id', 'theme_id', ), ), - 'drop_tables' => array( + 'drop_tables' => array( STYLES_IMAGESET_TABLE, STYLES_IMAGESET_DATA_TABLE, STYLES_TEMPLATE_TABLE, -- cgit v1.2.1 From c43373068636a4f361423f2fe41231ac2e32f70f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 19 Apr 2012 03:18:20 +0200 Subject: [ticket/10759] Retrieve style_id after INSERT since we cannot set it PHPBB3-10759 --- phpBB/install/database_update.php | 11 +++++++++-- 1 file changed, 9 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 cddc1c4164..d71226a29c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2503,10 +2503,17 @@ function change_database_data(&$no_updates, $version) // No valid styles: remove everything and add prosilver _sql('DELETE FROM ' . STYLES_TABLE, $errored, $error_ary); - $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_id, style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES (1, 'prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; + $sql = 'INSERT INTO ' . STYLES_TABLE . " (style_name, style_copyright, style_active, style_path, bbcode_bitfield, style_parent_id, style_parent_tree) VALUES ('prosilver', '© phpBB Group', 1, 'prosilver', 'kNg=', 0, '')"; _sql($sql, $errored, $error_ary); - set_config('default_style', '1'); + $sql = 'SELECT style_id + FROM ' . $table . " + WHERE style_name = 'prosilver'"; + $result = _sql($sql, $errored, $error_ary); + $default_style = $db->sql_fetchfield($result); + $db->sql_freeresult($result); + + set_config('default_style', $default_style); $sql = 'UPDATE ' . USERS_TABLE . ' SET user_style = 0'; _sql($sql, $errored, $error_ary); -- cgit v1.2.1 From 0b7a0fa2d11c4f30d31e36f2c11c574491432d4a Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 19 Apr 2012 03:27:42 +0200 Subject: [ticket/10759] Clarify comments a bit PHPBB3-10759 --- 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 d71226a29c..c30508dcee 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2404,7 +2404,7 @@ function change_database_data(&$no_updates, $version) // Check if styles table was already updated if ($db_tools->sql_table_exists(STYLES_THEME_TABLE)) { - // Get list of valid installed styles + // Get list of valid 3.1 styles $available_styles = array('prosilver'); $iterator = new DirectoryIterator($phpbb_root_path . 'styles'); @@ -2447,12 +2447,12 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); - // Check each style + // Decide which styles to keep, all others will be deleted $valid_styles = array(); foreach ($styles as $style_row) { if ( - // Ignore styles with parent style + // Delete styles with parent style (not supported yet) $style_row['template_inherits_id'] == 0 && // Check if components match $style_row['template_path'] == $style_row['theme_path'] && (!isset($style_row['imageset_path']) || $style_row['template_path'] == $style_row['imageset_path']) && -- cgit v1.2.1 From 18704215216cf31e8d96058d2df7ef7cf20a3f7b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 19 Apr 2012 03:38:01 +0200 Subject: [ticket/10759] Don't select imageset_id, it's not needed PHPBB3-10759 --- 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 c30508dcee..88ebb8209e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2425,7 +2425,7 @@ function change_database_data(&$no_updates, $version) // Get all installed styles if ($db_tools->sql_table_exists(STYLES_IMAGESET_TABLE)) { - $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path, i.imageset_id + $sql = 'SELECT s.style_id, t.template_path, t.template_id, t.bbcode_bitfield, t.template_inherits_id, t.template_inherit_path, c.theme_path, c.theme_id, i.imageset_path FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i WHERE t.template_id = s.template_id AND c.theme_id = s.theme_id -- cgit v1.2.1 From 439ade4ee2f2fcd301ad3690624a821a779c95ee Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 19 Apr 2012 03:51:17 +0200 Subject: [ticket/10759] Make sure style ids are integers PHPBB3-10759 --- 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 88ebb8209e..a0892005d2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2468,7 +2468,7 @@ function change_database_data(&$no_updates, $version) 'style_parent_tree' => '', ); _sql('UPDATE ' . STYLES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE style_id = ' . $style_row['style_id'], $errored, $error_ary); - $valid_styles[] = $style_row['style_id']; + $valid_styles[] = (int) $style_row['style_id']; } } -- cgit v1.2.1 From ed67dcf3d83d40623471fe191fdc415289c59c21 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 2 May 2012 21:12:18 +0200 Subject: [ticket/10818] Global Announcements Update Dialog should call exit_handler() PHPBB3-10818 --- 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 a0892005d2..665db1f2f0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -260,7 +260,7 @@ if ($has_global && !$ga_forum_id) Date: Sun, 6 May 2012 15:28:55 +0100 Subject: [ticket/10845] Two of the three colouns were missing in the DB update file Added the two colouns that were missing in the DB update file PHPBB3-10845 --- 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 a0892005d2..3c4a7f7027 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1102,7 +1102,9 @@ function database_update_info() 'style_parent_tree' => array('TEXT', ''), ), REPORTS_TABLE => array( - 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), ), ), 'change_columns' => array( -- cgit v1.2.1 From a9549cbe6ab66732fcf9c321496b74943e2972e7 Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Sun, 3 Jun 2012 15:56:55 +0530 Subject: [feature-delete-auto-logins] adds module to database update ucp delete auto-login keys module is added to database_update.php under 3.1-dev --- 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 665db1f2f0..a5bd5e7bfe 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2305,6 +2305,13 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), + 'autologin_keys' => array( + 'base' => 'ucp_profile', + 'class' => 'ucp', + 'title' => 'UCP_PROFILE_AUTOLOGIN_KEYS', + 'auth' => '', + 'cat' => 'UCP_PROFILE', + ), ); _add_modules($modules_to_install); -- cgit v1.2.1 From 3c6272ff0475dc19cc67553f370ce227214d0613 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 4 Jun 2012 23:28:48 +0200 Subject: [feature/new-tz-handling] Remove appearances of board_dst and user_dst PHPBB3-9558 --- 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 9758ad3b2b..b6f7f82785 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1971,7 +1971,7 @@ function change_database_data(&$no_updates, $version) 'user_email' => '', 'user_lang' => $config['default_lang'], 'user_style' => $config['default_style'], - 'user_timezone' => 0, + 'user_timezone' => 'UTC', 'user_dateformat' => $config['default_dateformat'], 'user_allow_massemail' => 0, ); -- cgit v1.2.1 From 902a79bfdabb2c459f2385cff80b5fa38099d2f7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 00:50:33 +0200 Subject: [feature/new-tz-handling] Readd Database updater changes from Oleg The change here converts user_timezone to vchar and computes timezone identifiers from the offsets. It uses database-specific functions for building SQL conditionals and concatenations which need to be implemented, probably in a separate ticket. As a result the current code is not functional. The changes are tricky since we need to drop user_dst column from users table, but we need it during the data migration process to properly calculate effective timezones for all users. PHPBB3-9558 --- 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 b6f7f82785..dd2d04d3a6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2588,6 +2588,33 @@ function change_database_data(&$no_updates, $version) $config->set('assets_version', '1'); } + // If the column exists, we did not yet update the users timezone + if ($db_tools->sql_column_exists(USERS_TABLE, 'user_dst')) + { + // Update timezones + // user_dst is 0 if not in dst and 1 if in dst; + // this happens to be exactly the correction that should be added to the timezone offset + // to obtain dst offset. + // Parenthesize here because we operate on this value later. + $active_offset = '(user_timezone + user_dst)'; + + // Now we have a tricky problem of forcing the plus sign into the expression. + // Build it via a conditional since there cannot be a portable printf equivalent in databases. + // Note that active offset is not an absolute value here - it is an expression that will + // be evaluated by the database during query execution. + // We don't print - (minus) here because it will come from active offset. + $sign = $db->sql_conditional("$active_offset < 0", '', '+'); + + // Use database-specific escaping because strings are quoted differently by different databases. + $new_value = $db->sql_concatenate($db->sql_escape('GMT'), $sign, $active_offset); + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_timezone = ' . $new_value; + _sql($sql, $errored, $error_ary); + + // After we have calculated the timezones we can delete user_dst column from user table. + $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); + } + break; } } -- cgit v1.2.1 From 8a659964e4788144fde24c4f43362ab2450582f8 Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Thu, 7 Jun 2012 01:11:12 +0530 Subject: [feature/postgresql-fulltext-search] database changes in database_update config entries are now added by database_update.php as well. PostgreSQL will work during update too. PHPBB3-9730 --- 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 665db1f2f0..3716c03030 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2207,6 +2207,13 @@ function change_database_data(&$no_updates, $version) set_config('search_type', 'phpbb_search_' . $config['search_type']); } + if (!isset($config['fulltext_postgres_ts_name'])) + { + set_config('fulltext_postgres_max_word_len', 254); + set_config('fulltext_postgres_min_word_len', 4); + set_config('fulltext_postgres_ts_name', 'simple'); + } + if (!isset($config['load_jquery_cdn'])) { set_config('load_jquery_cdn', 0); -- cgit v1.2.1 From d37c9cab6bc8444685c642b4a6bce6108f054acc Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Tue, 26 Jun 2012 01:36:34 +0530 Subject: [feature/postgresql-fulltext-search] each config is checked if it is set In database_update.php each config value of postgres fulltext search is first checked whether it already exists or not and then added. PHPBB3-9730 --- phpBB/install/database_update.php | 12 ++++++++++-- 1 file changed, 10 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 3716c03030..a6e5921b63 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2209,11 +2209,19 @@ function change_database_data(&$no_updates, $version) if (!isset($config['fulltext_postgres_ts_name'])) { - set_config('fulltext_postgres_max_word_len', 254); - set_config('fulltext_postgres_min_word_len', 4); set_config('fulltext_postgres_ts_name', 'simple'); } + if (!isset($config['fulltext_postgres_min_word_len'])) + { + set_config('fulltext_postgres_min_word_len', 4); + } + + if (!isset($config['fulltext_postgres_max_word_len'])) + { + set_config('fulltext_postgres_max_word_len', 254); + } + if (!isset($config['load_jquery_cdn'])) { set_config('load_jquery_cdn', 0); -- cgit v1.2.1 From 7ce66deca8dbe8187b86e130e8011be998580b4e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 18 Jul 2012 14:48:28 +0200 Subject: [feature/new-tz-handling] Correctly update user and board timezones on update PHPBB3-9558 --- phpBB/install/database_update.php | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 360e12e0b6..a3a51324a9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2613,25 +2613,24 @@ function change_database_data(&$no_updates, $version) // If the column exists, we did not yet update the users timezone if ($db_tools->sql_column_exists(USERS_TABLE, 'user_dst')) { - // Update timezones - // user_dst is 0 if not in dst and 1 if in dst; - // this happens to be exactly the correction that should be added to the timezone offset - // to obtain dst offset. - // Parenthesize here because we operate on this value later. - $active_offset = '(user_timezone + user_dst)'; - - // Now we have a tricky problem of forcing the plus sign into the expression. - // Build it via a conditional since there cannot be a portable printf equivalent in databases. - // Note that active offset is not an absolute value here - it is an expression that will - // be evaluated by the database during query execution. - // We don't print - (minus) here because it will come from active offset. - $sign = $db->sql_conditional("$active_offset < 0", '', '+'); - - // Use database-specific escaping because strings are quoted differently by different databases. - $new_value = $db->sql_concatenate($db->sql_escape('GMT'), $sign, $active_offset); - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_timezone = ' . $new_value; - _sql($sql, $errored, $error_ary); + // Update user timezones + $sql = 'SELECT user_dst, user_timezone + FROM ' . USERS_TABLE . ' + GROUP BY user_timezone, user_dst'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_timezone = '" . $db->sql_escape(_convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' + WHERE user_timezone = '" . $db->sql_escape($row['user_timezone']) . "' + AND user_dst = " . (int) $row['user_dst']; + _sql($sql, $errored, $error_ary); + } + $db->sql_freeresult($result); + + // Update board default timezone + set_config('board_timezone', _convert_phpbb30_timezone($config['board_timezone'], $config['board_dst'])); // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); -- cgit v1.2.1 From 8078a04f3a3816b4515da01eb3635ae8141db26b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 18 Jul 2012 14:52:51 +0200 Subject: [feature/new-tz-handling] Add function to update the timezone PHPBB3-9558 --- phpBB/install/database_update.php | 99 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a3a51324a9..43363babe1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -809,6 +809,105 @@ function _add_modules($modules_to_install) $_module->remove_cache_file(); } +/** +* Determinate the new timezone for a given phpBB 3.0 timezone and +* "Daylight Saving Time" option +* +* @param $timezone float Users timezone in 3.0 +* @param $dst int Users daylight saving time +* @return string Users new php Timezone which is used since 3.1 +*/ +function _convert_phpbb30_timezone($timezone, $dst) +{ + $offset = $timezone + $dst; + + switch ($timezone) + { + case '-12': + return 'Etc/GMT' . $offset; //'[UTC - 12] Baker Island Time' + case '-11': + return 'Etc/GMT' . $offset; //'[UTC - 11] Niue Time, Samoa Standard Time' + case '-10': + return 'Etc/GMT' . $offset; //'[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time' + case '-9.5': + return 'Pacific/Marquesas'; //'[UTC - 9:30] Marquesas Islands Time' + case '-9': + return 'Etc/GMT' . $offset; //'[UTC - 9] Alaska Standard Time, Gambier Island Time' + case '-8': + return 'Etc/GMT' . $offset; //'[UTC - 8] Pacific Standard Time' + case '-7': + return 'Etc/GMT' . $offset; //'[UTC - 7] Mountain Standard Time' + case '-6': + return 'Etc/GMT' . $offset; //'[UTC - 6] Central Standard Time' + case '-5': + return 'Etc/GMT' . $offset; //'[UTC - 5] Eastern Standard Time' + case '-4.5': + return 'America/Caracas'; //'[UTC - 4:30] Venezuelan Standard Time' + case '-4': + return 'Etc/GMT' . $offset; //'[UTC - 4] Atlantic Standard Time' + case '-3.5': + return 'America/St_Johns'; //'[UTC - 3:30] Newfoundland Standard Time' + case '-3': + return 'Etc/GMT' . $offset; //'[UTC - 3] Amazon Standard Time, Central Greenland Time' + case '-2': + return 'Etc/GMT' . $offset; //'[UTC - 2] Fernando de Noronha Time, South Georgia & the South Sandwich Islands Time' + case '-1': + return 'Etc/GMT' . $offset; //'[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time' + case '0': + return (!$dst) ? 'UTC' : 'Etc/GMT+1'; //'[UTC] Western European Time, Greenwich Mean Time' + case '1': + return 'Etc/GMT+' . $offset; //'[UTC + 1] Central European Time, West African Time' + case '2': + return 'Etc/GMT+' . $offset; //'[UTC + 2] Eastern European Time, Central African Time' + case '3': + return 'Etc/GMT+' . $offset; //'[UTC + 3] Moscow Standard Time, Eastern African Time' + case '3.5': + return 'Asia/Tehran'; //'[UTC + 3:30] Iran Standard Time' + case '4': + return 'Etc/GMT+' . $offset; //'[UTC + 4] Gulf Standard Time, Samara Standard Time' + case '4.5': + return 'Asia/Kabul'; //'[UTC + 4:30] Afghanistan Time' + case '5': + return 'Etc/GMT+' . $offset; //'[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time' + case '5.5': + return 'Asia/Kolkata'; //'[UTC + 5:30] Indian Standard Time, Sri Lanka Time' + case '5.75': + return 'Asia/Kathmandu'; //'[UTC + 5:45] Nepal Time' + case '6': + return 'Etc/GMT+' . $offset; //'[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time' + case '6.5': + return 'Indian/Cocos'; //'[UTC + 6:30] Cocos Islands Time, Myanmar Time' + case '7': + return 'Etc/GMT+' . $offset; //'[UTC + 7] Indochina Time, Krasnoyarsk Standard Time' + case '8': + return 'Etc/GMT+' . $offset; //'[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time' + case '8.75': + return 'Australia/Eucla'; //'[UTC + 8:45] Southeastern Western Australia Standard Time' + case '9': + return 'Etc/GMT+' . $offset; //'[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time' + case '9.5': + return 'Australia/ACT'; //'[UTC + 9:30] Australian Central Standard Time' + case '10': + return 'Etc/GMT+' . $offset; //'[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time' + case '10.5': + return 'Australia/Lord_Howe'; //'[UTC + 10:30] Lord Howe Standard Time' + case '11': + return 'Etc/GMT+' . $offset; //'[UTC + 11] Solomon Island Time, Magadan Standard Time' + case '11.5': + return 'Pacific/Norfolk'; //'[UTC + 11:30] Norfolk Island Time' + case '12': + return 'Etc/GMT+12'; //'[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time' + case '12.75': + return 'Pacific/Chatham'; //'[UTC + 12:45] Chatham Islands Time' + case '13': + return 'Pacific/Tongatapu'; //'[UTC + 13] Tonga Time, Phoenix Islands Time' + case '14': + return 'Pacific/Kiritimati'; //'[UTC + 14] Line Island Time' + default: + return 'UTC'; + } +} + /**************************************************************************** * ADD YOUR DATABASE SCHEMA CHANGES HERE * *****************************************************************************/ -- cgit v1.2.1 From 14a07b11936bc061b5c82daa6387eb4645974fac Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 18 Jul 2012 17:18:10 +0200 Subject: [feature/new-tz-handling] Move update helper function to new class PHPBB3-9558 --- phpBB/install/database_update.php | 105 ++------------------------------------ 1 file changed, 4 insertions(+), 101 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 43363babe1..6e99fd56a0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -809,105 +809,6 @@ function _add_modules($modules_to_install) $_module->remove_cache_file(); } -/** -* Determinate the new timezone for a given phpBB 3.0 timezone and -* "Daylight Saving Time" option -* -* @param $timezone float Users timezone in 3.0 -* @param $dst int Users daylight saving time -* @return string Users new php Timezone which is used since 3.1 -*/ -function _convert_phpbb30_timezone($timezone, $dst) -{ - $offset = $timezone + $dst; - - switch ($timezone) - { - case '-12': - return 'Etc/GMT' . $offset; //'[UTC - 12] Baker Island Time' - case '-11': - return 'Etc/GMT' . $offset; //'[UTC - 11] Niue Time, Samoa Standard Time' - case '-10': - return 'Etc/GMT' . $offset; //'[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time' - case '-9.5': - return 'Pacific/Marquesas'; //'[UTC - 9:30] Marquesas Islands Time' - case '-9': - return 'Etc/GMT' . $offset; //'[UTC - 9] Alaska Standard Time, Gambier Island Time' - case '-8': - return 'Etc/GMT' . $offset; //'[UTC - 8] Pacific Standard Time' - case '-7': - return 'Etc/GMT' . $offset; //'[UTC - 7] Mountain Standard Time' - case '-6': - return 'Etc/GMT' . $offset; //'[UTC - 6] Central Standard Time' - case '-5': - return 'Etc/GMT' . $offset; //'[UTC - 5] Eastern Standard Time' - case '-4.5': - return 'America/Caracas'; //'[UTC - 4:30] Venezuelan Standard Time' - case '-4': - return 'Etc/GMT' . $offset; //'[UTC - 4] Atlantic Standard Time' - case '-3.5': - return 'America/St_Johns'; //'[UTC - 3:30] Newfoundland Standard Time' - case '-3': - return 'Etc/GMT' . $offset; //'[UTC - 3] Amazon Standard Time, Central Greenland Time' - case '-2': - return 'Etc/GMT' . $offset; //'[UTC - 2] Fernando de Noronha Time, South Georgia & the South Sandwich Islands Time' - case '-1': - return 'Etc/GMT' . $offset; //'[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time' - case '0': - return (!$dst) ? 'UTC' : 'Etc/GMT+1'; //'[UTC] Western European Time, Greenwich Mean Time' - case '1': - return 'Etc/GMT+' . $offset; //'[UTC + 1] Central European Time, West African Time' - case '2': - return 'Etc/GMT+' . $offset; //'[UTC + 2] Eastern European Time, Central African Time' - case '3': - return 'Etc/GMT+' . $offset; //'[UTC + 3] Moscow Standard Time, Eastern African Time' - case '3.5': - return 'Asia/Tehran'; //'[UTC + 3:30] Iran Standard Time' - case '4': - return 'Etc/GMT+' . $offset; //'[UTC + 4] Gulf Standard Time, Samara Standard Time' - case '4.5': - return 'Asia/Kabul'; //'[UTC + 4:30] Afghanistan Time' - case '5': - return 'Etc/GMT+' . $offset; //'[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time' - case '5.5': - return 'Asia/Kolkata'; //'[UTC + 5:30] Indian Standard Time, Sri Lanka Time' - case '5.75': - return 'Asia/Kathmandu'; //'[UTC + 5:45] Nepal Time' - case '6': - return 'Etc/GMT+' . $offset; //'[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time' - case '6.5': - return 'Indian/Cocos'; //'[UTC + 6:30] Cocos Islands Time, Myanmar Time' - case '7': - return 'Etc/GMT+' . $offset; //'[UTC + 7] Indochina Time, Krasnoyarsk Standard Time' - case '8': - return 'Etc/GMT+' . $offset; //'[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time' - case '8.75': - return 'Australia/Eucla'; //'[UTC + 8:45] Southeastern Western Australia Standard Time' - case '9': - return 'Etc/GMT+' . $offset; //'[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time' - case '9.5': - return 'Australia/ACT'; //'[UTC + 9:30] Australian Central Standard Time' - case '10': - return 'Etc/GMT+' . $offset; //'[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time' - case '10.5': - return 'Australia/Lord_Howe'; //'[UTC + 10:30] Lord Howe Standard Time' - case '11': - return 'Etc/GMT+' . $offset; //'[UTC + 11] Solomon Island Time, Magadan Standard Time' - case '11.5': - return 'Pacific/Norfolk'; //'[UTC + 11:30] Norfolk Island Time' - case '12': - return 'Etc/GMT+12'; //'[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time' - case '12.75': - return 'Pacific/Chatham'; //'[UTC + 12:45] Chatham Islands Time' - case '13': - return 'Pacific/Tongatapu'; //'[UTC + 13] Tonga Time, Phoenix Islands Time' - case '14': - return 'Pacific/Kiritimati'; //'[UTC + 14] Line Island Time' - default: - return 'UTC'; - } -} - /**************************************************************************** * ADD YOUR DATABASE SCHEMA CHANGES HERE * *****************************************************************************/ @@ -1225,6 +1126,8 @@ function change_database_data(&$no_updates, $version) { global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx, $db_tools; + $update_helpers = new phpbb_update_helpers(); + switch ($version) { case '3.0.0': @@ -2721,7 +2624,7 @@ function change_database_data(&$no_updates, $version) while ($row = $db->sql_fetchrow($result)) { $sql = 'UPDATE ' . USERS_TABLE . " - SET user_timezone = '" . $db->sql_escape(_convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' + SET user_timezone = '" . $db->sql_escape($update_helpers->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "' WHERE user_timezone = '" . $db->sql_escape($row['user_timezone']) . "' AND user_dst = " . (int) $row['user_dst']; _sql($sql, $errored, $error_ary); @@ -2729,7 +2632,7 @@ function change_database_data(&$no_updates, $version) $db->sql_freeresult($result); // Update board default timezone - set_config('board_timezone', _convert_phpbb30_timezone($config['board_timezone'], $config['board_dst'])); + set_config('board_timezone', $update_helpers->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst'])); // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); -- cgit v1.2.1 From 9711da2763f707408efde160357d51330fd17681 Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Tue, 10 Jul 2012 05:04:14 +0530 Subject: [feature/sphinx-fulltext-search] adds default config values Default config values are added to config table in new install as well as database_update. PHPBB3-10946 --- 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 594397c815..0ffab8e413 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2260,6 +2260,16 @@ function change_database_data(&$no_updates, $version) set_config('fulltext_postgres_max_word_len', 254); } + if (!isset($config['fulltext_sphinx_stopwords'])) + { + set_config('fulltext_sphinx_stopwords', 0); + } + + if (!isset($config['fulltext_sphinx_indexer_mem_limit'])) + { + set_config('fulltext_sphinx_indexer_mem_limit', 512); + } + if (!isset($config['load_jquery_cdn'])) { set_config('load_jquery_cdn', 0); -- cgit v1.2.1 From 90a957ad26f52e26c3979464c5ac15b1fd0fcc28 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 17:43:43 +0200 Subject: [ticket/11015] Make DBAL classes autoloadable PHPBB3-11015 This allows us to just create the object without having to include the driver first. However, it also means that users must specify the full class name in config.php --- 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 6e99fd56a0..63a949762b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -91,7 +91,6 @@ phpbb_require_updated('includes/functions_content.' . $phpEx, true); require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); phpbb_require_updated('includes/db/db_tools.' . $phpEx); @@ -121,7 +120,7 @@ $phpbb_class_loader->set_cache($cache->get_driver()); $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new phpbb_user(); -$db = new $sql_db(); +$db = new $dbms(); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function @@ -2601,10 +2600,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) -- cgit v1.2.1 From a5dd64195a3a88db3fec38ac74dfb5d118ab5622 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 22 Jul 2012 22:26:38 -0500 Subject: [ticket/11021] Add the option to specify a Site home URL and text PHPBB3-11021 --- 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 6e99fd56a0..18efee72b5 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2637,6 +2637,12 @@ function change_database_data(&$no_updates, $version) // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } + + if (!isset($config['site_home_url'])) + { + $config->set('site_home_url', ''); + $config->set('site_home_text', ''); + } break; } -- cgit v1.2.1 From 8bbab088dd5830d8dd1151a3684dde5c197ba268 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 23 Jul 2012 15:17:42 -0500 Subject: [ticket/10631] Validation for extensions PHPBB3-10631 --- 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 502b3bb1a4..0b470ced26 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -683,12 +683,12 @@ function _write_result($no_updates, $errored, $error_ary) function _add_modules($modules_to_install) { - global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager; + global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config; // modules require an extension manager if (empty($phpbb_extension_manager)) { - $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx"); + $phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx"); } include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); -- cgit v1.2.1 From 503989979a2e6a7fb9d64ed249b09a0bef2b2f95 Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 13 Sep 2012 16:44:26 -0400 Subject: [ticket/11086] Fix database_update.php to use Dependency Injection Container PHPBB3-11086 --- phpBB/install/database_update.php | 47 ++++++++++++++++++++++++++++----------- 1 file changed, 34 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 0b470ced26..323ba0c876 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -7,6 +7,10 @@ * */ +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + define('UPDATES_TO_VERSION', '3.1.0-dev'); // Enter any version to update from to test updates. The version within the db will not be updated. @@ -107,21 +111,38 @@ if (!defined('EXT_TABLE')) define('EXT_TABLE', $table_prefix . 'ext'); } -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); -$phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); -$phpbb_class_loader->register(); +$phpbb_container = new ContainerBuilder(); +$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); +$loader->load('services.yml'); + +// We must include the DI processor class files because the class loader +// is not yet set up +require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); +require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); + +$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); +$processor->process($phpbb_container); + +// Setup class loader first +$phpbb_class_loader = $phpbb_container->get('class_loader'); +$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); + +$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); +foreach ($ids as $id) +{ + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); +} // set up caching -$cache_factory = new phpbb_cache_factory($acm_type); -$cache = $cache_factory->get_service(); -$phpbb_class_loader_ext->set_cache($cache->get_driver()); -$phpbb_class_loader->set_cache($cache->get_driver()); - -$phpbb_dispatcher = new phpbb_event_dispatcher(); -$request = new phpbb_request(); -$user = new phpbb_user(); -$db = new $sql_db(); +$cache = $phpbb_container->get('cache'); + +// Instantiate some basic classes +$phpbb_dispatcher = $phpbb_container->get('dispatcher'); +$request = $phpbb_container->get('request'); +$user = $phpbb_container->get('user'); +$auth = $phpbb_container->get('auth'); +$db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -- cgit v1.2.1 From 298fa894e7ea0807a295cd0ed55cabef8a27a3f3 Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 13 Sep 2012 16:56:09 -0400 Subject: [ticket/11086] Move DI processing below $request definition As per PR #991 (ticket/11101). PHPBB3-11086 --- phpBB/install/database_update.php | 15 +++++++-------- 1 file changed, 7 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 323ba0c876..5fa6166913 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -119,7 +119,6 @@ $loader->load('services.yml'); // is not yet set up require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); - $processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); $processor->process($phpbb_container); @@ -127,13 +126,6 @@ $processor->process($phpbb_container); $phpbb_class_loader = $phpbb_container->get('class_loader'); $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) -{ - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // set up caching $cache = $phpbb_container->get('cache'); @@ -144,6 +136,13 @@ $user = $phpbb_container->get('user'); $auth = $phpbb_container->get('auth'); $db = $phpbb_container->get('dbal.conn'); +$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); +foreach ($ids as $id) +{ + $processor = $phpbb_container->get($id); + $processor->process($phpbb_container); +} + // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -- cgit v1.2.1 From 195014867ae84fe04ec01c913e38bf1d435590f7 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 11:25:22 +0100 Subject: [ticket/11183] Remove $load_extensions and weird dl() calls PHPBB3-11183 --- phpBB/install/database_update.php | 17 +++-------------- 1 file changed, 3 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 527108af08..dcdd17cbc0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -73,17 +73,6 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) die("Please read: INSTALL.html before attempting to update."); } -// Load Extensions -if (!empty($load_extensions) && function_exists('dl')) -{ - $load_extensions = explode(',', $load_extensions); - - foreach ($load_extensions as $extension) - { - @dl(trim($extension)); - } -} - // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); @@ -2716,10 +2705,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) @@ -2752,7 +2741,7 @@ function change_database_data(&$no_updates, $version) // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } - + if (!isset($config['site_home_url'])) { $config->set('site_home_url', ''); -- cgit v1.2.1 From f48709f5bb8fb1b916d308e3b4bb06bc96d08611 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 19 Oct 2012 19:53:29 -0400 Subject: [feature/compiled-dic] Compile the DI Container into a cached class PHPBB3-11152 --- phpBB/install/database_update.php | 34 +++++++++++++++++++++------------- 1 file changed, 21 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 527108af08..65c72ad635 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -109,20 +109,28 @@ if (!defined('EXT_TABLE')) define('EXT_TABLE', $table_prefix . 'ext'); } -$phpbb_container = new ContainerBuilder(); -$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config')); -$loader->load('services.yml'); - -// We must include the DI processor class files because the class loader -// is not yet set up -require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx); -require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx); -$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx); -$processor->process($phpbb_container); - // Setup class loader first -$phpbb_class_loader = $phpbb_container->get('class_loader'); -$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext'); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader->register(); +$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); +$phpbb_class_loader_ext->register(); + +// Set up container +$phpbb_container = phpbb_create_compiled_container( + array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), + ), + array( + new phpbb_event_kernel_compiler_pass(), + ), + $phpbb_root_path . 'config.' . $phpEx, + $phpbb_root_path, + $phpEx +); + +$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); +$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); // set up caching $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From f9f03435f0681ab1aba1ff23d84fb4101be37e46 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 20 Oct 2012 17:03:06 -0400 Subject: [feature/compiled-dic] Move this to the other PR PHPBB3-11152 --- phpBB/install/database_update.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 65c72ad635..3d296545b4 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,9 +121,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array( - new phpbb_event_kernel_compiler_pass(), - ), + array(), $phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx -- cgit v1.2.1 From cb2725dd5a04118de8628e10f940e926f4fa8fa1 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 21 Oct 2012 16:09:43 -0400 Subject: [feature/compiled-dic] Fix cron task loading We cannot use container tags at run time if we are using a cached, compiled container object (i.e. phpbb_cache_container) so we have to load them beforehand. PHPBB3-11152 --- phpBB/install/database_update.php | 5 +++-- 1 file changed, 3 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 3d296545b4..1734272486 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,8 +121,9 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array(), - $phpbb_root_path . 'config.' . $phpEx, + array( + new phpbb_di_pass_cron(), + ), $phpbb_root_path, $phpEx ); -- cgit v1.2.1 From 897e8f2e8361839a92acae7e77225ef212e44647 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 9 Nov 2012 23:00:44 +0100 Subject: [ticket/11152] Move container functions to a separate function file PHPBB3-11152 --- phpBB/install/database_update.php | 7 ++++--- 1 file changed, 4 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 1734272486..a5c4e2acd3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -88,6 +88,7 @@ if (!empty($load_extensions) && function_exists('dl')) require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); @@ -2723,10 +2724,10 @@ function change_database_data(&$no_updates, $version) // Create config value for displaying last subject on forum list if (!isset($config['display_last_subject'])) - { + { $config->set('display_last_subject', '1'); } - + $no_updates = false; if (!isset($config['assets_version'])) @@ -2759,7 +2760,7 @@ function change_database_data(&$no_updates, $version) // After we have calculated the timezones we can delete user_dst column from user table. $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); } - + if (!isset($config['site_home_url'])) { $config->set('site_home_url', ''); -- cgit v1.2.1 From bd37f7f6c04780819dfa8f81b2d761b91859fd67 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 10 Nov 2012 10:45:02 -0600 Subject: [ticket/11189] Replace DEBUG_EXTRA with DEBUG PHPBB3-11189 --- 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 dcdd17cbc0..899394cd08 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -620,7 +620,7 @@ function _sql($sql, &$errored, &$error_ary, $echo_dot = true) { global $db; - if (defined('DEBUG_EXTRA')) + if (defined('DEBUG')) { echo "
\n{$sql}\n
"; } -- cgit v1.2.1 From 231d743ba9966e8304e0dd226ebf5eb7fb3b70d8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:34:27 +0100 Subject: [ticket/11152] Change phpbb_di_pass_cron to generic phpbb_di_pass_collection PHPBB3-11152 --- 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 a5c4e2acd3..bc45b27cdc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,7 +123,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_cron(), + new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 8851b797fbf0f1b4120aa4d3ae713711e01ef98f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 23:35:52 +0100 Subject: [ticket/11152] Create separate function for debug-dependent container PHPBB3-11152 --- 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 bc45b27cdc..add59b3c85 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -117,7 +117,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat $phpbb_class_loader_ext->register(); // Set up container -$phpbb_container = phpbb_create_compiled_container( +$phpbb_container = phpbb_create_dumped_container_unless_debug( array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), -- cgit v1.2.1 From 3e4d3761fdec878758e43779eab124816596c8aa Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 11 Nov 2012 14:18:11 +0100 Subject: [ticket/11152] Rename collection to collection_pass PHPBB3-11152 --- 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 add59b3c85..1940daf334 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,7 +123,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 844770d223eca4fe509a00e6e979be7cb58eadd5 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 11 Nov 2012 17:43:12 +0100 Subject: [ticket/11152] Remove old container processor calls PHPBB3-11152 --- phpBB/install/database_update.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1940daf334..0121ccab1e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -142,13 +142,6 @@ $user = $phpbb_container->get('user'); $auth = $phpbb_container->get('auth'); $db = $phpbb_container->get('dbal.conn'); -$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor')); -foreach ($ids as $id) -{ - $processor = $phpbb_container->get($id); - $processor->process($phpbb_container); -} - // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -- cgit v1.2.1 From d2a051cdd4269fd5749bdd4e7619fc5176a510a8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 11 Nov 2012 18:39:24 +0100 Subject: [ticket/11193] Instantiate a single collection_pass for all collections PHPBB3-11193 --- 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 27cc4951a9..297802c210 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -112,7 +112,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( new phpbb_di_extension_core($phpbb_root_path), ), array( - new phpbb_di_pass_collection_pass('cron.task_collection', 'cron.task'), + new phpbb_di_pass_collection_pass(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From dd1f8a0e554cc7c7fd975089cfd01acc88c656a6 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 11 Nov 2012 19:41:45 -0500 Subject: [feature/controller-new] Call pass to subscribe the Kernel event listener PHPBB3-10864 --- 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 297802c210..b8f5021dfd 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -113,6 +113,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( ), array( new phpbb_di_pass_collection_pass(), + new phpbb_di_pass_kernel(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 4b6d538b062a56f55ba221ac8437b4bfc712a475 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 13 Nov 2012 09:28:56 -0500 Subject: [feature/controller] Rename kernel pass class properly PHPBB3-10864 --- 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 b8f5021dfd..377e38c423 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -113,7 +113,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( ), array( new phpbb_di_pass_collection_pass(), - new phpbb_di_pass_kernel(), + new phpbb_di_pass_kernel_pass(), ), $phpbb_root_path, $phpEx -- cgit v1.2.1 From 80da19ca7c12feb2996fd9d64dbdc8cb5c3cd2d9 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 7 Nov 2012 09:13:16 +0000 Subject: [ticket/10601] Database updating code This is what is needed to update the database to comply with these code changes PHPBB3-10601 --- 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 377e38c423..7b20404cf2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2749,6 +2749,33 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_url', ''); $config->set('site_home_text', ''); } + + + // ticket/10601: Make inbox default. Add basename to ucp's pm category + // Check if this was already applied + $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id + FROM ' . MODULES_TABLE . ' + WHERE + module_basename = \'ucp_pm\' + ORDER BY module_id'; + $result = $db->sql_query_limit($sql, 1); + + if ($row = $db->sql_fetchrow($result)) + { + // Checking if this is not a category + if ($row['left_id'] === $row['right_id'] - 1) + { + // This update is still not applied. Applying it + + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_basename = \'ucp_pm\' + WHERE module_id = ' . (int)$row['parent_id']; + + _sql($sql, $errored, $error_ary); + + } + } + $db->sql_freeresult($result); break; } -- cgit v1.2.1 From 85ebbbaec471ea64f22543e006f8c160b02d503f Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 7 Nov 2012 22:26:54 +0000 Subject: [ticket/10601] Database updating code v2 Added the space after the (int) as requested PHPBB3-10601 --- phpBB/install/database_update.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7b20404cf2..620af92173 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2753,29 +2753,29 @@ function change_database_data(&$no_updates, $version) // ticket/10601: Make inbox default. Add basename to ucp's pm category // Check if this was already applied - $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id - FROM ' . MODULES_TABLE . ' - WHERE - module_basename = \'ucp_pm\' - ORDER BY module_id'; - $result = $db->sql_query_limit($sql, 1); + $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id + FROM ' . MODULES_TABLE . ' + WHERE + module_basename = \'ucp_pm\' + ORDER BY module_id'; + $result = $db->sql_query_limit($sql, 1); - if ($row = $db->sql_fetchrow($result)) + if ($row = $db->sql_fetchrow($result)) + { + // Checking if this is not a category + if ($row['left_id'] === $row['right_id'] - 1) { - // Checking if this is not a category - if ($row['left_id'] === $row['right_id'] - 1) - { - // This update is still not applied. Applying it - - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_basename = \'ucp_pm\' - WHERE module_id = ' . (int)$row['parent_id']; - - _sql($sql, $errored, $error_ary); + // This update is still not applied. Applying it - } + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_basename = \'ucp_pm\' + WHERE module_id = ' . (int) $row['parent_id']; + + _sql($sql, $errored, $error_ary); + } - $db->sql_freeresult($result); + } + $db->sql_freeresult($result); break; } -- cgit v1.2.1 From 1f9eaa1c56ec909bde82e1d7ad86079cd23f46bc Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Fri, 9 Nov 2012 08:51:18 +0000 Subject: [ticket/10601] Cosmetic code changes - Removed the double line before the addition - Moved the condition of the WHERE so that both are in the same line - Removed TABs from the black lines - Used double quotes instead of escaped single quotes. PHPBB3-10601 --- phpBB/install/database_update.php | 12 +++++------- 1 file changed, 5 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 620af92173..1dae3e566b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2749,14 +2749,12 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_url', ''); $config->set('site_home_text', ''); } - - + // ticket/10601: Make inbox default. Add basename to ucp's pm category // Check if this was already applied $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id FROM ' . MODULES_TABLE . ' - WHERE - module_basename = \'ucp_pm\' + WHERE module_basename = "ucp_pm" ORDER BY module_id'; $result = $db->sql_query_limit($sql, 1); @@ -2766,13 +2764,13 @@ function change_database_data(&$no_updates, $version) if ($row['left_id'] === $row['right_id'] - 1) { // This update is still not applied. Applying it - + $sql = 'UPDATE ' . MODULES_TABLE . ' SET module_basename = \'ucp_pm\' WHERE module_id = ' . (int) $row['parent_id']; - + _sql($sql, $errored, $error_ary); - + } } $db->sql_freeresult($result); -- cgit v1.2.1 From a4cc07617726bffd4c64cdebaa2e20a463990c5d Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 28 Nov 2012 19:36:13 +0000 Subject: [ticket/10601] Requested code changes - Renamed the comment to PHPBB3-10601 - Removed backslashes - Traded double quotes into single quotes inside. PHPBB3-10601 --- 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 1dae3e566b..eed484dfae 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2753,9 +2753,9 @@ function change_database_data(&$no_updates, $version) // ticket/10601: Make inbox default. Add basename to ucp's pm category // Check if this was already applied $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id - FROM ' . MODULES_TABLE . ' - WHERE module_basename = "ucp_pm" - ORDER BY module_id'; + FROM ' . MODULES_TABLE . " + WHERE module_basename = 'ucp_pm' + ORDER BY module_id"; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) @@ -2765,9 +2765,9 @@ function change_database_data(&$no_updates, $version) { // This update is still not applied. Applying it - $sql = 'UPDATE ' . MODULES_TABLE . ' - SET module_basename = \'ucp_pm\' - WHERE module_id = ' . (int) $row['parent_id']; + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['parent_id']; _sql($sql, $errored, $error_ary); -- cgit v1.2.1 From a0d5c52eb6e8ef3a6bb44cff60b364d3a3a5bf3e Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 1 Dec 2012 09:44:51 +0000 Subject: [ticket/10601] New approach in the update algorithm - New approach in the database update algorithm PHPBB3-10601 --- phpBB/install/database_update.php | 25 +++++++++++-------------- 1 file changed, 11 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 eed484dfae..f3136690a2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2750,28 +2750,25 @@ function change_database_data(&$no_updates, $version) $config->set('site_home_text', ''); } - // ticket/10601: Make inbox default. Add basename to ucp's pm category - // Check if this was already applied - $sql = 'SELECT module_id, module_basename, parent_id, left_id, right_id + // PHPBB3-10601: Make inbox default. Add basename to ucp's pm category + + // Get the category wanted while checking, at the same time, if this has already been applied + $sql = 'SELECT module_id, module_basename FROM ' . MODULES_TABLE . " - WHERE module_basename = 'ucp_pm' + WHERE module_basename <> 'ucp_pm' AND + module_langname='UCP_PM' ORDER BY module_id"; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) { - // Checking if this is not a category - if ($row['left_id'] === $row['right_id'] - 1) - { - // This update is still not applied. Applying it - - $sql = 'UPDATE ' . MODULES_TABLE . " - SET module_basename = 'ucp_pm' - WHERE module_id = " . (int) $row['parent_id']; + // This update is still not applied. Applying it - _sql($sql, $errored, $error_ary); + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_basename = 'ucp_pm' + WHERE module_id = " . (int) $row['module_id']; - } + _sql($sql, $errored, $error_ary); } $db->sql_freeresult($result); -- cgit v1.2.1 From 1ce06711811561d2e3fa3c6ba2aeac4ebffa6581 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sat, 1 Dec 2012 10:05:20 +0000 Subject: [ticket/10601] The ORDER BY is only taking space there PHPBB3-10601 --- 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 f3136690a2..ae6e3bd9cf 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2757,7 +2757,7 @@ function change_database_data(&$no_updates, $version) FROM ' . MODULES_TABLE . " WHERE module_basename <> 'ucp_pm' AND module_langname='UCP_PM' - ORDER BY module_id"; + "; $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) -- cgit v1.2.1 From 4103c99a8676653a868014a6f58a76e8986bd5ed Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 1 Mar 2012 16:15:11 +0100 Subject: [ticket/10679] Add new permission for changing profile field information The setting is copied from "Can use signature" PHPBB3-10679 --- phpBB/install/database_update.php | 48 +++++++++++++++++++++++++++++++++++---- 1 file changed, 44 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 e966756337..f0a16844e9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2731,8 +2731,6 @@ function change_database_data(&$no_updates, $version) $config->set('display_last_subject', '1'); } - $no_updates = false; - if (!isset($config['assets_version'])) { $config->set('assets_version', '1'); @@ -2771,7 +2769,7 @@ function change_database_data(&$no_updates, $version) } // PHPBB3-10601: Make inbox default. Add basename to ucp's pm category - + // Get the category wanted while checking, at the same time, if this has already been applied $sql = 'SELECT module_id, module_basename FROM ' . MODULES_TABLE . " @@ -2788,10 +2786,52 @@ function change_database_data(&$no_updates, $version) SET module_basename = 'ucp_pm' WHERE module_id = " . (int) $row['module_id']; - _sql($sql, $errored, $error_ary); + _sql($sql, $errored, $error_ary); } $db->sql_freeresult($result); + // Add new permission u_chgprofileinfo and duplicate settings from u_sig + include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); + $auth_admin = new auth_admin(); + + // Only add the new permission if it does not already exist + if (empty($auth_admin->acl_options['id']['u_chgprofileinfo'])) + { + $auth_admin->acl_add_option(array('global' => array('u_chgprofileinfo'))); + + // Now the tricky part, filling the permission + $old_id = $auth_admin->acl_options['id']['u_sig']; + $new_id = $auth_admin->acl_options['id']['u_chgprofileinfo']; + + $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(); + } + + $no_updates = false; + break; } } -- cgit v1.2.1 From 2f490293e4b8d08d6c1008ef5ea324ae259d9993 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Dec 2012 16:33:12 +0100 Subject: [ticket/10679] Use module_auth to limit access to the module PHPBB3-10679 --- 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 f0a16844e9..95fd1ca2c2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2830,6 +2830,14 @@ function change_database_data(&$no_updates, $version) $auth_admin->acl_clear_prefetch(); } + // Update the auth setting for the module + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_auth = 'acl_u_chgprofileinfo' + WHERE module_class = 'ucp' + AND module_basename = 'profile' + AND module_mode = 'profile_info'"; + _sql($sql, $errored, $error_ary); + $no_updates = false; break; -- cgit v1.2.1 From 25780c17a4e9c1e96e8f1648bd9bd16ff06afb7f Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Sun, 2 Dec 2012 22:59:11 +0000 Subject: [ticket/11171] DB changes for the update These are the changes to database_update.php required for this ticket. PHPBB3-11171 --- phpBB/install/database_update.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index e966756337..060d749b92 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2792,6 +2792,23 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); + // PHPBB3-11171: Copy bbcode fields, etc. for reported posts. Add 5 columns to the reports table + + // Add the columns used by these changes + $changes['add_columns'] = array( + REPORTS_TABLE => array( + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1) + ) + ); + $statements = $db_tools->perform_schema_changes($changes); + + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } + break; } } -- cgit v1.2.1 From c23d2457e9be616bfa83aebc5e743130b6c69624 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Dec 2012 12:50:21 +0100 Subject: [ticket/10679] Update module basename, we added the xcp_ prefix in 3.1 PHPBB3-10679 --- 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 95fd1ca2c2..30592b995d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2834,7 +2834,7 @@ function change_database_data(&$no_updates, $version) $sql = 'UPDATE ' . MODULES_TABLE . " SET module_auth = 'acl_u_chgprofileinfo' WHERE module_class = 'ucp' - AND module_basename = 'profile' + AND module_basename = 'ucp_profile' AND module_mode = 'profile_info'"; _sql($sql, $errored, $error_ary); -- cgit v1.2.1 From 9eecaa21e3fe23c0c1afc7f8d057754fca68e9a6 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 6 Dec 2012 11:22:56 +0000 Subject: [ticket/11171] Moved the DB schema changes to its place Moved the db changes schema to the place where all the other schema changes are. PHPBB3-11171 --- phpBB/install/database_update.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 060d749b92..91365d4a72 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1123,9 +1123,12 @@ function database_update_info() 'style_parent_tree' => array('TEXT', ''), ), REPORTS_TABLE => array( - 'reported_post_text' => array('MTEXT_UNI', ''), - 'reported_post_uid' => array('VCHAR:8', ''), - 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), + 'reported_post_uid' => array('VCHAR:8', ''), + 'reported_post_bitfield' => array('VCHAR:255', ''), + 'reported_post_enable_bbcode' => array('BOOL', 1), + 'reported_post_enable_smilies' => array('BOOL', 1), + 'reported_post_enable_magic_url' => array('BOOL', 1), ), ), 'change_columns' => array( @@ -2791,23 +2794,7 @@ function change_database_data(&$no_updates, $version) _sql($sql, $errored, $error_ary); } $db->sql_freeresult($result); - - // PHPBB3-11171: Copy bbcode fields, etc. for reported posts. Add 5 columns to the reports table - // Add the columns used by these changes - $changes['add_columns'] = array( - REPORTS_TABLE => array( - 'reported_post_enable_bbcode' => array('BOOL', 1), - 'reported_post_enable_smilies' => array('BOOL', 1), - 'reported_post_enable_magic_url' => array('BOOL', 1) - ) - ); - $statements = $db_tools->perform_schema_changes($changes); - - foreach ($statements as $sql) - { - _sql($sql, $errored, $error_ary); - } break; } -- cgit v1.2.1 From 6dee2539419ba2c050830b7677294603a63b559a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Dec 2012 17:01:08 -0600 Subject: [ticket/11259] Make phpbb_admin_path available everywhere PHPBB3-11259 --- 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 30592b995d..38bfe978e5 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -73,6 +73,10 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) die("Please read: INSTALL.html before attempting to update."); } +// In case $adm_relative_path is not set (in case of an update), use the default. +$adm_relative_path = (isset($adm_relative_path)) ? ((substr($adm_relative_path, -1) == '/') ? $adm_relative_path : $adm_relative_path . '/') : 'adm/'; +$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $adm_relative_path; + // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); @@ -232,7 +236,7 @@ if ($has_global && !$ga_forum_id) <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> - + @@ -282,7 +286,7 @@ header('Content-type: text/html; charset=UTF-8'); <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> - + -- cgit v1.2.1 From 30de17f69f70a0c23fa314de479bac57e3dbae2b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Dec 2012 19:29:51 -0600 Subject: [ticket/11259] adm_relative_path -> phpbb_adm_relative_path We can assume they properly format their config settings, right? PHPBB3-11259 --- 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 38bfe978e5..1600b7bd10 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -73,9 +73,9 @@ if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) die("Please read: INSTALL.html before attempting to update."); } -// In case $adm_relative_path is not set (in case of an update), use the default. -$adm_relative_path = (isset($adm_relative_path)) ? ((substr($adm_relative_path, -1) == '/') ? $adm_relative_path : $adm_relative_path . '/') : 'adm/'; -$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $adm_relative_path; +// In case $phpbb_adm_relative_path is not set (in case of an update), use the default. +$phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/'; +$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -- cgit v1.2.1 From 61391f648c95251466f805f148f1656e940f2027 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 10 Dec 2012 21:16:08 -0600 Subject: [ticket/11259] htmlspecialchars($phpbb_admin_path) PHPBB3-11259 --- 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 1600b7bd10..7795f8d7f7 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -236,7 +236,7 @@ if ($has_global && !$ga_forum_id) <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> - + @@ -286,7 +286,7 @@ header('Content-type: text/html; charset=UTF-8'); <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> - + -- cgit v1.2.1 From 4980d8b01150593175274dad45890544f56075d6 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 2 Sep 2012 23:44:13 -0400 Subject: [ticket/11088] Move style, extension and language pack management to customise Instead of being separated, these related ACP modules are now grouped intuitively. PHPBB3-11088 --- 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 30592b995d..d276cdbc57 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2489,6 +2489,20 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), + 'extensions' => array( + 'base' => 'acp_extensions', + 'class' => 'acp', + 'title' => 'ACP_EXTENSIONS', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_EXTENSION_MANAGEMENT', + ), + 'lang_management' => array( + 'base' => 'acp_language', + 'class' => 'acp', + 'title' => 'ACL_LANGUAGE_PACKS', + 'auth' => 'acl_a_language', + 'cat' => 'ACL_LANGUAGE', + ), 'autologin_keys' => array( 'base' => 'ucp_profile', 'class' => 'ucp', -- cgit v1.2.1 From e58c6536f0407ec5f82c634c058270c4e627d03d Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 28 Sep 2012 18:03:35 -0400 Subject: [ticket/11088] Untested progress for update script PHPBB3-11088 --- phpBB/install/database_update.php | 55 +++++++++++++++++++++++++++++---------- 1 file changed, 41 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 d276cdbc57..73efa3f7f6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2459,6 +2459,19 @@ function change_database_data(&$no_updates, $version) unset($next_legend); } + // Create new Customise ACP tab + $module_manager = new acp_modules(); + $module_manager->update_module_data(array( + 'parent_id' => 0, + 'module_enabled' => 1, + 'module_display' => 1, + 'module_basename' => ''. + 'module_class' => 'acp', + 'module_mode' => '', + 'module_auth' => '', + 'module_langname' => 'ACP_CAT_CUSTOMISE', + )); + // Install modules $modules_to_install = array( 'position' => array( @@ -2489,20 +2502,6 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), - 'extensions' => array( - 'base' => 'acp_extensions', - 'class' => 'acp', - 'title' => 'ACP_EXTENSIONS', - 'auth' => 'acl_a_extensions', - 'cat' => 'ACP_EXTENSION_MANAGEMENT', - ), - 'lang_management' => array( - 'base' => 'acp_language', - 'class' => 'acp', - 'title' => 'ACL_LANGUAGE_PACKS', - 'auth' => 'acl_a_language', - 'cat' => 'ACL_LANGUAGE', - ), 'autologin_keys' => array( 'base' => 'ucp_profile', 'class' => 'ucp', @@ -2510,6 +2509,13 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), + 'extensions' => array( + 'base' => 'acp_extensions', + 'class' => 'acp', + 'title' => 'ACP_EXTENSIONS', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_EXTENSION_MANAGEMENT', + ), ); _add_modules($modules_to_install); @@ -2518,6 +2524,27 @@ function change_database_data(&$no_updates, $version) WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); + // Move language management to Customise + // First select the current language managment module ID + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language' OR module_langname = 'styles'"; + $result = $db->sql_query($sql); + $modules_to_move = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + // Next, selec the ID of the new parent module + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_CAT_CUSTOMISE'"; + $result = $db->sql_query($sql); + $customise_category_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + + // Now perform the move + foreach ($modules_to_move as $module_id) + { + $module_manager->move_module($module_id, $customise_category_id); + } + // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour FROM ' . TOPICS_TABLE . ' -- cgit v1.2.1 From 72d1a210de0f08550ce6a1b44c5ac468520146f2 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 23 Oct 2012 13:25:24 -0400 Subject: [ticket/11088] Fix typo (period instead of comma) PHPBB3-11088 --- 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 73efa3f7f6..7fa853938d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2465,7 +2465,7 @@ function change_database_data(&$no_updates, $version) 'parent_id' => 0, 'module_enabled' => 1, 'module_display' => 1, - 'module_basename' => ''. + 'module_basename' => '', 'module_class' => 'acp', 'module_mode' => '', 'module_auth' => '', -- cgit v1.2.1 From 30c64f6a01e7d5706c4c0e6b429c1d200f1c3e46 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 23 Oct 2012 13:37:46 -0400 Subject: [ticket/11088] Untested, progress on update script This should rename Styles category to Customise, move language packs, and add extension management PHPBB3-11088 --- phpBB/install/database_update.php | 49 ++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7fa853938d..610c591fcc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2459,19 +2459,31 @@ function change_database_data(&$no_updates, $version) unset($next_legend); } - // Create new Customise ACP tab + // Rename styles module to Customise + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_STYLE_MANAGEMENT'"; + $result = _sql($sql, $errored, $error_ary); + $row = $db->sql_fetchrow($result); + $styles_module_id = (int) $row['module_id']; + $db->sql_freeresult($result); + $module_manager = new acp_modules(); $module_manager->update_module_data(array( - 'parent_id' => 0, - 'module_enabled' => 1, - 'module_display' => 1, - 'module_basename' => '', - 'module_class' => 'acp', - 'module_mode' => '', - 'module_auth' => '', + 'module_id' => $styles_module_id, 'module_langname' => 'ACP_CAT_CUSTOMISE', )); + // Move language management to Customise + // First select the current language managment module ID + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language'"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $module_manager->move_module($row['module_id'], $customise_category_id); + } + $db->sql_freeresult($result); + // Install modules $modules_to_install = array( 'position' => array( @@ -2524,27 +2536,6 @@ function change_database_data(&$no_updates, $version) WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); - // Move language management to Customise - // First select the current language managment module ID - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language' OR module_langname = 'styles'"; - $result = $db->sql_query($sql); - $modules_to_move = $db->sql_fetchrowset($result); - $db->sql_freeresult($result); - - // Next, selec the ID of the new parent module - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_CAT_CUSTOMISE'"; - $result = $db->sql_query($sql); - $customise_category_id = $db->sql_fetchfield('module_id'); - $db->sql_freeresult($result); - - // Now perform the move - foreach ($modules_to_move as $module_id) - { - $module_manager->move_module($module_id, $customise_category_id); - } - // Localise Global Announcements $sql = 'SELECT topic_id, topic_approved, (topic_replies + 1) AS topic_posts, topic_last_post_id, topic_last_post_subject, topic_last_post_time, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour FROM ' . TOPICS_TABLE . ' -- cgit v1.2.1 From 80f68c358ff9e01d5cf4327c5c0d748e6e6de448 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 11:38:44 -0500 Subject: [ticket/11088] Put language pack module move below extension module creation PHPBB3-11088 --- phpBB/install/database_update.php | 21 ++++++++++----------- 1 file changed, 10 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 610c591fcc..47983676cc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2473,17 +2473,6 @@ function change_database_data(&$no_updates, $version) 'module_langname' => 'ACP_CAT_CUSTOMISE', )); - // Move language management to Customise - // First select the current language managment module ID - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language'"; - $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) - { - $module_manager->move_module($row['module_id'], $customise_category_id); - } - $db->sql_freeresult($result); - // Install modules $modules_to_install = array( 'position' => array( @@ -2532,6 +2521,16 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); + // Move language management to Customise + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_basename = 'language'"; + $result = $db->sql_query($sql); + while($row = $db->sql_fetchrow($result)) + { + $module_manager->move_module($row['module_id'], $styles_module_id); + } + $db->sql_freeresult($result); + $sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; _sql($sql, $errored, $error_ary); -- cgit v1.2.1 From 70aea6fd7c1af79774d800eaafe11c5381e3ff32 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 12:48:27 -0500 Subject: [ticket/11088] Fix the database updater to correctly manipulate the modules PHPBB3-11088 --- phpBB/install/database_update.php | 102 +++++++++++++++++++++++++++++++------- 1 file changed, 85 insertions(+), 17 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 47983676cc..afc816845d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2460,18 +2460,10 @@ function change_database_data(&$no_updates, $version) } // Rename styles module to Customise - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_langname = 'ACP_STYLE_MANAGEMENT'"; - $result = _sql($sql, $errored, $error_ary); - $row = $db->sql_fetchrow($result); - $styles_module_id = (int) $row['module_id']; - $db->sql_freeresult($result); - - $module_manager = new acp_modules(); - $module_manager->update_module_data(array( - 'module_id' => $styles_module_id, - 'module_langname' => 'ACP_CAT_CUSTOMISE', - )); + $sql = 'UPDATE ' . MODULES_TABLE . " + SET module_langname = 'ACP_CAT_CUSTOMISE' + WHERE module_langname = 'ACP_CAT_STYLES'"; + _sql($sql, $errored, $error_ary); // Install modules $modules_to_install = array( @@ -2510,6 +2502,15 @@ function change_database_data(&$no_updates, $version) 'auth' => '', 'cat' => 'UCP_PROFILE', ), + // To add a category, the mode and basename must be empty + // The mode is taken from the this array key + '' => array( + 'base' => '', + 'class' => 'acp', + 'title' => 'ACP_EXTENSION_MANAGEMENT', + 'auth' => 'acl_a_extensions', + 'cat' => 'ACP_CAT_CUSTOMISE', + ), 'extensions' => array( 'base' => 'acp_extensions', 'class' => 'acp', @@ -2521,15 +2522,46 @@ function change_database_data(&$no_updates, $version) _add_modules($modules_to_install); - // Move language management to Customise + // We need a separate array for the new language sub heading + // because it requires another empty key + $modules_to_install = array( + '' => array( + 'base' => '', + 'class' => 'acp', + 'title' => 'ACP_LANGUAGE', + 'auth' => 'acl_a_language', + 'cat' => 'ACP_CAT_CUSTOMISE', + ), + ); + + _add_modules($modules_to_install); + + // Move language management to new location in the Customise tab + // First get language module id $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " - WHERE module_basename = 'language'"; + WHERE module_basename = 'acp_language'"; $result = $db->sql_query($sql); - while($row = $db->sql_fetchrow($result)) + $language_module_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + // Next get language management module id of the one just created + $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " + WHERE module_langname = 'ACP_LANGUAGE'"; + $result = $db->sql_query($sql); + $language_management_module_id = $db->sql_fetchfield('module_id'); + $db->sql_freeresult($result); + + if (!class_exists('acp_modules')) { - $module_manager->move_module($row['module_id'], $styles_module_id); + include($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); } - $db->sql_freeresult($result); + // acp_modules calls adm_back_link, which is undefined at this point + if (!function_exists('adm_back_link')) + { + include($phpbb_root_path . 'includes/functions_acp.' . $phpEx); + } + $module_manager = new acp_modules(); + $module_manager->module_class = 'acp'; + $module_manager->move_module($language_module_id, $language_management_module_id); $sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE (module_basename = 'styles' OR module_basename = 'acp_styles') AND (module_mode = 'imageset' OR module_mode = 'theme' OR module_mode = 'template')"; @@ -2861,6 +2893,42 @@ function change_database_data(&$no_updates, $version) $auth_admin->acl_clear_prefetch(); } + // Add acl_a_extensions + if (empty($auth_admin->acl_options['id']['a_extensions'])) + { + $auth_admin->acl_add_option(array('global' => array('a_extensions'))); + + // Now the tricky part, filling the permission + $old_id = $auth_admin->acl_options['id']['a_']; + $new_id = $auth_admin->acl_options['id']['a_extensions']; + + $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(); + } + // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " SET module_auth = 'acl_u_chgprofileinfo' -- cgit v1.2.1 From 61adfa502684727f071f85afde08227ebc448232 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 19:37:39 -0500 Subject: [ticket/11088] Remove extraneous word from sentence in comment PHPBB3-11088 --- 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 afc816845d..1d4c71767b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2503,7 +2503,7 @@ function change_database_data(&$no_updates, $version) 'cat' => 'UCP_PROFILE', ), // To add a category, the mode and basename must be empty - // The mode is taken from the this array key + // The mode is taken from the array key '' => array( 'base' => '', 'class' => 'acp', -- cgit v1.2.1 From 8e4c1526fc3d0b8897886a12dff59808398b2304 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 19:39:48 -0500 Subject: [ticket/11088] Copy a_styles permission for a_extensions PHPBB3-11088 --- 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 1d4c71767b..db5659db7c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2899,7 +2899,7 @@ function change_database_data(&$no_updates, $version) $auth_admin->acl_add_option(array('global' => array('a_extensions'))); // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['a_']; + $old_id = $auth_admin->acl_options['id']['a_styles']; $new_id = $auth_admin->acl_options['id']['a_extensions']; $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); -- cgit v1.2.1 From 13f8e64a33a862554cfa185bcf09af9ccdace95c Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:01:58 -0500 Subject: [ticket/11088] Move permission creation to a function PHPBB3-11088 --- phpBB/install/database_update.php | 138 ++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 72 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index db5659db7c..3815f5e8b3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -818,6 +818,69 @@ function _add_modules($modules_to_install) $_module->remove_cache_file(); } +/** +* Add a new permission, optionally copy permission setting from another +* +* @param auth_admin $auth_admin auth_admin object +* @param string $permission_name Name of the permission to add +* @param bool $is_global True is global, false is local +* @param string $copy_from Optional permission name from which to copy +* @return bool true on success, false on failure +*/ +function _add_permission(auth_admin $auth_admin, $permission_name, $is_global = true, $copy_from = '') +{ + // Only add a permission that don't already exist + if (!empty($auth_admin->acl_options['id'][$permission_name])) + { + return true; + } + + $permission_scope = $is_global ? 'global' : 'local'; + + $result = $auth_admin->acl_add_option(array( + $permission_scope => array($permission_name), + )); + + if (!$result) + { + return $result; + } + + // The permission has been added, now we can copy it if needed + if ($copy_from && isset($auth_admin->acl_options['id'][$copy_from])) + { + $old_id = $auth_admin->acl_options['id'][$copy_from]; + $new_id = $auth_admin->acl_options['id'][$permission_name]; + + $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE); + + foreach ($tables as $table) + { + $sql = 'SELECT * + FROM ' . $table . ' + WHERE auth_option_id = ' . $old_id; + $result = _sql($sql, $errored, $error_ary); + + $sql_ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $row['auth_option_id'] = $new_id; + $sql_ary[] = $row; + } + $db->sql_freeresult($result); + + if (sizeof($sql_ary)) + { + $db->sql_multi_insert($table, $sql_ary); + } + } + + $auth_admin->acl_clear_prefetch(); + } + + return true; +} + /**************************************************************************** * ADD YOUR DATABASE SCHEMA CHANGES HERE * *****************************************************************************/ @@ -2853,81 +2916,12 @@ function change_database_data(&$no_updates, $version) } $db->sql_freeresult($result); - // Add new permission u_chgprofileinfo and duplicate settings from u_sig + // Add new permissions include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); - // Only add the new permission if it does not already exist - if (empty($auth_admin->acl_options['id']['u_chgprofileinfo'])) - { - $auth_admin->acl_add_option(array('global' => array('u_chgprofileinfo'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['u_sig']; - $new_id = $auth_admin->acl_options['id']['u_chgprofileinfo']; - - $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(); - } - - // Add acl_a_extensions - if (empty($auth_admin->acl_options['id']['a_extensions'])) - { - $auth_admin->acl_add_option(array('global' => array('a_extensions'))); - - // Now the tricky part, filling the permission - $old_id = $auth_admin->acl_options['id']['a_styles']; - $new_id = $auth_admin->acl_options['id']['a_extensions']; - - $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(); - } + _add_permission($auth_admin, 'u_chgprofileinfo', true, 'u_sig'); + _add_permission($auth_admin, 'a_extensions', true, 'a_styles'); // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " -- cgit v1.2.1 From 5fc6752178ebc814c83b88b5891c568273d36c94 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:04:20 -0500 Subject: [ticket/11088] Globalize objects in new permission function PHPBB3-11088 --- phpBB/install/database_update.php | 7 ++++--- 1 file changed, 4 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 3815f5e8b3..fb762c6137 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -827,8 +827,9 @@ function _add_modules($modules_to_install) * @param string $copy_from Optional permission name from which to copy * @return bool true on success, false on failure */ -function _add_permission(auth_admin $auth_admin, $permission_name, $is_global = true, $copy_from = '') +function _add_permission($permission_name, $is_global = true, $copy_from = '') { + global $db, $auth_admin; // Only add a permission that don't already exist if (!empty($auth_admin->acl_options['id'][$permission_name])) { @@ -2920,8 +2921,8 @@ function change_database_data(&$no_updates, $version) include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); - _add_permission($auth_admin, 'u_chgprofileinfo', true, 'u_sig'); - _add_permission($auth_admin, 'a_extensions', true, 'a_styles'); + _add_permission('u_chgprofileinfo', true, 'u_sig'); + _add_permission('a_extensions', true, 'a_styles'); // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " -- cgit v1.2.1 From a5783211c90e226a9d1a2b3636f63f1a80aced19 Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 12 Dec 2012 20:19:06 -0500 Subject: [ticket/11088] Pass required objects in as arguments PHPBB3-11088 --- phpBB/install/database_update.php | 8 ++++---- 1 file changed, 4 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 fb762c6137..7aa346b817 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -822,14 +822,14 @@ function _add_modules($modules_to_install) * Add a new permission, optionally copy permission setting from another * * @param auth_admin $auth_admin auth_admin object +* @param dbal $db Database object * @param string $permission_name Name of the permission to add * @param bool $is_global True is global, false is local * @param string $copy_from Optional permission name from which to copy * @return bool true on success, false on failure */ -function _add_permission($permission_name, $is_global = true, $copy_from = '') +function _add_permission(auth_admin $auth_admin, dbal $db, $permission_name, $is_global = true, $copy_from = '') { - global $db, $auth_admin; // Only add a permission that don't already exist if (!empty($auth_admin->acl_options['id'][$permission_name])) { @@ -2921,8 +2921,8 @@ function change_database_data(&$no_updates, $version) include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); $auth_admin = new auth_admin(); - _add_permission('u_chgprofileinfo', true, 'u_sig'); - _add_permission('a_extensions', true, 'a_styles'); + _add_permission($auth_admin, $db, 'u_chgprofileinfo', true, 'u_sig'); + _add_permission($auth_admin, $db, 'a_extensions', true, 'a_styles'); // Update the auth setting for the module $sql = 'UPDATE ' . MODULES_TABLE . " -- cgit v1.2.1 From 1a1ae1b663079792c775c4a51d5aaaf0259fb05c Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 13 Dec 2012 18:00:29 -0500 Subject: [ticket/11015] Change permission adding in database updater to new style. PHPBB3-11015 --- 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 9afb5cc963..19d0d35fc0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -821,13 +821,13 @@ function _add_modules($modules_to_install) * Add a new permission, optionally copy permission setting from another * * @param auth_admin $auth_admin auth_admin object -* @param dbal $db Database object +* @param phpbb_db_driver $db Database object * @param string $permission_name Name of the permission to add * @param bool $is_global True is global, false is local * @param string $copy_from Optional permission name from which to copy * @return bool true on success, false on failure */ -function _add_permission(auth_admin $auth_admin, dbal $db, $permission_name, $is_global = true, $copy_from = '') +function _add_permission(auth_admin $auth_admin, phpbb_db_driver $db, $permission_name, $is_global = true, $copy_from = '') { // Only add a permission that don't already exist if (!empty($auth_admin->acl_options['id'][$permission_name])) -- cgit v1.2.1 From 5f56804a9620bd537f85757707327a1017325053 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 21 Dec 2012 15:29:54 +0100 Subject: [ticket/11277] Correctly remove user_dst column on database update The db_tools is running in "return statement" mode, so the queries to modify the data are not executed, but just returned. PHPBB3-11277 --- 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 19d0d35fc0..1698e7777a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2885,7 +2885,11 @@ function change_database_data(&$no_updates, $version) set_config('board_timezone', $update_helpers->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst'])); // After we have calculated the timezones we can delete user_dst column from user table. - $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); + $statements = $db_tools->sql_column_remove(USERS_TABLE, 'user_dst'); + foreach ($statements as $sql) + { + _sql($sql, $errored, $error_ary); + } } if (!isset($config['site_home_url'])) -- cgit v1.2.1 From ea24de8de3e4f451aa4394f0f46d6955ccb671c2 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 2 Jan 2013 04:04:01 +0100 Subject: [ticket/11306] Introduce phpbb_create_default_container Extracts default container construction to factory function, removing boilerplate duplication for container construction. PHPBB3-11306 --- phpBB/install/database_update.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index bbb40d3976..87b1188c65 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -109,18 +109,7 @@ $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_pat $phpbb_class_loader_ext->register(); // Set up container -$phpbb_container = phpbb_create_dumped_container_unless_debug( - array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), - ), - array( - new phpbb_di_pass_collection_pass(), - new phpbb_di_pass_kernel_pass(), - ), - $phpbb_root_path, - $phpEx -); +$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); -- cgit v1.2.1 From 7adae349a96d5dffbd47ea5eca1e6bee481b7ce1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 1 Jan 2013 20:48:04 -0500 Subject: [ticket/11305] Extract hook finder from cache service. Unlike most other things in cache service, hook finder does not need a database connection. PHPBB3-11305 --- phpBB/install/database_update.php | 3 ++- 1 file changed, 2 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 87b1188c65..aeb5ae3859 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -133,7 +133,8 @@ if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); - foreach ($cache->obtain_hooks() as $hook) + $phpbb_hook_finder = new phpbb_hook_finder($phpbb_root_path, $phpEx, $phpbb_container->get('cache.driver')); + foreach ($phpbb_hook_finder->find() as $hook) { @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); } -- cgit v1.2.1 From b94f9ae3029777fa0aba2f3cb52b321925ce7e72 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 1 Jan 2013 20:57:21 -0500 Subject: [ticket/11305] Retrieve cache driver from container rather than cache service. This only covers some of the call sites. PHPBB3-11305 --- 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 aeb5ae3859..f31682c784 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -187,7 +187,7 @@ include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); $inline_update = (request_var('type', 0)) ? true : false; // To let set_config() calls succeed, we need to make the config array available globally -$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); +$config = new phpbb_config_db($db, $phpbb_container->get('cache.driver'), CONFIG_TABLE); set_config(null, null, null, $config); set_config_count(null, null, null, $config); @@ -574,7 +574,7 @@ else 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(); +$phpbb_container->get('cache.driver')->purge(); _print_footer(); -- cgit v1.2.1 From bc317c49a73bb6e271ac084b0b696b44e20babe8 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Wed, 2 Jan 2013 01:36:50 -0500 Subject: [ticket/11305] Define hook finder as a service on the container. PHPBB3-11305 --- 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 f31682c784..8950d677ae 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -133,7 +133,7 @@ if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); - $phpbb_hook_finder = new phpbb_hook_finder($phpbb_root_path, $phpEx, $phpbb_container->get('cache.driver')); + $phpbb_hook_finder = $phpbb_container->get('hook_finder'); foreach ($phpbb_hook_finder->find() as $hook) { @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx); -- cgit v1.2.1 From 460470229d972b93ef5a98b0d1d97a2a970d684f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Jan 2013 01:08:34 +0100 Subject: [ticket/11201] Remove database column on update PHPBB3-11201 --- 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 8950d677ae..3de9ce2717 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1193,6 +1193,11 @@ function database_update_info() 'user_timezone' => array('VCHAR:100', ''), ), ), + 'drop_columns' => array( + USERS_TABLE => array( + 'user_msnm', + ), + ), ), ); } -- cgit v1.2.1 From 336187151a2010197ddda1bcdabc311fd10c1c87 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Mon, 4 Feb 2013 01:30:04 +0100 Subject: [ticket/11201] Revert WLM dropping because it is still used in China. Windows Live Messenger is still in use in china which accounts for ~20% of world population. Revert WLM dropping which has been merged under the assumption that WLM data and features are completely useless. This commit reverts commits - 460470229d972b93ef5a98b0d1d97a2a970d684f - 9affd6f7e7b95442f1ef14894858d8213f3fbd2a which have been merged by d59431691c27c73fba8ae9934b84b34a13280dd2. PHPBB3-11201 --- phpBB/install/database_update.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4a61d189a3..4e17a1429c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1196,11 +1196,6 @@ function database_update_info() 'user_timezone' => array('VCHAR:100', ''), ), ), - 'drop_columns' => array( - USERS_TABLE => array( - 'user_msnm', - ), - ), ), ); } -- cgit v1.2.1 From bb99a2609d9fcdd3c20ea9c910ae6e05d9da56cd Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 16:00:58 -0600 Subject: [feature/migrations] Replace database_update.php with migrations updater PHPBB3-9737 --- phpBB/install/database_update.php | 2899 ++----------------------------------- 1 file changed, 99 insertions(+), 2800 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 4e17a1429c..7431c96231 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1,39 +1,23 @@ INSTALL.html before attempting to update."); @@ -81,38 +57,36 @@ $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_ro require($phpbb_root_path . 'includes/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_content.' . $phpEx); require($phpbb_root_path . 'includes/functions_container.' . $phpEx); -phpbb_require_updated('includes/functions_content.' . $phpEx, true); - -require($phpbb_root_path . 'includes/functions_admin.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); -phpbb_require_updated('includes/db/db_tools.' . $phpEx); - -// new table constants are separately defined here in case the updater is run -// before the files are updated -if (!defined('LOGIN_ATTEMPT_TABLE')) -{ - define('LOGIN_ATTEMPT_TABLE', $table_prefix . 'login_attempts'); -} -if (!defined('EXT_TABLE')) -{ - define('EXT_TABLE', $table_prefix . 'ext'); -} +// Set PHP error handler to ours +set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); $phpbb_class_loader->register(); -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", ".$phpEx"); -$phpbb_class_loader_ext->register(); -// Set up container -$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx); +// Set up container (must be done here because extensions table may not exist) +$container_extensions = array( + new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), + new phpbb_di_extension_core($phpbb_root_path), +); +$container_passes = array( + new phpbb_di_pass_collection_pass(), + //new phpbb_di_pass_kernel_pass(), +); +$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); -$phpbb_class_loader->set_cache($phpbb_container->get('cache.driver')); -$phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); +// Compile the container +foreach ($container_passes as $pass) +{ + $phpbb_container->addCompilerPass($pass); +} +$phpbb_container->compile(); // set up caching $cache = $phpbb_container->get('cache'); @@ -127,6 +101,16 @@ $db = $phpbb_container->get('dbal.conn'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function +// Grab global variables, re-cache if necessary +$config = $phpbb_container->get('config'); +set_config(null, null, null, $config); +set_config_count(null, null, null, $config); +$orig_version = $config['version']; + +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/common.' . $phpEx); +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/acp/common.' . $phpEx); +include($phpbb_root_path . 'language/' . $config['default_lang'] . '/install.' . $phpEx); + // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) { @@ -144,129 +128,7 @@ else $phpbb_hook = false; } -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); - -// We do not need this any longer, unset for safety purposes -unset($dbpasswd); - -$user->ip = ''; -if ($request->server('REMOTE_ADDR')) -{ - $user->ip = (function_exists('phpbb_ip_normalise')) ? phpbb_ip_normalise($request->server('REMOTE_ADDR')) : $request->server('REMOTE_ADDR'); -} - -$sql = "SELECT config_value - FROM " . CONFIG_TABLE . " - WHERE config_name = 'default_lang'"; -$result = $db->sql_query($sql); -$row = $db->sql_fetchrow($result); -$db->sql_freeresult($result); - -$language = basename(request_var('language', '')); - -if (!$language) -{ - $language = $row['config_value']; -} - -if (!file_exists($phpbb_root_path . 'language/' . $language)) -{ - die('No language found!'); -} - -// And finally, load the relevant language files -include($phpbb_root_path . 'language/' . $language . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $language . '/install.' . $phpEx); - -// Set PHP error handler to ours -//set_error_handler('msg_handler'); - -// Define some variables for the database update -$inline_update = (request_var('type', 0)) ? true : false; - -// To let set_config() calls succeed, we need to make the config array available globally -$config = new phpbb_config_db($db, $phpbb_container->get('cache.driver'), CONFIG_TABLE); -set_config(null, null, null, $config); -set_config_count(null, null, null, $config); - -// Update asset_version -if (isset($config['assets_version'])) -{ - set_config('assets_version', $config['assets_version'] + 1); -} - -// phpbb_db_tools will be taken from new files (under install/update/new) -// if possible, falling back to the board's copy. -$db_tools = new phpbb_db_tools($db, true); - -$database_update_info = database_update_info(); - -$error_ary = array(); -$errored = false; - -$sql = 'SELECT topic_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = 0 - AND topic_type = ' . POST_GLOBAL; -$result = $db->sql_query_limit($sql, 1); -$has_global = (int) $db->sql_fetchfield('topic_id'); -$db->sql_freeresult($result); -$ga_forum_id = request_var('ga_forum_id', 0); - -if ($has_global && !$ga_forum_id) -{ - ?> - - - - - - <?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> - - - - - - -
- - -
-
-
- -
-
- -

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

- -
- -

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

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

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

'; - echo '

' . $lang['ERROR'] . '


'; +
- echo '

' . $lang['FIREBIRD_DBMS_UPDATE_REQUIRED'] . '

'; +

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

'; - echo '

' . $lang['ERROR'] . '


'; - - echo '

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

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

' . $lang['ERROR'] . '


'; - echo '

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

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

- -

- -
-

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

-

-
-

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

-

-
-

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

+echo 'Finished'; -
- - - -

+ $cache->purge(); -

- - - -

- -

" class="button1">

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

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

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

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

  • '; - } - - echo '


' . $lang['SQL_FAILURE_EXPLAIN'] . '

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

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

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

-
-
- -
-
-
- - -
- - - - Date: Sun, 13 Jan 2013 13:23:02 -0600 Subject: [feature/migrations] effectively installed check for migration data PHPBB3-9737 --- phpBB/install/database_update.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f220a1f684..459839f393 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -193,13 +193,22 @@ header('Content-type: text/html; charset=UTF-8'); // End startup code -// Make sure migrations have been installed. If not, install migrations and guess what migrations have been installed +// Make sure migrations have been installed. $db_tools = $phpbb_container->get('dbal.tools'); if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) { - $migrations_installer = new phpbb_db_migration_install(); - $migrations_installer->install($db, $db_tools, $table_prefix, $config['version']); - unset($migrations_installer); + $db_tools->sql_create_table($table_prefix . 'migrations', array( + 'COLUMNS' => array( + 'migration_name' => array('VCHAR', ''), + 'migration_depends_on' => array('TEXT', ''), + 'migration_schema_done' => array('BOOL', 0), + 'migration_data_done' => array('BOOL', 0), + 'migration_data_state' => array('TEXT', ''), + 'migration_start_time' => array('TIMESTAMP', 0), + 'migration_end_time' => array('TIMESTAMP', 0), + ), + 'PRIMARY_KEY' => 'migration_name', + )); } $migrator = $phpbb_container->get('migrator'); -- cgit v1.2.1 From f6a894f07700627b675c2b16aab4714df5819a23 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 23 Feb 2013 16:12:24 -0600 Subject: [feature/migrations] Use the user class for language handling Also localise error messages from the migrator PHBB3-9737 --- phpBB/install/database_update.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 459839f393..4938ef0f87 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -133,9 +133,7 @@ set_config(null, null, null, $config); set_config_count(null, null, null, $config); $orig_version = $config['version']; -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/acp/common.' . $phpEx); -include($phpbb_root_path . 'language/' . $config['default_lang'] . '/install.' . $phpEx); +$user->add_lang(array('common', 'acp/common', 'install', 'migrator')); // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) @@ -157,11 +155,11 @@ else header('Content-type: text/html; charset=UTF-8'); ?> - + -<?php echo $lang['UPDATING_TO_LATEST_STABLE']; ?> +<?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?> @@ -178,12 +176,12 @@ header('Content-type: text/html; charset=UTF-8');
-

+

lang['UPDATING_TO_LATEST_STABLE']; ?>


-

:: sql_layer; ?>
- ::
+

lang['DATABASE_TYPE']; ?> :: sql_layer; ?>
+ lang['PREVIOUS_VERSION']; ?> ::
finished()) } catch (phpbb_db_migration_exception $e) { - echo $e; + echo $e->getLocalisedMessage($user); phpbb_end_update($cache); } @@ -236,8 +234,8 @@ while (!$migrator->finished()) if ((time() - $update_start_time) >= $safe_time_limit) { //echo ''; - echo $lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; - echo '' . $lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache); } @@ -248,6 +246,6 @@ if ($orig_version != $config['version']) add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); } -echo $lang['DATABASE_UPDATE_COMPLETE']; +echo $user->lang['DATABASE_UPDATE_COMPLETE']; phpbb_end_update($cache); -- cgit v1.2.1 From e4f782819968ec44f1dd207dc9de7ec703826d29 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 3 Mar 2013 19:54:22 -0600 Subject: [ticket/11386] Send list of migrations instead of using load_migrations Remove dependency of extension manager for migrator. Keeping load_migrations function for others to use if they desire but requiring the finder be sent to it in order to use it. PHPBB3-11386 --- 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 4938ef0f87..b84f00659c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -210,7 +210,13 @@ if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) } $migrator = $phpbb_container->get('migrator'); -$migrator->load_migrations($phpbb_root_path . 'includes/db/migration/data/'); +$extension_manager = $phpbb_container->get('ext.manager'); +$finder = $extension_manager->get_finder(); + +$migrations = $finder + ->core_path('includes/db/migration/data/') + ->get_classes(); +$migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. $safe_time_limit = (ini_get('max_execution_time') / 2); -- cgit v1.2.1 From 6cad032fbb2ceba892c861f8a2abab82574b12ae Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 3 Mar 2013 20:18:05 -0600 Subject: [ticket/11393] Give more information on database updater PHPBB3-11393 --- phpBB/install/database_update.php | 23 ++++++++++++++++++++++- 1 file changed, 22 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 4938ef0f87..6c8a95a413 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -228,7 +228,28 @@ while (!$migrator->finished()) phpbb_end_update($cache); } - echo $migrator->last_run_migration['name'] . '
'; + $state = array_merge(array( + 'migration_schema_done' => false, + 'migration_data_done' => false, + ), + $migrator->last_run_migration['state'] + ); + + if (isset($migrator->last_run_migration['effectively_installed']) && $migrator->last_run_migration['effectively_installed']) + { + echo $user->lang('MIGRATION_EFFECTIVELY_INSTALLED', $migrator->last_run_migration['name']) . '
'; + } + else + { + if ($state['migration_data_done']) + { + echo $user->lang('MIGRATION_DATA_DONE', $migrator->last_run_migration['name']) . '
'; + } + else if ($state['migration_schema_done']) + { + echo $user->lang('MIGRATION_SCHEMA_DONE', $migrator->last_run_migration['name']) . '
'; + } + } // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) -- cgit v1.2.1 From 7423d48757bec0a81c8d439e911ed32d5af3a775 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 4 Mar 2013 11:25:27 +0100 Subject: [ticket/10714] Get log from container in install, update and download/file PHPBB3-10714 --- 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 4938ef0f87..23048df9fa 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,6 +123,7 @@ $request = $phpbb_container->get('request'); $user = $phpbb_container->get('user'); $auth = $phpbb_container->get('auth'); $db = $phpbb_container->get('dbal.conn'); +$phpbb_log = $phpbb_container->get('log'); // make sure request_var uses this request instance request_var('', 0, false, false, $request); // "dependency injection" for a function -- cgit v1.2.1 From 6704a82bbea45ab53a05c7490c87e46e1c57dd00 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 9 Mar 2013 09:21:31 -0600 Subject: [ticket/11422] Increment assets when database_update is complete PHPBB3-11422 --- phpBB/install/database_update.php | 10 ++++++---- 1 file changed, 6 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 2ecddf49d4..867235e607 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -41,10 +41,12 @@ if (!function_exists('phpbb_require_updated')) } } -function phpbb_end_update($cache) +function phpbb_end_update($cache, $config) { $cache->purge(); + $config->increment('assets_version', 1); + ?>

@@ -232,7 +234,7 @@ while (!$migrator->finished()) { echo $e->getLocalisedMessage($user); - phpbb_end_update($cache); + phpbb_end_update($cache, $config); } $state = array_merge(array( @@ -265,7 +267,7 @@ while (!$migrator->finished()) echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; - phpbb_end_update($cache); + phpbb_end_update($cache, $config); } } @@ -276,4 +278,4 @@ if ($orig_version != $config['version']) echo $user->lang['DATABASE_UPDATE_COMPLETE']; -phpbb_end_update($cache); +phpbb_end_update($cache, $config); -- cgit v1.2.1 From e5d032ca2112ba2c6156718b3fe42128e444a6fd Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 24 Apr 2013 17:37:05 -0500 Subject: [ticket/11335] (more class loader) Make php_ext 'php' not '.php' PHPBB3-11335 --- 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 867235e607..c2b31b4ecd 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -95,7 +95,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", ".$phpEx"); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", "$phpEx"); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) -- cgit v1.2.1 From 9c4553c41f0e0f2c28fb95b5e56886f77cb759ba Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 24 Apr 2013 20:39:24 -0500 Subject: [ticket/11335] Replace "$phpEx" with $phpEx PHPBB3-11335 --- 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 c2b31b4ecd..5ea950bfad 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -95,7 +95,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", "$phpEx"); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) -- cgit v1.2.1 From bb67b079207703568e69bd9d38e8dbe3f33287fc Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 26 May 2013 12:48:49 +0200 Subject: [ticket/11567] Renamed extension_manager variable to avoid fatal error PHPBB3-11567 --- 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 5ea950bfad..6637736bf2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -213,8 +213,8 @@ if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) } $migrator = $phpbb_container->get('migrator'); -$extension_manager = $phpbb_container->get('ext.manager'); -$finder = $extension_manager->get_finder(); +$phpbb_extension_manager = $phpbb_container->get('ext.manager'); +$finder = $phpbb_extension_manager->get_finder(); $migrations = $finder ->core_path('includes/db/migration/data/') -- cgit v1.2.1 From 7383841af55803c2f9dde9549c100bae179f800e Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 26 May 2013 22:39:23 +0200 Subject: [ticket/11569] Fixing link to continue update PHPBB3-11569 --- 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 6637736bf2..eefc50bd04 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -265,7 +265,7 @@ while (!$migrator->finished()) { //echo ''; echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; - echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache, $config); } -- cgit v1.2.1 From c65617479df664f1d4cc03400ba46ca1ad5e95de Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 26 May 2013 23:16:13 +0200 Subject: [ticket/11569] Add parameter to URL and remove comment PHPBB3-11569 --- phpBB/install/database_update.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index eefc50bd04..0da6ab1eb1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -263,9 +263,8 @@ while (!$migrator->finished()) // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) { - //echo ''; echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; - echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache, $config); } -- cgit v1.2.1 From a79e229c25be067b64511ba4df8c3a7ea99b0994 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 29 May 2013 13:27:15 +0200 Subject: [ticket/11569] Add type parameter and fix language variable PHPBB3-11569 --- 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 0da6ab1eb1..be3cc60eaa 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -264,7 +264,7 @@ while (!$migrator->finished()) if ((time() - $update_start_time) >= $safe_time_limit) { echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; - echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache, $config); } -- cgit v1.2.1 From 8b0a6fd2cdf5a2dee53c5485fc7153c5ccde4a6f Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 30 May 2013 21:30:09 +0200 Subject: [ticket/11570] Add link back to update process PHPBB3-11570 --- 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 be3cc60eaa..9f3fd41ef2 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -275,6 +275,17 @@ if ($orig_version != $config['version']) add_log('admin', 'LOG_UPDATE_DATABASE', $orig_version, $config['version']); } -echo $user->lang['DATABASE_UPDATE_COMPLETE']; +echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '
'; + +if ($request->variable('type', 0)) +{ + echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '
'; + echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; +} +else +{ + echo $user->lang['UPDATE_FILES_NOTICE'] . '
'; + echo $user->lang['COMPLETE_LOGIN_TO_BOARD']; +} phpbb_end_update($cache, $config); -- cgit v1.2.1 From ec2cdbed6179f551910759f0e22714d17a683026 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Fri, 31 May 2013 12:18:03 +0200 Subject: [ticket/11570] Fix link and make the notice more conspiciuous PHPBB3-11570 --- 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 9f3fd41ef2..b20ca1e4ea 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -279,12 +279,12 @@ echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '
'; if ($request->variable('type', 0)) { - echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '
'; - echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; + echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '

'; + echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; } else { - echo $user->lang['UPDATE_FILES_NOTICE'] . '
'; + echo '
' . $user->lang['UPDATE_FILES_NOTICE'] . '
'; echo $user->lang['COMPLETE_LOGIN_TO_BOARD']; } -- cgit v1.2.1 From e12fd2fdda76f629060c517aab9812b8565cc696 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:51:55 +0200 Subject: [ticket/11574] Require new files in database_update.php and add a class loader PHPBB3-11574 --- phpBB/install/database_update.php | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 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 b20ca1e4ea..3341c20058 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -41,6 +41,26 @@ if (!function_exists('phpbb_require_updated')) } } +if (!function_exists('phpbb_include_updated')) +{ + function phpbb_include_updated($path, $optional = false) + { + global $phpbb_root_path; + + $new_path = $phpbb_root_path . 'install/update/new/' . $path; + $old_path = $phpbb_root_path . $path; + + if (file_exists($new_path)) + { + include($new_path); + } + else if (!$optional || file_exists($old_path)) + { + include($old_path); + } + } +} + function phpbb_end_update($cache, $config) { $cache->purge(); @@ -82,19 +102,21 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +phpbb_require_updated('includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/functions.' . $phpEx); -require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); +phpbb_require_updated('includes/functions.' . $phpEx); +phpbb_require_updated('includes/functions_content.' . $phpEx); +phpbb_require_updated('includes/functions_container.' . $phpEx); -require($phpbb_root_path . 'includes/constants.' . $phpEx); -require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); +phpbb_require_updated('includes/constants.' . $phpEx); +phpbb_require_updated('includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first +$phpbb_class_loader_new = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}install/update/new/includes/", $phpEx); +$phpbb_class_loader_new->register(); $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); $phpbb_class_loader->register(); -- cgit v1.2.1 From fcf343733887d7d42a3060c48b1a009ae0520467 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Jun 2013 13:58:36 +0200 Subject: [ticket/11574] Add correct language parameter to return links PHPBB3-11574 --- 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 3341c20058..de7f4f202e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -286,7 +286,7 @@ while (!$migrator->finished()) if ((time() - $update_start_time) >= $safe_time_limit) { echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; - echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache, $config); } @@ -302,7 +302,7 @@ echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '
'; if ($request->variable('type', 0)) { echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '

'; - echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; + echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; } else { -- cgit v1.2.1 From 1dea0286a48b4bac6702aad673e13e281690adfb Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 12 Jul 2013 15:40:49 -0400 Subject: [ticket/11574] Use alternate DI config file for updater PHPBB3-11574 --- 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 de7f4f202e..b0e28958ac 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,9 +121,12 @@ $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includ $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) +$other_config_path = $phpbb_root_path . 'install/update/new/config'; +$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path; + $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), + new phpbb_di_extension_core($config_path), ); $container_passes = array( new phpbb_di_pass_collection_pass(), -- cgit v1.2.1 From d6de892ee40579c45259f8c68ba7eef26accc08b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 13 Jul 2013 16:47:15 -0400 Subject: [ticket/11574] Fix various path issues in the updater PHPBB3-11574 --- phpBB/install/database_update.php | 5 ++--- 1 file changed, 2 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 b0e28958ac..51ffdd3c88 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -121,8 +121,8 @@ $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includ $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) -$other_config_path = $phpbb_root_path . 'install/update/new/config'; -$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path; +$other_config_path = $phpbb_root_path . 'install/update/new/config/'; +$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config'; $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), @@ -130,7 +130,6 @@ $container_extensions = array( ); $container_passes = array( new phpbb_di_pass_collection_pass(), - //new phpbb_di_pass_kernel_pass(), ); $phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); -- cgit v1.2.1 From c96f8936c969b3fd441c179cc4ffa8ea75d8f901 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 13 Jul 2013 18:19:21 -0400 Subject: [ticket/11574] Fix table prefix in database updater PHPBB3-11574 --- phpBB/install/database_update.php | 3 ++- 1 file changed, 2 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 51ffdd3c88..5f2d46c7ad 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -25,7 +25,7 @@ if (!function_exists('phpbb_require_updated')) { function phpbb_require_updated($path, $optional = false) { - global $phpbb_root_path; + global $phpbb_root_path, $table_prefix; $new_path = $phpbb_root_path . 'install/update/new/' . $path; $old_path = $phpbb_root_path . $path; @@ -108,6 +108,7 @@ phpbb_require_updated('includes/functions.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx); phpbb_require_updated('includes/functions_container.' . $phpEx); +require($phpbb_root_path . 'config.' . $phpEx); phpbb_require_updated('includes/constants.' . $phpEx); phpbb_require_updated('includes/utf/utf_tools.' . $phpEx); -- cgit v1.2.1 From e6e2a50062eca8b640822b8f616ea4bb23b23566 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 14 Jul 2013 01:28:49 -0400 Subject: [ticket/11574] Add trailing slash for consistency PHPBB3-11574 --- 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 5f2d46c7ad..e0ecc242e1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -123,7 +123,7 @@ $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) $other_config_path = $phpbb_root_path . 'install/update/new/config/'; -$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config'; +$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), -- cgit v1.2.1 From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- 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 b20ca1e4ea..cd6fb7931b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -82,7 +82,7 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files -require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -95,7 +95,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}includes/", $phpEx); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) @@ -217,7 +217,7 @@ $phpbb_extension_manager = $phpbb_container->get('ext.manager'); $finder = $phpbb_extension_manager->get_finder(); $migrations = $finder - ->core_path('includes/db/migration/data/') + ->core_path('phpbb/db/migration/data/') ->get_classes(); $migrator->set_migrations($migrations); -- cgit v1.2.1 From 4311cd65e30b994c5ecd07baf0a508f40d51f155 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 14:29:11 -0400 Subject: [ticket/11700] Instantiate the class loader with namespace rather than prefix PHPBB3-11700 --- 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 cd6fb7931b..19db0a9fc1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -95,7 +95,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); +$phpbb_class_loader = new phpbb_class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) -- cgit v1.2.1 From 5bb08a1ab973ee13237876d11b001c4ed6658892 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 29 Jul 2013 21:30:01 +0200 Subject: [ticket/11574] Change order of files and database update PHPBB3-11574 --- phpBB/install/database_update.php | 3 ++- 1 file changed, 2 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 44cbc74d29..f69f0f6986 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -110,6 +110,7 @@ phpbb_require_updated('includes/functions_container.' . $phpEx); require($phpbb_root_path . 'config.' . $phpEx); phpbb_require_updated('includes/constants.' . $phpEx); +phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx); phpbb_require_updated('includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours @@ -305,7 +306,7 @@ echo $user->lang['DATABASE_UPDATE_COMPLETE'] . '
'; if ($request->variable('type', 0)) { echo $user->lang['INLINE_UPDATE_SUCCESSFUL'] . '

'; - echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; + echo '' . $user->lang['CONTINUE_UPDATE_NOW'] . ''; } else { -- cgit v1.2.1 From 32499c8808bb72812f66ba00e35c5af128a4d4e2 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 30 Jul 2013 01:38:06 +0200 Subject: [ticket/11574] Remove install/udpate/new/ fallback from database_update.php Since we switched the order, everything should be in the normal root by then. PHPBB3-11574 --- phpBB/install/database_update.php | 67 +++++++-------------------------------- 1 file changed, 11 insertions(+), 56 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f69f0f6986..3be5ea659c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -21,46 +21,6 @@ define('IN_INSTALL', true); $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../'; $phpEx = substr(strrchr(__FILE__, '.'), 1); -if (!function_exists('phpbb_require_updated')) -{ - function phpbb_require_updated($path, $optional = false) - { - global $phpbb_root_path, $table_prefix; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - require($new_path); - } - else if (!$optional || file_exists($old_path)) - { - require($old_path); - } - } -} - -if (!function_exists('phpbb_include_updated')) -{ - function phpbb_include_updated($path, $optional = false) - { - global $phpbb_root_path; - - $new_path = $phpbb_root_path . 'install/update/new/' . $path; - $old_path = $phpbb_root_path . $path; - - if (file_exists($new_path)) - { - include($new_path); - } - else if (!$optional || file_exists($old_path)) - { - include($old_path); - } - } -} - function phpbb_end_update($cache, $config) { $cache->purge(); @@ -89,7 +49,7 @@ function phpbb_end_update($cache, $config) exit_handler(); } -phpbb_require_updated('includes/startup.' . $phpEx); +require($phpbb_root_path . 'includes/startup.' . $phpEx); include($phpbb_root_path . 'config.' . $phpEx); if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) @@ -102,33 +62,28 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files -phpbb_require_updated('phpbb/class_loader.' . $phpEx); +require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); -phpbb_require_updated('includes/functions.' . $phpEx); -phpbb_require_updated('includes/functions_content.' . $phpEx); -phpbb_require_updated('includes/functions_container.' . $phpEx); +require($phpbb_root_path . 'includes/functions.' . $phpEx); +require($phpbb_root_path . 'includes/functions_content.' . $phpEx); +require($phpbb_root_path . 'includes/functions_container.' . $phpEx); require($phpbb_root_path . 'config.' . $phpEx); -phpbb_require_updated('includes/constants.' . $phpEx); -phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx); -phpbb_require_updated('includes/utf/utf_tools.' . $phpEx); +require($phpbb_root_path . 'includes/constants.' . $phpEx); +include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); +require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader_new = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx); -$phpbb_class_loader_new->register(); $phpbb_class_loader = new phpbb_class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) -$other_config_path = $phpbb_root_path . 'install/update/new/config/'; -$config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/'; - $container_extensions = array( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($config_path), + new phpbb_di_extension_core($phpbb_root_path . 'config/'), ); $container_passes = array( new phpbb_di_pass_collection_pass(), @@ -289,8 +244,8 @@ while (!$migrator->finished()) // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) { - echo $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '
'; - echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; + echo '
' . $user->lang['DATABASE_UPDATE_NOT_COMPLETED'] . '

'; + echo '' . $user->lang['DATABASE_UPDATE_CONTINUE'] . ''; phpbb_end_update($cache, $config); } -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- 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 19db0a9fc1..74106ca31f 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -95,17 +95,17 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Setup class loader first -$phpbb_class_loader = new phpbb_class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); +$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); // Set up container (must be done here because extensions table may not exist) $container_extensions = array( - new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), - new phpbb_di_extension_core($phpbb_root_path), + new \phpbb\di\extension\config($phpbb_root_path . 'config.' . $phpEx), + new \phpbb\di\extension\core($phpbb_root_path), ); $container_passes = array( - new phpbb_di_pass_collection_pass(), - //new phpbb_di_pass_kernel_pass(), + new \phpbb\di\pass\collection_pass(), + //new \phpbb\di\pass\kernel_pass(), ); $phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); @@ -230,7 +230,7 @@ while (!$migrator->finished()) { $migrator->update(); } - catch (phpbb_db_migration_exception $e) + catch (\phpbb\db\migration\exception $e) { echo $e->getLocalisedMessage($user); -- cgit v1.2.1 From 621e6c93ed5517cedbf7a6a37c35786a1e2f27e8 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 2 Oct 2013 14:27:46 -0500 Subject: [ticket/11883] Report completed data step in migration as "Installing Data" PHPBB3-11883 --- phpBB/install/database_update.php | 16 ++++++++++++---- 1 file changed, 12 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 fa8ec6b6ce..d846884399 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -207,6 +207,8 @@ $safe_time_limit = (ini_get('max_execution_time') / 2); while (!$migrator->finished()) { + $migration_start_time = microtime(true); + try { $migrator->update(); @@ -227,20 +229,26 @@ while (!$migrator->finished()) if (isset($migrator->last_run_migration['effectively_installed']) && $migrator->last_run_migration['effectively_installed']) { - echo $user->lang('MIGRATION_EFFECTIVELY_INSTALLED', $migrator->last_run_migration['name']) . '
'; + echo $user->lang('MIGRATION_EFFECTIVELY_INSTALLED', $migrator->last_run_migration['name']); } else { - if ($state['migration_data_done']) + if ($migrator->last_run_migration['task'] == 'process_data_step' && $state['migration_data_done']) + { + echo $user->lang('MIGRATION_DATA_DONE', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time), (time() - $update_start_time)); + } + else if ($migrator->last_run_migration['task'] == 'process_data_step') { - echo $user->lang('MIGRATION_DATA_DONE', $migrator->last_run_migration['name']) . '
'; + echo $user->lang('MIGRATION_DATA_IN_PROGRESS', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time), (time() - $update_start_time)); } else if ($state['migration_schema_done']) { - echo $user->lang('MIGRATION_SCHEMA_DONE', $migrator->last_run_migration['name']) . '
'; + echo $user->lang('MIGRATION_SCHEMA_DONE', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time), (time() - $update_start_time)); } } + echo "
\n"; + // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) { -- cgit v1.2.1 From 3259bd1196ca2a7f77fe7060e5510813e7844ebd Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 4 Oct 2013 09:23:54 -0500 Subject: [ticket/11883] Only output the migration time, not total PHPBB3-11883 --- 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 d846884399..b79420ab71 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -235,15 +235,15 @@ while (!$migrator->finished()) { if ($migrator->last_run_migration['task'] == 'process_data_step' && $state['migration_data_done']) { - echo $user->lang('MIGRATION_DATA_DONE', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time), (time() - $update_start_time)); + echo $user->lang('MIGRATION_DATA_DONE', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time)); } else if ($migrator->last_run_migration['task'] == 'process_data_step') { - echo $user->lang('MIGRATION_DATA_IN_PROGRESS', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time), (time() - $update_start_time)); + echo $user->lang('MIGRATION_DATA_IN_PROGRESS', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time)); } else if ($state['migration_schema_done']) { - echo $user->lang('MIGRATION_SCHEMA_DONE', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time), (time() - $update_start_time)); + echo $user->lang('MIGRATION_SCHEMA_DONE', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time)); } } -- cgit v1.2.1 From 3e694f784d490eeec2fe71015a16316db4a17cb9 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Thu, 10 Oct 2013 10:05:20 -0500 Subject: [ticket/11902] Set max execution time to 0 in db update PHPBB3-11902 --- 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 b79420ab71..2526657bf9 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -203,7 +203,14 @@ $migrations = $finder $migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. -$safe_time_limit = (ini_get('max_execution_time') / 2); +// No more than 15 seconds so the user isn't sitting and waiting for a very long time +$safe_time_limit = min(15, (ini_get('max_execution_time') / 2)); + +// While we're going to try limit this to half the max execution time, +// we want to try and take additional measures to prevent hitting the +// max execution time (if, say, one migration step takes much longer +// than the max execution time) +set_time_limit(0); while (!$migrator->finished()) { -- cgit v1.2.1 From d062402c4b4a97a7ab4b6d2f316d4d14d8faf70b Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 16 Oct 2013 11:08:33 -0500 Subject: [ticket/11902] Prevent errors if set_time_limit disabled PHPBB3-11902 --- 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 2526657bf9..07a8ed7a1e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -210,7 +210,7 @@ $safe_time_limit = min(15, (ini_get('max_execution_time') / 2)); // we want to try and take additional measures to prevent hitting the // max execution time (if, say, one migration step takes much longer // than the max execution time) -set_time_limit(0); +@set_time_limit(0); while (!$migrator->finished()) { -- cgit v1.2.1 From 405f883437e248801f3c7d15766a035be53f38ce Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 30 Dec 2013 14:24:58 -0600 Subject: [ticket/11902] Use phpbb\php\ini class PHPBB3-11902 --- phpBB/install/database_update.php | 3 ++- 1 file changed, 2 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 07a8ed7a1e..bad51e2fe3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -204,7 +204,8 @@ $migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. // No more than 15 seconds so the user isn't sitting and waiting for a very long time -$safe_time_limit = min(15, (ini_get('max_execution_time') / 2)); +$phpbb_ini = new \phpbb\php\ini(); +$safe_time_limit = min(15, ($phpbb_ini->get_int('max_execution_time') / 2)); // While we're going to try limit this to half the max execution time, // we want to try and take additional measures to prevent hitting the -- cgit v1.2.1 From 7cccd59cdc0f89d13b57c1aacad72dc5687dd453 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sat, 5 Apr 2014 19:48:52 +0200 Subject: [ticket/12193] Fix broken HTML if SQL error occurs during migration PHPBB3-12193 --- 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 bad51e2fe3..6c9eeb6a75 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -169,6 +169,8 @@ header('Content-type: text/html; charset=UTF-8'); Date: Wed, 7 May 2014 02:07:30 +0200 Subject: [ticket/12428] Incorrect from version in database update log entry https://tracker.phpbb.com/browse/PHPBB3-12428 PHPBB3-12428 --- phpBB/install/database_update.php | 10 +++++++++- 1 file changed, 9 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 6c9eeb6a75..91d9a792d7 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -115,7 +115,13 @@ request_var('', 0, false, false, $request); // "dependency injection" for a func $config = $phpbb_container->get('config'); set_config(null, null, null, $config); set_config_count(null, null, null, $config); -$orig_version = $config['version']; + +$orig_version = $this->cache->get('database_update_orig_version'); +if ($orig_version === false) +{ + $orig_version = $config['version']; + $cache->put('database_update_orig_version', $orig_version, 86400); +} $user->add_lang(array('common', 'acp/common', 'install', 'migrator')); @@ -287,4 +293,6 @@ else echo $user->lang['COMPLETE_LOGIN_TO_BOARD']; } +$cache->destroy('database_update_orig_version'); + phpbb_end_update($cache, $config); -- cgit v1.2.1 From 32efd5de7389ed1ee8943b2b167ae427a6847d1f Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 7 May 2014 23:04:41 +0200 Subject: [ticket/12428] Use the database to store the original version number PHPBB3-12428 --- 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 91d9a792d7..b1bfbc1839 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -116,13 +116,13 @@ $config = $phpbb_container->get('config'); set_config(null, null, null, $config); set_config_count(null, null, null, $config); -$orig_version = $this->cache->get('database_update_orig_version'); -if ($orig_version === false) +if (!isset($config['version_update_from'])) { - $orig_version = $config['version']; - $cache->put('database_update_orig_version', $orig_version, 86400); + $config->set('version_update_from', $config['version']); } +$orig_version = $config['version_update_from']; + $user->add_lang(array('common', 'acp/common', 'install', 'migrator')); // Add own hook handler, if present. :o @@ -293,6 +293,6 @@ else echo $user->lang['COMPLETE_LOGIN_TO_BOARD']; } -$cache->destroy('database_update_orig_version'); +$config->delete('version_update_from'); phpbb_end_update($cache, $config); -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/install/database_update.php | 10 +++++++--- 1 file changed, 7 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 b1bfbc1839..cf70019035 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1 From 27f787e5e4e118b77a3e16879d6c684bdaafc303 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 21:25:33 +0200 Subject: [ticket/12594] Update footer credit lines PHPBB3-12594 --- 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 cf70019035..44dbe43cf8 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -41,7 +41,7 @@ function phpbb_end_update($cache, $config)
-- cgit v1.2.1 From 04164affe672be6feea676fd05cf9761bf2e477a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 20 Jun 2014 12:35:42 +0200 Subject: [ticket/12747] Drop support for Firebird PHPBB3-12747 --- 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 44dbe43cf8..72073be880 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -182,7 +182,7 @@ header('Content-type: text/html; charset=UTF-8'); define('IN_DB_UPDATE', true); /** -* @todo firebird/mysql update? +* @todo mysql update? */ // End startup code -- cgit v1.2.1 From e427d203b6aeaa600d71d302551c874df648ee06 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Mon, 23 Jun 2014 20:53:18 -0700 Subject: [ticket/12750] Center installation page copyright text. PHPBB3-12750 --- 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 72073be880..c349d71563 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -41,7 +41,9 @@ function phpbb_end_update($cache, $config)
-- cgit v1.2.1 From ff6e026a403a622bd1aa498bff396a737735faed Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 26 Jun 2014 17:17:35 +0200 Subject: [ticket/12446] Unnecessary db connect inphpbb_bootstrap_enabled_exts PHPBB3-12446 --- 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 c349d71563..63e4e8f4ac 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -176,7 +176,7 @@ header('Content-type: text/html; charset=UTF-8');
-

lang['DATABASE_TYPE']; ?> :: sql_layer; ?>
+

lang['DATABASE_TYPE']; ?> :: get_sql_layer(); ?>
lang['PREVIOUS_VERSION']; ?> ::
Date: Fri, 27 Jun 2014 21:02:20 +0200 Subject: [ticket/12775] Update phpBB/install/database_update.php PHPBB3-12775 --- phpBB/install/database_update.php | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 63e4e8f4ac..481f52de65 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -56,8 +56,15 @@ function phpbb_end_update($cache, $config) } require($phpbb_root_path . 'includes/startup.' . $phpEx); +require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); + +// Setup class loader first +$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); +$phpbb_class_loader->register(); + +$phpbb_config_php_handler = new \phpbb\config_php($phpbb_root_path, $phpEx); +extract($phpbb_config_php_handler->get_all()); -include($phpbb_root_path . 'config.' . $phpEx); if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) { die("Please read: INSTALL.html before attempting to update."); @@ -68,11 +75,8 @@ $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relati $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path; // Include files -require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); - require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -require($phpbb_root_path . 'includes/functions_container.' . $phpEx); require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); @@ -82,26 +86,12 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -// Setup class loader first -$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); -$phpbb_class_loader->register(); - // Set up container (must be done here because extensions table may not exist) -$container_extensions = array( - new \phpbb\di\extension\config($phpbb_root_path . 'config.' . $phpEx), - new \phpbb\di\extension\core($phpbb_root_path . 'config/'), -); -$container_passes = array( - new \phpbb\di\pass\collection_pass(), -); -$phpbb_container = phpbb_create_container($container_extensions, $phpbb_root_path, $phpEx); - -// Compile the container -foreach ($container_passes as $pass) -{ - $phpbb_container->addCompilerPass($pass); -} -$phpbb_container->compile(); +$phpbb_container_factory = new \phpbb\di\container_factory($phpbb_config_php_handler, $phpbb_root_path, $phpEx); +$phpbb_container_factory->set_use_extensions(false); +$phpbb_container_factory->set_use_kernel_pass(false); +$phpbb_container_factory->set_dump_container(false); +$phpbb_container = $phpbb_container_factory->get_container(); // set up caching $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From cefffe07771162da3dba1bbc7febc611b508e7aa Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 27 Jun 2014 21:35:53 +0200 Subject: [ticket/12775] Load the config file before constants.php PHPBB3-12775 --- phpBB/install/database_update.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 481f52de65..869d650b7c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -78,7 +78,6 @@ $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_ro require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); -require($phpbb_root_path . 'config.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); -- cgit v1.2.1 From 40937e21c58399a847d04f23423622b0e1894446 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:29:08 +0200 Subject: [ticket/12775] Renamed to \phpbb\di\container_builder PHPBB3-12775 --- 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 869d650b7c..392bb2ad8c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -86,11 +86,11 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Set up container (must be done here because extensions table may not exist) -$phpbb_container_factory = new \phpbb\di\container_factory($phpbb_config_php_handler, $phpbb_root_path, $phpEx); -$phpbb_container_factory->set_use_extensions(false); -$phpbb_container_factory->set_use_kernel_pass(false); -$phpbb_container_factory->set_dump_container(false); -$phpbb_container = $phpbb_container_factory->get_container(); +$phpbb_container_builder = new \phpbb\di\container_factory($phpbb_config_php_handler, $phpbb_root_path, $phpEx); +$phpbb_container_builder->set_use_extensions(false); +$phpbb_container_builder->set_use_kernel_pass(false); +$phpbb_container_builder->set_dump_container(false); +$phpbb_container = $phpbb_container_builder->get_container(); // set up caching $cache = $phpbb_container->get('cache'); -- cgit v1.2.1 From 2db160ff87fa42ca6c47e580de9bc9d7e5cced49 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:33:31 +0200 Subject: [ticket/12775] Rename config_php to config_php_file PHPBB3-12775 --- 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 392bb2ad8c..2b12b965be 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -62,8 +62,8 @@ require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); -$phpbb_config_php_handler = new \phpbb\config_php($phpbb_root_path, $phpEx); -extract($phpbb_config_php_handler->get_all()); +$phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); +extract($phpbb_config_php_file->get_all()); if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) { @@ -86,7 +86,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Set up container (must be done here because extensions table may not exist) -$phpbb_container_builder = new \phpbb\di\container_factory($phpbb_config_php_handler, $phpbb_root_path, $phpEx); +$phpbb_container_builder = new \phpbb\di\container_factory($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_use_extensions(false); $phpbb_container_builder->set_use_kernel_pass(false); $phpbb_container_builder->set_dump_container(false); -- cgit v1.2.1 From f2e8e928c08809202b1abf5668a46e3d9e735c38 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 00:35:46 +0200 Subject: [ticket/12775] Fix container_builder PHPBB3-12775 --- 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 2b12b965be..fc68235ec8 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -86,7 +86,7 @@ require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); // Set up container (must be done here because extensions table may not exist) -$phpbb_container_builder = new \phpbb\di\container_factory($phpbb_config_php_file, $phpbb_root_path, $phpEx); +$phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx); $phpbb_container_builder->set_use_extensions(false); $phpbb_container_builder->set_use_kernel_pass(false); $phpbb_container_builder->set_dump_container(false); -- cgit v1.2.1 From 15c23e60b8e4b78c68286ae76e03a12b81393159 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 29 Jun 2014 18:39:19 +0200 Subject: [ticket/12775] Update doc blocks PHPBB3-12775 --- phpBB/install/database_update.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fc68235ec8..c54c84cdbc 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -58,7 +58,6 @@ function phpbb_end_update($cache, $config) require($phpbb_root_path . 'includes/startup.' . $phpEx); require($phpbb_root_path . 'phpbb/class_loader.' . $phpEx); -// Setup class loader first $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx); $phpbb_class_loader->register(); -- cgit v1.2.1 From a8e81b6e9f42c3187d7b17c6bb5da052c28944a6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 27 Jul 2014 11:08:13 +0200 Subject: [ticket/12870] Create the migrations table with a method in the migrator PHPBB3-12870 --- phpBB/install/database_update.php | 20 ++------------------ 1 file changed, 2 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 c54c84cdbc..517143792a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -177,25 +177,9 @@ define('IN_DB_UPDATE', true); // End startup code -// Make sure migrations have been installed. -$db_tools = $phpbb_container->get('dbal.tools'); -if (!$db_tools->sql_table_exists($table_prefix . 'migrations')) -{ - $db_tools->sql_create_table($table_prefix . 'migrations', array( - 'COLUMNS' => array( - 'migration_name' => array('VCHAR', ''), - 'migration_depends_on' => array('TEXT', ''), - 'migration_schema_done' => array('BOOL', 0), - 'migration_data_done' => array('BOOL', 0), - 'migration_data_state' => array('TEXT', ''), - 'migration_start_time' => array('TIMESTAMP', 0), - 'migration_end_time' => array('TIMESTAMP', 0), - ), - 'PRIMARY_KEY' => 'migration_name', - )); -} - $migrator = $phpbb_container->get('migrator'); +$migrator->create_migrations_table(); + $phpbb_extension_manager = $phpbb_container->get('ext.manager'); $finder = $phpbb_extension_manager->get_finder(); -- cgit v1.2.1 From 336d7cd41a7c77b02c53a8c1752a1034846f7934 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 9 Aug 2014 12:04:30 +0200 Subject: [ticket/12940] Remove unused use statements. PHPBB3-12940 --- phpBB/install/database_update.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 517143792a..6a91033dbb 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -13,10 +13,6 @@ $update_start_time = time(); -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - /** * @ignore */ -- cgit v1.2.1 From a093c28d1adf18d10208f05fca18e2e653f03b80 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 10 Sep 2014 12:01:01 +0200 Subject: [ticket/12963] Fix the list of migrations in database_update.php Without this patch the finder grab all the class available in the ext folder and not only the migrations. This change is backported for the one done before to the cli tool db:migrate. (see the commit 3420f8f3201ac337434f73ee00bda6df7b378212) PHPBB3-12963 --- 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 6a91033dbb..7299c0aa2a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -181,7 +181,17 @@ $finder = $phpbb_extension_manager->get_finder(); $migrations = $finder ->core_path('phpbb/db/migration/data/') + ->extension_directory('/migrations') ->get_classes(); + +// @deprecated to be removed in 3.2 final +$migrations_deprecated = $phpbb_extension_manager + ->get_finder() + ->extension_directory('/migrations') + ->get_classes(); + +$migrations = array_merge($migrations, $migrations_deprecated); + $migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. -- cgit v1.2.1 From 72ee4b3a7c4fca67cb226dab3ed27a8afa903144 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 10 Sep 2014 12:08:13 +0200 Subject: [ticket/12963] Load extensions migrations from /migration PHPBB3-12963 --- 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 7299c0aa2a..f0091ac995 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -177,11 +177,11 @@ $migrator = $phpbb_container->get('migrator'); $migrator->create_migrations_table(); $phpbb_extension_manager = $phpbb_container->get('ext.manager'); -$finder = $phpbb_extension_manager->get_finder(); -$migrations = $finder +$migrations = $phpbb_extension_manager + ->get_finder() ->core_path('phpbb/db/migration/data/') - ->extension_directory('/migrations') + ->extension_directory('/migration') ->get_classes(); // @deprecated to be removed in 3.2 final -- cgit v1.2.1 From 8b16d3141396a11db3ab4ade49af91f2477f5fb6 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 16 Sep 2014 20:18:10 +0200 Subject: [ticket/12963] Edit deprecation message PHPBB3-12963 --- 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 f0091ac995..5cf01fec79 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -184,7 +184,7 @@ $migrations = $phpbb_extension_manager ->extension_directory('/migration') ->get_classes(); -// @deprecated to be removed in 3.2 final +// @deprecated 3.1.0-RC4 (To be removed: 3.2.0) $migrations_deprecated = $phpbb_extension_manager ->get_finder() ->extension_directory('/migrations') -- cgit v1.2.1 From c220fa89a1bf5652df6512ad78eb9ba550fe465e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 18 Sep 2014 10:42:21 +0200 Subject: [ticket/12963] Revert back to "migrations" folder name for extensions The issues that can be created with the name change are just too much PHPBB3-12963 --- phpBB/install/database_update.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 5cf01fec79..8016ff349b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -181,17 +181,9 @@ $phpbb_extension_manager = $phpbb_container->get('ext.manager'); $migrations = $phpbb_extension_manager ->get_finder() ->core_path('phpbb/db/migration/data/') - ->extension_directory('/migration') - ->get_classes(); - -// @deprecated 3.1.0-RC4 (To be removed: 3.2.0) -$migrations_deprecated = $phpbb_extension_manager - ->get_finder() ->extension_directory('/migrations') ->get_classes(); -$migrations = array_merge($migrations, $migrations_deprecated); - $migrator->set_migrations($migrations); // What is a safe limit of execution time? Half the max execution time should be safe. -- cgit v1.2.1 From 56d7c2c6ed3e5924aeced53a163bfd1aa8288034 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 14 Oct 2014 17:58:29 +0200 Subject: [ticket/13126] Improve the feedback when running the migrations PHPBB3-13126 --- phpBB/install/database_update.php | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 8016ff349b..960b3c3fb3 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -174,6 +174,19 @@ define('IN_DB_UPDATE', true); // End startup code $migrator = $phpbb_container->get('migrator'); +$migrator->set_output_handler( + new \phpbb\db\migrator_output_handler( + function($message, $verbosity) use ($user) + { + if ($verbosity <= \phpbb\db\migrator_output_handler::VERBOSITY_NORMAL) + { + $final_message = call_user_func_array(array($user, 'lang'), $message); + echo $final_message . "
\n"; + } + } + ) +); + $migrator->create_migrations_table(); $phpbb_extension_manager = $phpbb_container->get('ext.manager'); @@ -199,8 +212,6 @@ $safe_time_limit = min(15, ($phpbb_ini->get_int('max_execution_time') / 2)); while (!$migrator->finished()) { - $migration_start_time = microtime(true); - try { $migrator->update(); @@ -219,28 +230,6 @@ while (!$migrator->finished()) $migrator->last_run_migration['state'] ); - if (isset($migrator->last_run_migration['effectively_installed']) && $migrator->last_run_migration['effectively_installed']) - { - echo $user->lang('MIGRATION_EFFECTIVELY_INSTALLED', $migrator->last_run_migration['name']); - } - else - { - if ($migrator->last_run_migration['task'] == 'process_data_step' && $state['migration_data_done']) - { - echo $user->lang('MIGRATION_DATA_DONE', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time)); - } - else if ($migrator->last_run_migration['task'] == 'process_data_step') - { - echo $user->lang('MIGRATION_DATA_IN_PROGRESS', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time)); - } - else if ($state['migration_schema_done']) - { - echo $user->lang('MIGRATION_SCHEMA_DONE', $migrator->last_run_migration['name'], (microtime(true) - $migration_start_time)); - } - } - - echo "
\n"; - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) { -- cgit v1.2.1 From 58075e25e8173ec663e4e8908d1963b1947a225b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 16 Oct 2014 01:34:23 +0200 Subject: [ticket/13126] Extends migrator_output_handler instead of using a closure PHPBB3-13126 --- phpBB/install/database_update.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 960b3c3fb3..5a2287c9e1 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -174,18 +174,7 @@ define('IN_DB_UPDATE', true); // End startup code $migrator = $phpbb_container->get('migrator'); -$migrator->set_output_handler( - new \phpbb\db\migrator_output_handler( - function($message, $verbosity) use ($user) - { - if ($verbosity <= \phpbb\db\migrator_output_handler::VERBOSITY_NORMAL) - { - $final_message = call_user_func_array(array($user, 'lang'), $message); - echo $final_message . "
\n"; - } - } - ) -); +$migrator->set_output_handler(new \phpbb\db\html_migrator_output_handler($user)); $migrator->create_migrations_table(); -- cgit v1.2.1 From 516bd9ea51a2c2b908eb1f62bddaba967559db4a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 24 Oct 2014 13:20:40 -0700 Subject: [ticket/13211] Add log wrapper for writing database updater to log file PHPBB3-13211 --- 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 5a2287c9e1..80fd40a944 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -174,7 +174,7 @@ define('IN_DB_UPDATE', true); // End startup code $migrator = $phpbb_container->get('migrator'); -$migrator->set_output_handler(new \phpbb\db\html_migrator_output_handler($user)); +$migrator->set_output_handler(new \phpbb\db\log_wrapper_migrator_output_handler($user, new \phpbb\db\html_migrator_output_handler($user), $phpbb_root_path . 'store/migrations_' . time() . '.log')); $migrator->create_migrations_table(); -- cgit v1.2.1 From 244d171cb035f0229ad2a06d01062ca809a72025 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 24 Mar 2016 16:07:07 +0100 Subject: [ticket/14136] Add back X-UA-Compatible meta tag This was previously removed without needing to. Adding it back to force users to not emulate the page for previous versions of IE. The imagetoolbar http-equiv tag was not restored as IE does not contain that anymore since IE7. Also, the chome=1 has been removed from the X-UA-Compatible content as ChromeFrame does not receive any further updates since 2014 and is potentially broken. PHPBB3-14136 --- 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 80fd40a944..42cc27e60b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -138,6 +138,7 @@ header('Content-type: text/html; charset=UTF-8'); + <?php echo $user->lang['UPDATING_TO_LATEST_STABLE']; ?> -- cgit v1.2.1 From 68eba86309a63889ca8f8de1ce4ce6600d356f42 Mon Sep 17 00:00:00 2001 From: Richard McGirr Date: Mon, 4 Apr 2016 07:18:21 -0400 Subject: [ticket/14408] Remove span tags from file PHPBB3-14408 --- phpBB/install/database_update.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 42cc27e60b..0ea6eeffd7 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -31,7 +31,6 @@ function phpbb_end_update($cache, $config)

- @@ -153,7 +152,6 @@ header('Content-type: text/html; charset=UTF-8');
-
-- cgit v1.2.1 From b00a39b9adeca86f2c2777a74d6f4f8325ee7743 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 11 Aug 2016 15:37:53 +0200 Subject: [ticket/14742] Make $last_run_migration protected PHPBB3-14742 --- phpBB/install/database_update.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'phpBB/install/database_update.php') diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0ea6eeffd7..f367ae1fc0 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -211,13 +211,6 @@ while (!$migrator->finished()) phpbb_end_update($cache, $config); } - $state = array_merge(array( - 'migration_schema_done' => false, - 'migration_data_done' => false, - ), - $migrator->last_run_migration['state'] - ); - // Are we approaching the time limit? If so we want to pause the update and continue after refreshing if ((time() - $update_start_time) >= $safe_time_limit) { -- cgit v1.2.1