diff options
author | Andreas Fischer <bantu@phpbb.com> | 2012-02-26 02:19:12 +0100 |
---|---|---|
committer | Andreas Fischer <bantu@phpbb.com> | 2012-02-26 02:19:12 +0100 |
commit | 6548a3094f2981a19ff001e67596befab4159ecd (patch) | |
tree | 77c18d5fe3afa54a1de2b6e026328263632602fa /phpBB/search.php | |
parent | 459e8dc09522d8e54ce82182a99ebddf2362a737 (diff) | |
download | forums-6548a3094f2981a19ff001e67596befab4159ecd.tar forums-6548a3094f2981a19ff001e67596befab4159ecd.tar.gz forums-6548a3094f2981a19ff001e67596befab4159ecd.tar.bz2 forums-6548a3094f2981a19ff001e67596befab4159ecd.tar.xz forums-6548a3094f2981a19ff001e67596befab4159ecd.zip |
[ticket/10532] Remove one unnecessary level of if block nesting.
PHPBB3-10532
Diffstat (limited to 'phpBB/search.php')
-rw-r--r-- | phpBB/search.php | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/phpBB/search.php b/phpBB/search.php index 3006c0e5d9..d89bc79225 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -475,56 +475,53 @@ if ($keywords || $author || $author_id || $search_id || $submit) if ($search_id) { - if ($sql || $search_id == 'unreadposts') + if ($sql) { - if ($sql) - { - // Only return up to $total_matches_limit+1 ids (the last one will be removed later) - $result = $db->sql_query_limit($sql, ($total_matches_limit + 1)); + // Only return up to $total_matches_limit+1 ids (the last one will be removed later) + $result = $db->sql_query_limit($sql, ($total_matches_limit + 1)); - while ($row = $db->sql_fetchrow($result)) - { - $id_ary[] = (int) $row[$field]; - } - $db->sql_freeresult($result); - } - else if ($search_id == 'unreadposts') + while ($row = $db->sql_fetchrow($result)) { - // Only return up to $total_matches_limit+1 ids (the last one will be removed later) - $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, ($total_matches_limit + 1))); + $id_ary[] = (int) $row[$field]; } + $db->sql_freeresult($result); + } + else if ($search_id == 'unreadposts') + { + // Only return up to $total_matches_limit+1 ids (the last one will be removed later) + $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, ($total_matches_limit + 1))); + } + else + { + $search_id = ''; + } - $total_match_count = sizeof($id_ary); - if ($total_match_count) + $total_match_count = sizeof($id_ary); + if ($total_match_count) + { + // Limit the number to $total_matches_limit for pre-made searches + if ($total_match_count > $total_matches_limit) { - // Limit the number to $total_matches_limit for pre-made searches - if ($total_match_count > $total_matches_limit) - { - $found_more_search_matches = true; - $total_match_count = $total_matches_limit; - } - - // Make sure $start is set to the last page if it exceeds the amount - if ($start < 0) - { - $start = 0; - } - else if ($start >= $total_match_count) - { - $start = floor(($total_match_count - 1) / $per_page) * $per_page; - } - - $id_ary = array_slice($id_ary, $start, $per_page); + $found_more_search_matches = true; + $total_match_count = $total_matches_limit; } - else + + // Make sure $start is set to the last page if it exceeds the amount + if ($start < 0) { - // Set $start to 0 if no matches were found $start = 0; } + else if ($start >= $total_match_count) + { + $start = floor(($total_match_count - 1) / $per_page) * $per_page; + } + + $id_ary = array_slice($id_ary, $start, $per_page); } else { - $search_id = ''; + // Set $start to 0 if no matches were found + $start = 0; } } |