aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/viewtopic.php
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2006-09-26 19:59:41 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2006-09-26 19:59:41 +0000
commit734492958eaa2f193db304fd5d4cf050390eff1a (patch)
tree37f19f2dd765fd45024bcd9180e729b79c9a430a /phpBB/viewtopic.php
parente339c36ec035520ce6f3ae4c8ad69bff35eabde6 (diff)
downloadforums-734492958eaa2f193db304fd5d4cf050390eff1a.tar
forums-734492958eaa2f193db304fd5d4cf050390eff1a.tar.gz
forums-734492958eaa2f193db304fd5d4cf050390eff1a.tar.bz2
forums-734492958eaa2f193db304fd5d4cf050390eff1a.tar.xz
forums-734492958eaa2f193db304fd5d4cf050390eff1a.zip
These changes should let olympus scale a little bit better.
i haven't adjusted the schemas but added the details to create_schema_files - david is able to build them then in line with his changes. :) git-svn-id: file:///svn/phpbb/trunk@6411 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r--phpBB/viewtopic.php39
1 files changed, 27 insertions, 12 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index a22aedf651..534e72780d 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -238,19 +238,34 @@ if (!$topic_data)
// This is for determining where we are (page)
if ($post_id)
{
- /**
- * @todo adjust for using post_time? Generally adjust query... it is not called very often though
- */
- $sql = 'SELECT COUNT(post_id) AS prev_posts
- FROM ' . POSTS_TABLE . "
- WHERE topic_id = {$topic_data['topic_id']}
- " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND post_approved = 1' : '') . "
- AND " . (($sort_dir == 'd') ? "post_id >= $post_id" : "post_id <= $post_id");
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id'])
+ {
+ $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';
+
+ if ($sort_dir == $check_sort)
+ {
+ $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] + 1 : $topic_data['topic_replies'] + 1;
+ }
+ else
+ {
+ $topic_data['prev_posts'] = 1;
+ }
+ }
+ else
+ {
+ $sql = 'SELECT COUNT(p1.post_id) AS prev_posts
+ FROM ' . POSTS_TABLE . ' p1, ' . POSTS_TABLE . " p2
+ WHERE p1.topic_id = {$topic_data['topic_id']}
+ AND p2.post_id = {$post_id}
+ " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p1.post_approved = 1' : '') . '
+ AND ' . (($sort_dir == 'd') ? 'p1.post_time >= p2.post_time' : 'p1.post_time <= p2.post_time');
- $topic_data['prev_posts'] = $row['prev_posts'];
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ $topic_data['prev_posts'] = $row['prev_posts'];
+ }
}
$forum_id = (int) $topic_data['forum_id'];