From 52d7e7da486d77b2e4dbd0cdfe29fd790c920be4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 21 Nov 2007 11:34:06 +0100 Subject: [PATCH] disable headline cache when searching --- backend.php | 2 ++ feedlist.js | 8 +++++++- functions.php | 9 ++++++++- viewfeed.js | 8 ++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/backend.php b/backend.php index 02b52e68a..d68ede30a 100644 --- a/backend.php +++ b/backend.php @@ -227,6 +227,7 @@ $topmost_article_ids = $ret[0]; $headlines_count = $ret[1]; $returned_feed = $ret[2]; + $disable_cache = $ret[3]; print "]]>"; @@ -235,6 +236,7 @@ $headlines_unread = getFeedUnread($link, $returned_feed); print ""; + printf("", $disable_cache); if ($_GET["debug"]) $timing_info = print_checkpoint("10", $timing_info); diff --git a/feedlist.js b/feedlist.js index 57bfdcd1e..872709a10 100644 --- a/feedlist.js +++ b/feedlist.js @@ -36,6 +36,8 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { // if (!offset) page_offset = 0; + var force_nocache = false; + var page_offset = 0; if (offset > 0) { @@ -76,6 +78,9 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { var toolbar_query = Form.serialize("main_toolbar_form"); if (toolbar_form.query) { + if (toolbar_form.query.value != "") { + force_nocache = true; + } toolbar_form.query.value = ""; } @@ -86,6 +91,7 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { var search_query = Form.serialize("search_form"); query = query + "&" + search_query; closeInfoBox(true); + force_nocache = true; } // debug("IS_CAT_STORED: " + activeFeedIsCat() + ", IS_CAT: " + is_cat); @@ -146,7 +152,7 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { var unread_ctr = document.getElementById("FEEDU-" + feed); var cache_check = false; - if (unread_ctr && !page_offset) { + if (unread_ctr && !page_offset && !force_nocache) { unread_ctr = unread_ctr.innerHTML; var cache_prefix = ""; diff --git a/functions.php b/functions.php index 0dce414c9..3644bc25d 100644 --- a/functions.php +++ b/functions.php @@ -4519,6 +4519,8 @@ function outputHeadlinesList($link, $feed, $subop, $view_mode, $limit, $cat_view, $next_unread_feed, $offset) { + $disable_cache = false; + $timing_info = getmicrotime(); $topmost_article_ids = array(); @@ -4586,6 +4588,11 @@ /// START ///////////////////////////////////////////////////////////////////////////////// $search = db_escape_string($_GET["query"]); + + if ($search) { + $disable_cache = true; + } + $search_mode = db_escape_string($_GET["search_mode"]); $match_on = db_escape_string($_GET["match_on"]); @@ -4952,7 +4959,7 @@ print ""; } - return array($topmost_article_ids, $headlines_count, $feed); + return array($topmost_article_ids, $headlines_count, $feed, $disable_cache); } // from here: http://www.roscripts.com/Create_tag_cloud-71.html diff --git a/viewfeed.js b/viewfeed.js index 1968c3775..aa3a14837 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -91,9 +91,11 @@ function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) { var headlines = transport.responseXML.getElementsByTagName("headlines")[0]; var headlines_count_obj = transport.responseXML.getElementsByTagName("headlines-count")[0]; var headlines_unread_obj = transport.responseXML.getElementsByTagName("headlines-unread")[0]; + var disable_cache_obj = transport.responseXML.getElementsByTagName("disable-cache")[0]; var headlines_count = headlines_count_obj.getAttribute("value"); var headlines_unread = headlines_unread_obj.getAttribute("value"); + var disable_cache = disable_cache_obj.getAttribute("value") != "0"; if (headlines_count == 0) _infscroll_disable = 1; @@ -115,8 +117,10 @@ function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) { cache_invalidate(cache_prefix + active_feed_id); - cache_inject(cache_prefix + active_feed_id, - headlines.firstChild.nodeValue, headlines_unread); + if (!disable_cache) { + cache_inject(cache_prefix + active_feed_id, + headlines.firstChild.nodeValue, headlines_unread); + } } else { debug("headlines_callback: returned no data");