summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2009-11-03 16:57:39 -0800
committerBrion Vibber <brion@pobox.com>2009-11-10 13:44:40 -0800
commit53c86c43c4b8cba313335f5d70f7f77d4ab640d2 (patch)
tree96de2e9f0793685e35702946ec8539edbcf80921 /classes
parent1cd6650ae43d548f209d68e9feaaa7185d5ffecb (diff)
Bringing Sphinx search support up to code: broken out to a plugin, now supports multiple sites on a single server.
Upgrade notes: * Index names have changed from hardcoded 'Identica_people' and 'Identica_notices' to use the database name and actual table names. Must reindex. New events: * GetSearchEngine to override default search engine class selection from plugins New scripts: * gen_config.php generates a sphinx.conf from database configuration (with theoretical support for status_network table, but it doesn't seem to be cleanly queriable right now without knowing the db setup info for that. Needs generalized support.) * Replaced old sphinx-indexer.sh and sphinx-cron.sh with index_update.php Other fixes: * sphinx.conf.sample better matches our live config, skipping unused stopword list and using a more realistic indexer memory limit Further notes: * Probably doesn't work right with PostgreSQL yet; Sphinx can pull from PG but the extraction queries currently look like they use some MySQL-specific functions.
Diffstat (limited to 'classes')
-rw-r--r--classes/Memcached_DataObject.php29
-rw-r--r--classes/Status_network.php28
2 files changed, 29 insertions, 28 deletions
diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php
index 9c2ac3e01..753fe954e 100644
--- a/classes/Memcached_DataObject.php
+++ b/classes/Memcached_DataObject.php
@@ -184,27 +184,20 @@ class Memcached_DataObject extends DB_DataObject
require_once INSTALLDIR.'/lib/search_engines.php';
static $search_engine;
if (!isset($search_engine)) {
- $connected = false;
- if (common_config('sphinx', 'enabled')) {
- $search_engine = new SphinxSearch($this, $table);
- $connected = $search_engine->is_connected();
- }
-
- // unable to connect to sphinx' search daemon
- if (!$connected) {
- if ('mysql' === common_config('db', 'type')) {
- $type = common_config('search', 'type');
- if ($type == 'like') {
- $search_engine = new MySQLLikeSearch($this, $table);
- } else if ($type == 'fulltext') {
- $search_engine = new MySQLSearch($this, $table);
- } else {
- throw new ServerException('Unknown search type: ' . $type);
- }
+ if (Event::handle('GetSearchEngine', array($this, $table, &$search_engine))) {
+ if ('mysql' === common_config('db', 'type')) {
+ $type = common_config('search', 'type');
+ if ($type == 'like') {
+ $search_engine = new MySQLLikeSearch($this, $table);
+ } else if ($type == 'fulltext') {
+ $search_engine = new MySQLSearch($this, $table);
} else {
- $search_engine = new PGSearch($this, $table);
+ throw new ServerException('Unknown search type: ' . $type);
}
+ } else {
+ $search_engine = new PGSearch($this, $table);
}
+ }
}
return $search_engine;
}
diff --git a/classes/Status_network.php b/classes/Status_network.php
index fe4f0b0c5..b3117640d 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -57,14 +57,16 @@ class Status_network extends DB_DataObject
$config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/status_network.ini';
$config['db']['table_status_network'] = $dbname;
- self::$cache = new Memcache();
+ if (class_exists('Memcache')) {
+ self::$cache = new Memcache();
- if (is_array($servers)) {
- foreach($servers as $server) {
- self::$cache->addServer($server);
+ if (is_array($servers)) {
+ foreach($servers as $server) {
+ self::$cache->addServer($server);
+ }
+ } else {
+ self::$cache->addServer($servers);
}
- } else {
- self::$cache->addServer($servers);
}
self::$base = $dbname;
@@ -76,6 +78,10 @@ class Status_network extends DB_DataObject
static function memGet($k, $v)
{
+ if (!self::$cache) {
+ return self::staticGet($k, $v);
+ }
+
$ck = self::cacheKey($k, $v);
$sn = self::$cache->get($ck);
@@ -92,10 +98,12 @@ class Status_network extends DB_DataObject
function decache()
{
- $keys = array('nickname', 'hostname', 'pathname');
- foreach ($keys as $k) {
- $ck = self::cacheKey($k, $this->$k);
- self::$cache->delete($ck);
+ if (self::$cache) {
+ $keys = array('nickname', 'hostname', 'pathname');
+ foreach ($keys as $k) {
+ $ck = self::cacheKey($k, $this->$k);
+ self::$cache->delete($ck);
+ }
}
}