]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Memcached_DataObject.php
Memcache_DataObject checks for PEAR::isError() on results
[quix0rs-gnu-social.git] / classes / Memcached_DataObject.php
index 7768fe757147c7493c5c662a971e57e78ae13ce8..d50b4071d1eeaef3548dd992675498bd991fad31 100644 (file)
@@ -74,7 +74,7 @@ class Memcached_DataObject extends Safe_DataObject
             return $i;
         } else {
             $i = DB_DataObject::factory($cls);
-            if (empty($i)) {
+            if (empty($i) || PEAR::isError($i)) {
                 return false;
             }
             foreach ($kv as $k => $v) {
@@ -189,11 +189,11 @@ class Memcached_DataObject extends Safe_DataObject
                        str_replace("\n", " ", $e->getTraceAsString()));
             return false;
         } else {
-               $keys = $this->_allCacheKeys();
+            $keys = $this->_allCacheKeys();
 
-               foreach ($keys as $key) {
-                   $c->set($key, $this);
-               }
+            foreach ($keys as $key) {
+                $c->set($key, $this);
+            }
         }
     }
 
@@ -338,7 +338,11 @@ class Memcached_DataObject extends Safe_DataObject
         }
 
         $start = microtime(true);
-        $result = parent::_query($string);
+        $result = null;
+        if (Event::handle('StartDBQuery', array($this, $string, &$result))) {
+            $result = parent::_query($string);
+            Event::handle('EndDBQuery', array($this, $string, &$result));
+        }
         $delta = microtime(true) - $start;
 
         $limit = common_config('db', 'log_slow_queries');
@@ -574,7 +578,7 @@ class Memcached_DataObject extends Safe_DataObject
     function raiseError($message, $type = null, $behaviour = null)
     {
         $id = get_class($this);
-        if ($this->id) {
+        if (!empty($this->id)) {
             $id .= ':' . $this->id;
         }
         if ($message instanceof PEAR_Error) {
@@ -637,4 +641,3 @@ class Memcached_DataObject extends Safe_DataObject
         return $vstr;
     }
 }
-