]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Memcached_DataObject.php
add profile to stream function
[quix0rs-gnu-social.git] / classes / Memcached_DataObject.php
index 27bb5d3c9d6e32f58063f9e1320b5daa711d123f..59809dc8f772a060efa5200595e3cb0ded66310c 100644 (file)
@@ -34,7 +34,7 @@ class Memcached_DataObject extends Safe_DataObject
     {
         if (is_null($v)) {
             $v = $k;
-            # XXX: HACK!
+            // XXX: HACK!
             $i = new $cls;
             $keys = $i->keys();
             $k = $keys[0];
@@ -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) {
@@ -339,10 +339,15 @@ class Memcached_DataObject extends Safe_DataObject
 
         $start = microtime(true);
         $fail = false;
-        try {
-            $result = parent::_query($string);
-        } catch (Exception $e) {
-            $fail = $e;
+        $result = null;
+        if (Event::handle('StartDBQuery', array($this, $string, &$result))) {
+            common_perf_counter('query', $string);
+            try {
+                $result = parent::_query($string);
+            } catch (Exception $e) {
+                $fail = $e;
+            }
+            Event::handle('EndDBQuery', array($this, $string, &$result));
         }
         $delta = microtime(true) - $start;
 
@@ -490,6 +495,10 @@ class Memcached_DataObject extends Safe_DataObject
                     }
                 }
             }
+            // Needed to make timestamp values usefully comparable.
+            if (common_config('db', 'type') == 'mysql') {
+                parent::_query("set time_zone='+0:00'");
+            }
         }
 
         return $result;