diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2011-04-08 14:44:21 +0200 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2011-07-30 23:46:53 -0400 |
commit | bb7e8bb4244eece7dbbe2a81216b9da976f6c0e9 (patch) | |
tree | 19ce1c919d6c58a0ea867a5277839a076bed56d7 | |
parent | edb745e9516b236c370b9d1213598dfac69860c4 (diff) | |
download | forums-bb7e8bb4244eece7dbbe2a81216b9da976f6c0e9.tar forums-bb7e8bb4244eece7dbbe2a81216b9da976f6c0e9.tar.gz forums-bb7e8bb4244eece7dbbe2a81216b9da976f6c0e9.tar.bz2 forums-bb7e8bb4244eece7dbbe2a81216b9da976f6c0e9.tar.xz forums-bb7e8bb4244eece7dbbe2a81216b9da976f6c0e9.zip |
[ticket/9976] Fix link to post when two posts have the same post_time.
When two posts have the same post_time, a link to the first post being on
page 1, leads you to the second post with the same timestamp on page two.
So in case the post_times are equal, we need to use the post_id to correctly
order the posts.
PHPBB3-9976
-rw-r--r-- | phpBB/viewtopic.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index f1ab30aad3..203b8586ce 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -196,7 +196,7 @@ if ($db->sql_layer === 'firebird') // The FROM-Order is quite important here, else t.* columns can not be correctly bound. if ($post_id) { - $sql_array['SELECT'] .= ', p.post_approved, p.post_time'; + $sql_array['SELECT'] .= ', p.post_approved, p.post_time, p.post_id'; $sql_array['FROM'][POSTS_TABLE] = 'p'; } @@ -317,8 +317,16 @@ if ($post_id) $sql = 'SELECT COUNT(p.post_id) AS prev_posts FROM ' . POSTS_TABLE . " p WHERE p.topic_id = {$topic_data['topic_id']} - " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . ' - AND ' . (($sort_dir == 'd') ? "p.post_time >= {$topic_data['post_time']}" : "p.post_time <= {$topic_data['post_time']}"); + " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : ''); + + if ($sort_dir == 'd') + { + $sql .= " AND (p.post_time > {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id >= {$topic_data['post_id']}))"; + } + else + { + $sql .= " AND (p.post_time < {$topic_data['post_time']} OR (p.post_time = {$topic_data['post_time']} AND p.post_id <= {$topic_data['post_id']}))"; + } $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); |