aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2008-09-24 13:58:50 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2008-09-24 13:58:50 +0000
commit10d3191198064e0a37afcf88a92082990981fbd5 (patch)
tree4b8920e26f03f7db392480392c050d5eb865113a /phpBB
parent9f9a89c78ef8998dea9d611a21889a09b6e4952f (diff)
downloadforums-10d3191198064e0a37afcf88a92082990981fbd5.tar
forums-10d3191198064e0a37afcf88a92082990981fbd5.tar.gz
forums-10d3191198064e0a37afcf88a92082990981fbd5.tar.bz2
forums-10d3191198064e0a37afcf88a92082990981fbd5.tar.xz
forums-10d3191198064e0a37afcf88a92082990981fbd5.zip
better query for syncing post counts. Thanks to BartVB for this. ;)
git-svn-id: file:///svn/phpbb/trunk@8933 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/acp/acp_main.php23
1 files changed, 11 insertions, 12 deletions
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php
index a279f2b489..e122273284 100644
--- a/phpBB/includes/acp/acp_main.php
+++ b/phpBB/includes/acp/acp_main.php
@@ -185,30 +185,29 @@ class acp_main
// Resync post counts
$start = 0;
+ $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;
+
+ $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0');
do
{
- $sql = 'SELECT COUNT(p.post_id) AS num_posts, u.user_id
- FROM ' . USERS_TABLE . ' u
- LEFT JOIN ' . POSTS_TABLE . ' p ON (u.user_id = p.poster_id AND p.post_postcount = 1 AND p.post_approved = 1)
- GROUP BY u.user_id
- ORDER BY u.user_id ASC';
- $result = $db->sql_query_limit($sql, 200, $start);
+ $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
+ FROM ' . POSTS_TABLE . '
+ WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
+ AND post_postcount = 1 AND post_approved = 1
+ GROUP BY poster_id';
+ $result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
- $i = 0;
-
do
{
- $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = {$row['num_posts']} WHERE user_id = {$row['user_id']}";
+ $sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
$db->sql_query($sql);
-
- $i++;
}
while ($row = $db->sql_fetchrow($result));
- $start = ($i < 200) ? 0 : $start + 200;
+ $start += $step;
}
else
{