mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[feature/prune-users] Call sql_is_set for user ids once in user_delete.
PHPBB3-9622
This commit is contained in:
parent
33c7bb4ec3
commit
44f524aa50
1 changed files with 9 additions and 7 deletions
|
@ -345,9 +345,11 @@ function user_delete($mode, $user_ids, $retain_username = true)
|
||||||
$user_ids = array($user_ids);
|
$user_ids = array($user_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user_id_sql = $db->sql_in_set('user_id', $user_ids);
|
||||||
|
|
||||||
$sql = 'SELECT *
|
$sql = 'SELECT *
|
||||||
FROM ' . USERS_TABLE . '
|
FROM ' . USERS_TABLE . '
|
||||||
WHERE ' . $db->sql_in_set('user_id', $user_ids);
|
WHERE ' . $user_id_sql;
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
|
@ -418,7 +420,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove reports
|
// Remove reports
|
||||||
$db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE ' . $db->sql_in_set('user_id', $user_ids));
|
$db->sql_query('DELETE FROM ' . REPORTS_TABLE . ' WHERE ' . $user_id_sql);
|
||||||
|
|
||||||
// Some things need to be done in the loop (if the query changes based
|
// Some things need to be done in the loop (if the query changes based
|
||||||
// on which user is currently being deleted)
|
// on which user is currently being deleted)
|
||||||
|
@ -529,7 +531,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
|
||||||
foreach ($table_ary as $table)
|
foreach ($table_ary as $table)
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM $table
|
$sql = "DELETE FROM $table
|
||||||
WHERE " . $db->sql_in_set('user_id', $user_ids);
|
WHERE " . $user_id_sql;
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,18 +539,18 @@ function user_delete($mode, $user_ids, $retain_username = true)
|
||||||
|
|
||||||
// Delete user log entries about this user
|
// Delete user log entries about this user
|
||||||
$sql = 'DELETE FROM ' . LOG_TABLE . '
|
$sql = 'DELETE FROM ' . LOG_TABLE . '
|
||||||
WHERE ' . $db->sql_in_set('user_id', $user_ids); //reportee_id = ' . $user_id;
|
WHERE ' . $user_id_sql; //reportee_id = ' . $user_id;
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
// Change user_id to anonymous for this users triggered events
|
// Change user_id to anonymous for this users triggered events
|
||||||
$sql = 'UPDATE ' . LOG_TABLE . '
|
$sql = 'UPDATE ' . LOG_TABLE . '
|
||||||
SET user_id = ' . ANONYMOUS . '
|
SET user_id = ' . ANONYMOUS . '
|
||||||
WHERE ' . $db->sql_in_set('user_id', $user_ids); //user_id = ' . $user_id;
|
WHERE ' . $user_id_sql; //user_id = ' . $user_id;
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
// Delete the user_id from the zebra table
|
// Delete the user_id from the zebra table
|
||||||
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
|
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
|
||||||
WHERE ' . $db->sql_in_set('user_id', $user_ids) . //user_id = ' . $user_id . '
|
WHERE ' . $user_id_sql . //user_id = ' . $user_id . '
|
||||||
' OR ' . $db->sql_in_set('zebra_id', $user_ids);
|
' OR ' . $db->sql_in_set('zebra_id', $user_ids);
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
@ -591,7 +593,7 @@ function user_delete($mode, $user_ids, $retain_username = true)
|
||||||
|
|
||||||
// Delete all to-information
|
// Delete all to-information
|
||||||
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
|
$sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
|
||||||
WHERE ' . $db->sql_in_set('user_id', $user_ids);
|
WHERE ' . $user_id_sql;
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
// Set the remaining author id to anonymous - this way users are still able to read messages from users being removed
|
// Set the remaining author id to anonymous - this way users are still able to read messages from users being removed
|
||||||
|
|
Loading…
Add table
Reference in a new issue