aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/search/search.php
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2006-01-21 22:57:42 +0000
committerNils Adermann <naderman@naderman.de>2006-01-21 22:57:42 +0000
commit7de53b46ec192c66192f3ebcd6123c2c3dbecb6f (patch)
treee9bc358c5840c795bb35711182a978c1e9ef82c2 /phpBB/includes/search/search.php
parent133ce52d3b7fb4c653ac7195d681e0201c1cf38d (diff)
downloadforums-7de53b46ec192c66192f3ebcd6123c2c3dbecb6f.tar
forums-7de53b46ec192c66192f3ebcd6123c2c3dbecb6f.tar.gz
forums-7de53b46ec192c66192f3ebcd6123c2c3dbecb6f.tar.bz2
forums-7de53b46ec192c66192f3ebcd6123c2c3dbecb6f.tar.xz
forums-7de53b46ec192c66192f3ebcd6123c2c3dbecb6f.zip
- search deals with global topics
- fixed some other search related bugs git-svn-id: file:///svn/phpbb/trunk@5482 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/search/search.php')
-rwxr-xr-xphpBB/includes/search/search.php48
1 files changed, 43 insertions, 5 deletions
diff --git a/phpBB/includes/search/search.php b/phpBB/includes/search/search.php
index 6f31e88ca4..daa3d62a4d 100755
--- a/phpBB/includes/search/search.php
+++ b/phpBB/includes/search/search.php
@@ -82,7 +82,7 @@ class search_backend
if (!isset($match_synonym[$user->lang_name]))
{
- preg_match_all('#^\s+(\S+)\s+(\S+)\s+$#m', file_get_contents($user->lang_path . '/search_synonyms.txt'), $match);
+ preg_match_all('#^\s*(\S+)\s+(\S+)\s*$#m', file_get_contents($user->lang_path . '/search_synonyms.txt'), $match);
$match_synonym[$user->lang_name]['replace']= &$match[1];
$match_synonym[$user->lang_name]['match'] = &$match[2];
@@ -170,6 +170,12 @@ class search_backend
$length = min(sizeof($id_ary), $config['search_block_size']);
+ // nothing to cache so exit
+ if (!$length)
+ {
+ return;
+ }
+
$store_ids = array_slice($id_ary, 0, $length);
// create a new resultset if there is none for this search_key yet
@@ -190,7 +196,7 @@ class search_backend
'search_key' => $search_key,
'search_time' => time(),
'search_keywords' => $keywords,
- 'search_authors' => implode(' ', $author_ary)
+ 'search_authors' => ' ' . implode(' ', $author_ary) . ' '
);
$sql = 'INSERT INTO ' . SEARCH_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
@@ -218,9 +224,19 @@ class search_backend
}
}
+ $store_ids = array_combine($id_range, $store_ids);
+
// append the ids
- $store += array_combine($id_range, $store_ids);
- $cache->put('_search_results_' . $search_key, $store, $config['search_store_results']);
+ if (is_array($store_ids))
+ {
+ $store += $store_ids;
+ $cache->put('_search_results_' . $search_key, $store, $config['search_store_results']);
+
+ $sql = 'UPDATE ' . SEARCH_TABLE . '
+ SET search_time = ' . time() . '
+ WHERE search_key = \'' . $db->sql_escape($search_key) . '\'';
+ $db->sql_query($sql);
+ }
unset($store);
unset($store_ids);
@@ -230,10 +246,11 @@ class search_backend
/**
* Removes old entries from the search results table and removes searches with keywords that contain a word in $words.
*/
- function destroy_cache($words)
+ function destroy_cache($words, $authors = false)
{
global $db, $cache, $config;
+ // clear all searches that searched for the specified words
if (sizeof($words))
{
$sql_where = '';
@@ -254,6 +271,27 @@ class search_backend
$db->sql_freeresult();
}
+ // clear all searches that searched for the specified authors
+ if (is_array($authors) && sizeof($authors))
+ {
+ $sql_where = '';
+ foreach ($authors as $author)
+ {
+ $sql_where .= (($sql_where) ? ' OR ' : '') . 'search_authors LIKE \'% ' . (int) $author . ' %\'';
+ }
+
+ $sql = 'SELECT search_key
+ FROM ' . SEARCH_TABLE . "
+ WHERE $sql_where";
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $cache->destroy('_search_results_' . $row['search_key']);
+ }
+ $db->sql_freeresult();
+ }
+
$sql = 'DELETE
FROM ' . SEARCH_TABLE . '
WHERE search_time < ' . (time() - $config['search_store_results']);