From a74e3aea6f0bdde210c91622535af3e58aa1e9fd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 9 Dec 2012 20:26:16 -0800 Subject: Eliminate the search context if we encounter an item that cannot be found in the search results. Fixes #1923. --- modules/gallery/helpers/item.php | 7 +++++++ modules/search/helpers/search.php | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index d8b660d9..b739e8bd 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -414,6 +414,13 @@ class item_Core { } } + /** + * Get rid of the display context callback + */ + static function clear_display_context_callback() { + Cache::instance()->delete("display_context_" . $sid = Session::instance()->id()); + } + /** * Call the display context callback for the given item */ diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index b7fa21c4..64a13825 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -117,7 +117,14 @@ class search_Core { // Truncate the score by two decimal places as this resolves the issues // that arise due to in exact numeric conversions. - $score = $db->query($query)->current()->score; + $current = $db->query($query)->current(); + if (!$current) { + // We can't find this result in our result set - perhaps we've fallen out of context? Clear + // the context and try again. + item::clear_display_context_callback(); + url::redirect(url::current()); + } + $score = $current->score(); if (strlen($score) > 7) { $score = substr($score, 0, strlen($score) - 2); } -- cgit v1.2.3