|
|
Re: How to use Search plugin hook [message #184815 is a reply to message #184767] |
Wed, 05 February 2014 12:57 |
|
wferguss
Messages: 11 Registered: December 2013
Karma: 0
|
Junior Member |
add to buddy list ignore all messages by this user
|
|
I ended up adding a hook in a different spot, since all I really needed to do was change how the search_cache table is populated:
/* Remove expired cache entries. */
q('DELETE FROM {SQL_TABLE_PREFIX}search_cache WHERE expiry<'. (__request_timestamp__ - $GLOBALS['SEARCH_CACHE_EXPIRY']));
if (!($total = q_singleval('SELECT count(*) FROM {SQL_TABLE_PREFIX}search_cache WHERE srch_query=\''. $qry_lck .'\' AND query_type='. $qt))) {
if (defined('plugins') && isset($plugin_hooks['UPDATE_SEARCH_CACHE'])) {
plugin_call_hook('UPDATE_SEARCH_CACHE', array($qry_lck, $tbl, $qt, $wa));
} else {
q('INSERT INTO {SQL_TABLE_PREFIX}search_cache (srch_query, query_type, expiry, msg_id, n_match) '.
q_limit('SELECT \''. $qry_lck .'\', '. $qt .', '. __request_timestamp__ .', msg_id, count(*) as word_count FROM {SQL_TABLE_PREFIX}search s INNER JOIN {SQL_TABLE_PREFIX}'. $tbl .' i ON i.word_id=s.id WHERE word IN('. $qr .') GROUP BY msg_id ORDER BY word_count DESC',
500, 0));
}
}
Any chance this could be accepted into the source?
|
|
|