mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Reduce user post count when deleting topics ... this could be troublesome on big topics with lots of posters ...
git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@2729 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
8054ef2b71
commit
df848a295c
1 changed files with 30 additions and 1 deletions
|
@ -211,10 +211,39 @@ switch( $mode )
|
||||||
$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . $topics[$i];
|
$topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . $topics[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT poster_id, COUNT(post_id) AS posts
|
||||||
|
FROM " . POSTS_TABLE . "
|
||||||
|
WHERE topic_id IN ($topic_id_sql)
|
||||||
|
GROUP BY poster_id";
|
||||||
|
if ( !($result = $db->sql_query($sql)) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
$count_sql = array();
|
||||||
|
while ( $row = $db->sql_fetchrow($result) )
|
||||||
|
{
|
||||||
|
$count_sql[] = "UPDATE " . USERS_TABLE . "
|
||||||
|
SET user_posts = user_posts - " . $row['posts'] . "
|
||||||
|
WHERE user_id = " . $row['poster_id'];
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
if ( sizeof($count_sql) )
|
||||||
|
{
|
||||||
|
for($i = 0; $i < sizeof($count_sql); $i++)
|
||||||
|
{
|
||||||
|
if ( !$db->sql_query($count_sql[$i]) )
|
||||||
|
{
|
||||||
|
message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "SELECT post_id
|
$sql = "SELECT post_id
|
||||||
FROM " . POSTS_TABLE . "
|
FROM " . POSTS_TABLE . "
|
||||||
WHERE topic_id IN ($topic_id_sql)";
|
WHERE topic_id IN ($topic_id_sql)";
|
||||||
if ( !$result = $db->sql_query($sql) )
|
if ( !($result = $db->sql_query($sql)) )
|
||||||
{
|
{
|
||||||
message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
|
message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue