]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Memcached_DataObject.php
Merge branch '0.9.x' into testing
[quix0rs-gnu-social.git] / classes / Memcached_DataObject.php
index 9c2ac3e01ca7f4c179bc29b2bac567b6eefd00d0..70e9e351d5e8855f814d168b2505091f8b427bf1 100644 (file)
@@ -23,6 +23,20 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 
 class Memcached_DataObject extends DB_DataObject
 {
+    /**
+     * Destructor to free global memory resources associated with
+     * this data object when it's unset or goes out of scope.
+     * DB_DataObject doesn't do this yet by itself.
+     */
+
+    function __destruct()
+    {
+        $this->free();
+        if (method_exists('DB_DataObject', '__destruct')) {
+            parent::__destruct();
+        }
+    }
+
     function &staticGet($cls, $k, $v=null)
     {
         if (is_null($v)) {
@@ -184,27 +198,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;
     }