diff options
Diffstat (limited to 'phpBB/viewforum.php')
| -rw-r--r-- | phpBB/viewforum.php | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 58ee68a38e..1092bdb90f 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -405,20 +405,31 @@ $sql_array = array( // the number of stickies are not known $sql = $db->sql_build_query('SELECT', $sql_array); $sql = str_replace('{SQL_TOPIC_TYPE}', ($store_reverse) ? POST_NORMAL : POST_STICKY, $sql); -$result = $db->sql_query_limit($sql, $sql_limit, $sql_start); +$result = $db->sql_query_limit($sql, $sql_limit); $shadow_topic_list = array(); + +// Total number of normal or sticky topics that have been retrieved +$start_count = 0; + +// Number of normal or sticky topics that have been placed $num_rows = 0; + while ($row = $db->sql_fetchrow($result)) { - if ($row['topic_status'] == ITEM_MOVED) + $start_count++; + + if ($start_count >= $sql_start) { - $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; - } + if ($row['topic_status'] == ITEM_MOVED) + { + $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; + } - $rowset[$row['topic_id']] = $row; - $topic_list[] = $row['topic_id']; - $num_rows++; + $rowset[$row['topic_id']] = $row; + $topic_list[] = $row['topic_id']; + $num_rows++; + } } $db->sql_freeresult($result); @@ -427,7 +438,9 @@ if ($num_rows < $sql_limit) { $sql = $db->sql_build_query('SELECT', $sql_array); $sql = str_replace('{SQL_TOPIC_TYPE}', ($store_reverse) ? POST_STICKY : POST_NORMAL, $sql); - $result = $db->sql_query_limit($sql, $sql_limit - $num_rows, $sql_start); + + // Start at $sql_start - number of sticky topics on the previous page ($start_count - $num_rows) + $result = $db->sql_query_limit($sql, $sql_limit - $num_rows, $sql_start - ($start_count - $num_rows)); while ($row = $db->sql_fetchrow($result)) { |
