aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install/database_update.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/install/database_update.php')
-rw-r--r--phpBB/install/database_update.php66
1 files changed, 64 insertions, 2 deletions
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index ca94bf03a9..3ad01f62bb 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -894,10 +894,10 @@ function change_database_data(&$no_updates, $version)
set_config('captcha_gd_wave', 0);
set_config('captcha_gd_3d_noise', 1);
set_config('captcha_gd_fonts', 1);
- set_config('confirm_refresh', 1);
-
+ set_config('confirm_refresh', 1);
+ // Hash old MD5 passwords
$sql = 'SELECT user_id, user_password
FROM ' . USERS_TABLE . '
WHERE user_pass_convert = 1';
@@ -916,11 +916,73 @@ function change_database_data(&$no_updates, $version)
}
$db->sql_freeresult($result);
+ // Adjust bot entry
$sql = 'UPDATE ' . BOTS_TABLE . "
SET bot_agent = 'ichiro/'
WHERE bot_agent = 'ichiro/2'";
_sql($sql, $errored, $error_ary);
+ // Before we are able to add a unique key to auth_option, we need to remove duplicate entries
+
+ // We get duplicate entries first
+ $sql = 'SELECT auth_option
+ FROM ' . ACL_OPTIONS_TABLE . '
+ GROUP BY auth_option
+ HAVING COUNT(*) >= 1';
+ $result = $db->sql_query($sql);
+
+ $auth_options = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $auth_options[] = $row['auth_option'];
+ }
+ $db->sql_freeresult($result);
+
+ // Remove specific auth options
+ if (!empty($auth_options))
+ {
+ foreach ($auth_options as $option)
+ {
+ // Select auth_option_ids... the largest id will be preserved
+ $sql = 'SELECT auth_option_id
+ FROM ' . ACL_OPTIONS_TABLE . "
+ WHERE auth_option = '" . $db->sql_escape($option) . "'
+ ORDER BY auth_option_id DESC";
+ $result = $db->sql_query_limit($sql, 0, 1);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ // Ok, remove this auth option...
+ _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
+ _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
+ _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
+ _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
+ }
+ $db->sql_freeresult($result);
+ }
+ }
+
+ // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one.
+ $changes = array(
+ 'drop_keys' => array(
+ ACL_OPTIONS_TABLE => array('auth_option'),
+ ),
+ 'add_unique_index' => array(
+ ACL_OPTIONS_TABLE => array(
+ 'auth_option' => array('auth_option'),
+ ),
+ ),
+ );
+
+ global $db_tools;
+
+ $statements = $db_tools->perform_schema_changes($changes);
+
+ foreach ($statements as $sql)
+ {
+ _sql($sql, $errored, $error_ary);
+ }
+
$no_updates = false;
break;