diff options
| author | Meik Sievertsen <acydburn@phpbb.com> | 2008-12-04 14:53:04 +0000 |
|---|---|---|
| committer | Meik Sievertsen <acydburn@phpbb.com> | 2008-12-04 14:53:04 +0000 |
| commit | a41e8c101d3211b915cc065b27f494aa3bb8a741 (patch) | |
| tree | 1184f45b460e13ee58a20f24bdc47c6b7d4da82a /phpBB/includes | |
| parent | 23d9700f0737fdd547bda3e7d910300be4127120 (diff) | |
| download | forums-a41e8c101d3211b915cc065b27f494aa3bb8a741.tar forums-a41e8c101d3211b915cc065b27f494aa3bb8a741.tar.gz forums-a41e8c101d3211b915cc065b27f494aa3bb8a741.tar.bz2 forums-a41e8c101d3211b915cc065b27f494aa3bb8a741.tar.xz forums-a41e8c101d3211b915cc065b27f494aa3bb8a741.zip | |
fix postcount resync for situations where low and high post ids are higher than step value, resulting in users having 0 posts. (Bug #38195)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9171 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/acp/acp_main.php | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index d100c49381..a558fe6712 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -185,12 +185,36 @@ class acp_main } // Resync post counts - $start = 0; - $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; + $start = $max_post_id = 0; + + // Find the maximum post ID, we can only stop the cycle when we've reached it + $sql = 'SELECT MAX(forum_last_post_id) as max_post_id + FROM ' . FORUMS_TABLE; + $result = $db->sql_query($sql); + $max_post_id = (int) $db->sql_fetchfield('max_post_id'); + $db->sql_freeresult($result); + + // No maximum post id? :o + if (!$max_post_id) + { + $sql = 'SELECT MAX(post_id) + FROM ' . POSTS_TABLE; + $result = $db->sql_query($sql); + $max_post_id = (int) $db->sql_fetchfield('max_post_id'); + $db->sql_freeresult($result); + } + // Still no maximum post id? Then we are finished + if (!$max_post_id) + { + add_log('admin', 'LOG_RESYNC_POSTCOUNTS'); + break; + } + + $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000; $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_posts = 0'); - do + while ($start < $max_post_id) { $sql = 'SELECT COUNT(post_id) AS num_posts, poster_id FROM ' . POSTS_TABLE . ' @@ -207,16 +231,11 @@ class acp_main $db->sql_query($sql); } while ($row = $db->sql_fetchrow($result)); - - $start += $step; - } - else - { - $start = 0; } $db->sql_freeresult($result); + + $start += $step; } - while ($start); add_log('admin', 'LOG_RESYNC_POSTCOUNTS'); |
