summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-11-11 00:22:42 -0500
committerEvan Prodromou <evan@status.net>2009-11-11 00:22:42 -0500
commit935410e8dc4c2d4d286a942cc27bbf8bc452fbdd (patch)
tree98e3a577b432232bdddcc30afa9ad8a61a28d301 /classes
parent1f5f5474f175a8248b362f8be4ff23bb5e971305 (diff)
parent093857c582a68b39e0d65523d27f25ede7b7fed6 (diff)
Merge branch '0.9.x' into adminpanel
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);
+ }
}
}