From d819ee343a3a6dc6282f709e67454cd2f0d1afcf Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 17 May 2010 21:14:02 +0800 Subject: [PATCH 1/2] [ticket/9606] Optimize unread search option. Get rid of redundant SQL query in search.php that should increase performance slightly. PHPBB3-9606 --- phpBB/includes/functions.php | 7 ++++--- phpBB/search.php | 19 +++++++------------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index cd8447a2a3..f783694db1 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1660,10 +1660,11 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * @param string $sql_extra Extra WHERE SQL statement * @param string $sql_sort ORDER BY SQL sorting statement * @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query +* @param string $sql_limit_offset Sets the offset of the first row to search, 0 to search from the start * * @return array[int][int] Topic ids as keys, mark_time of topic as value */ -function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) +function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0) { global $config, $db, $user; @@ -1709,7 +1710,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s ); $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query_limit($sql, $sql_limit); + $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset); while ($row = $db->sql_fetchrow($result)) { @@ -1742,7 +1743,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s WHERE t.topic_last_post_time > ' . $user_lastmark . " $sql_extra $sql_sort"; - $result = $db->sql_query_limit($sql, $sql_limit); + $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset); while ($row = $db->sql_fetchrow($result)) { diff --git a/phpBB/search.php b/phpBB/search.php index 7a9ab82f93..1e1e42d01f 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -387,18 +387,6 @@ if ($keywords || $author || $author_id || $search_id || $submit) gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = ''; - - $unread_list = array(); - $unread_list = get_unread_topics($user->data['user_id'], $sql_where, $sql_sort); - - if (!empty($unread_list)) - { - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list)) . " - $sql_sort"; - $field = 'topic_id'; - } break; case 'newposts': @@ -476,6 +464,13 @@ if ($keywords || $author || $author_id || $search_id || $submit) $total_match_count = sizeof($id_ary) + $start; $id_ary = array_slice($id_ary, 0, $per_page); } + else if ($search_id == 'unreadposts') + { + $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, 1001 - $start, $start)); + + $total_match_count = sizeof($id_ary) + $start; + $id_ary = array_slice($id_ary, 0, $per_page); + } else { $search_id = ''; From e942af533165dd3ef5236ef6b6a7499613b26693 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sun, 13 Jun 2010 19:18:35 -0500 Subject: [PATCH 2/2] [ticket/9132] Oracle CLOB support is broken, preventing storage of long strings This reverts Oracle support to the state it was in prior to phpBB 3.0.6. That is, storage of long strings works again (e.g. posts > 4 KB), but the database backup/restore functionality is broken. We feel that the ability to store long strings is more important than the DB restore, since Oracle 10g itself provides tools for backing up databases. PHPBB3-9132 --- phpBB/includes/db/oracle.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index 55b3599800..5a9b18abf0 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -261,6 +261,10 @@ class dbal_oracle extends dbal { $cols = explode(', ', $regs[2]); +/* The code inside this comment block breaks clob handling, but does allow the + database restore script to work. If you want to allow no posts longer than 4KB + and/or need the db restore script, uncomment this. + preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER); if (sizeof($cols) !== sizeof($vals)) @@ -310,6 +314,7 @@ class dbal_oracle extends dbal $vals = array(0 => $vals); } +*/ $inserts = $vals[0]; unset($vals);