From 15b2933fd9867d15bd81b3fd86487837d9e3c6fe Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Mon, 12 Mar 2007 21:43:07 +0000 Subject: [PATCH] remove user with empty username_clean... git-svn-id: file:///svn/phpbb/trunk@7180 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_convert.php | 26 ++++++++++++++++++++ phpBB/install/convertors/convert_phpbb20.php | 6 ++++- phpBB/install/install_install.php | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 294390af69..88ea955a42 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -2002,6 +2002,32 @@ function fix_empty_primary_groups() $db->sql_freeresult($result); } +/** +* Cleanly remove invalid user entries after converting the users table... +*/ +function remove_invalid_users() +{ + global $convert, $db; + + // username_clean is UNIQUE + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = ''"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + if (!function_exists('user_delete')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + user_delete('remove', $row['user_id']); + } +} + function convert_bbcode($message, $convert_size = true, $extended_bbcodes = false) { static $orig, $repl, $origx, $replx, $str_from, $str_to; diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index eb7c106d73..132c4fedb4 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -821,7 +821,11 @@ if (!$get_info) array('target', 'DELETE FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS), array('target', $convert->truncate_statement . BOTS_TABLE) ), - + + 'execute_last' => ' + remove_invalid_users(); + ', + array('user_id', 'users.user_id', 'phpbb_user_id'), array('', 'users.user_id AS poster_id', 'phpbb_user_id'), array('user_type', 'users.user_active', 'set_user_type'), diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 392f70dec9..eeb0bd8491 100755 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -1669,7 +1669,7 @@ class install_install extends module if (!function_exists('user_add')) { - include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx); + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); } foreach ($this->bot_list as $bot_name => $bot_ary)