diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 81b0805a8d..a3cea370e1 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -213,7 +213,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_path', 'files'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.1-dev'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.1.0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_expire_days', '90'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_gc', '14400'); diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index cb9b125400..7b8a909b46 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -405,7 +405,7 @@ else if (empty($active_forum_ary['exclude_forum_id'])) else { $get_forum_ids = array_diff($active_forum_ary['forum_id'], $active_forum_ary['exclude_forum_id']); - $sql_where = $db->sql_in_set('t.forum_id', $get_forum_ids); + $sql_where = (sizeof($get_forum_ids)) ? $db->sql_in_set('t.forum_id', $get_forum_ids) : 't.forum_id = ' . $forum_id; } // Grab just the sorted topic ids @@ -417,38 +417,44 @@ $sql = 'SELECT t.topic_id $sql_limit_time ORDER BY t.topic_type " . ((!$store_reverse) ? 'DESC' : 'ASC') . ', ' . $sql_sort_order; $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); + while ($row = $db->sql_fetchrow($result)) { $topic_list[] = (int) $row['topic_id']; } $db->sql_freeresult($result); -// SQL array for obtaining topics/stickies -$sql_array = array( - 'SELECT' => $sql_array['SELECT'], - 'FROM' => $sql_array['FROM'], - 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], - - 'WHERE' => $db->sql_in_set('t.topic_id', $topic_list), -); - -// If store_reverse, then first obtain topics, then stickies, else the other way around... -// Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because -// the number of stickies are not known -$sql = $db->sql_build_query('SELECT', $sql_array); -$result = $db->sql_query($sql); - +// For storing shadow topics $shadow_topic_list = array(); -while ($row = $db->sql_fetchrow($result)) -{ - if ($row['topic_status'] == ITEM_MOVED) - { - $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; - } - $rowset[$row['topic_id']] = $row; +if (sizeof($topic_list)) +{ + // SQL array for obtaining topics/stickies + $sql_array = array( + 'SELECT' => $sql_array['SELECT'], + 'FROM' => $sql_array['FROM'], + 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], + + 'WHERE' => $db->sql_in_set('t.topic_id', $topic_list), + ); + + // If store_reverse, then first obtain topics, then stickies, else the other way around... + // Funnily enough you typically save one query if going from the last page to the middle (store_reverse) because + // the number of stickies are not known + $sql = $db->sql_build_query('SELECT', $sql_array); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if ($row['topic_status'] == ITEM_MOVED) + { + $shadow_topic_list[$row['topic_moved_id']] = $row['topic_id']; + } + + $rowset[$row['topic_id']] = $row; + } + $db->sql_freeresult($result); } -$db->sql_freeresult($result); // If we have some shadow topics, update the rowset to reflect their topic information if (sizeof($shadow_topic_list))