From 306581d905c508e6d4a7bafebce1b90dbedbbf4a Mon Sep 17 00:00:00 2001
From: Meik Sievertsen
Date: Tue, 24 Jul 2007 15:17:47 +0000
Subject: [PATCH] this should work fine now...
git-svn-id: file:///svn/phpbb/trunk@7937 89ea8834-ac86-4346-8a33-228a782c2dd0
---
phpBB/includes/db/dbal.php | 2 +-
phpBB/install/database_update.php | 66 +++++++++++++++++++++++--------
phpBB/language/en/install.php | 3 ++
3 files changed, 53 insertions(+), 18 deletions(-)
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index aa8adda86c..79a2d6bf35 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -534,7 +534,7 @@ class dbal
// Show complete SQL error and path to administrators only
// Additionally show complete error on installation or if extended debug mode is enabled
// The DEBUG_EXTRA constant is for development only!
- if (isset($auth) && ($auth->acl_get('a_') || defined('IN_INSTALL') || defined('DEBUG_EXTRA')))
+ if ((isset($auth) && $auth->acl_get('a_')) || defined('IN_INSTALL') || defined('DEBUG_EXTRA'))
{
// Print out a nice backtrace...
$backtrace = get_backtrace();
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 082d9a530e..74ffdc8c8a 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -1,14 +1,14 @@
+ if (!isset($lang['CLEANING_USERNAMES']))
+ {
+ $lang['CLEANING_USERNAMES'] = 'Cleaning usernames';
+ }
- Clean Usernames
+ if (!isset($lang['LONG_SCRIPT_EXECUTION']))
+ {
+ $lang['LONG_SCRIPT_EXECUTION'] = 'Please note that this can take a while... Please do not stop the script.';
+ }
+
+?>
+
+
+
- Please note that this can take a while... Please do not stop the script.
-*/
+
+
+ ::
+
+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 ...
@@ -621,14 +639,18 @@ if (version_compare($current_version, '3.0.RC3', '<='))
// 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) . '\'
- AND user_id > ' . $user_id . '
- ORDER BY user_id';
+ 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
@@ -672,6 +694,13 @@ if (version_compare($current_version, '3.0.RC3', '<='))
}
}
}
+
+ if (($echos % 1000) == 0)
+ {
+ echo '.';
+ flush();
+ }
+ $echos++;
}
$db->sql_freeresult($result);
@@ -730,7 +759,8 @@ if (version_compare($current_version, '3.0.RC3', '<='))
// for the admin: keep name, change name (with text input) or delete user
$u_action = "database_update.$phpEx?language=$language&type=$inline_update";
?>
-
+
+
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;
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET username_clean = ' {$user_id}'
+ WHERE user_id = {$user_id}";
$db->sql_query($sql);
}
}
diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php
index c1ed96580b..1a932369a8 100755
--- a/phpBB/language/en/install.php
+++ b/phpBB/language/en/install.php
@@ -58,6 +58,7 @@ $lang = array_merge($lang, array(
'CHANGE' => 'Change',
'CHECK_TABLE_PREFIX' => 'Please check your table prefix and try again.',
'CLEAN_VERIFY' => 'Cleaning up and verifying the final structure',
+ 'CLEANING_USERNAMES' => 'Cleaning usernames',
'COLLIDING_CLEAN_USERNAME' => '%s is the clean username for:',
'COLLIDING_USERNAMES_FOUND' => 'Colliding usernames were found on your old board. In order to complete the conversion please delete or rename these users so that there is only one user on your old board for each clean username.',
'COLLIDING_USER' => 'ยป user id: %d username: %s (%d posts)',
@@ -245,6 +246,8 @@ $lang = array_merge($lang, array(
'INST_ERR_USER_TOO_SHORT' => 'The username you entered is too short. The minimum length is 3 characters.',
'INVALID_PRIMARY_KEY' => 'Invalid primary key : %s',
+ 'LONG_SCRIPT_EXECUTION' => 'Please note that this can take a while... Please do not stop the script.',
+
// mbstring
'MBSTRING_CHECK' => 'mbstring extension check',
'MBSTRING_CHECK_EXPLAIN' => 'Required - mbstring is a PHP extension that provides multibyte string functions. Certain features of mbstring are not compatible with phpBB and must be disabled.',