]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
authorEvan Prodromou <evan@status.net>
Fri, 22 Jan 2010 19:18:21 +0000 (14:18 -0500)
committerEvan Prodromou <evan@status.net>
Fri, 22 Jan 2010 19:18:21 +0000 (14:18 -0500)
1  2 
classes/Memcached_DataObject.php

index 6ddef4816015b7a5c3e8afb23629c1ebcc6a4241,6ceb59e8b498c64fd5a94f20f10b86dce5e56647..33645a3e8b6eeaf75246d69e87f70db41ab209a7
@@@ -19,6 -19,8 +19,6 @@@
  
  if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
  
 -require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
 -
  class Memcached_DataObject extends DB_DataObject
  {
      /**
          return new ArrayWrapper($cached);
      }
  
+     /**
+      * sends query to database - this is the private one that must work 
+      *   - internal functions use this rather than $this->query()
+      *
+      * Overridden to do logging.
+      *
+      * @param  string  $string
+      * @access private
+      * @return mixed none or PEAR_Error
+      */
+     function _query($string)
+     {
+         $start = microtime(true);
+         $result = parent::_query($string);
+         $delta = microtime(true) - $start;
+         $limit = common_config('db', 'log_slow_queries');
+         if (($limit > 0 && $delta >= $limit) || common_config('db', 'log_queries')) {
+             $clean = $this->sanitizeQuery($string);
+             common_log(LOG_DEBUG, sprintf("DB query (%0.3fs): %s", $delta, $clean));
+         }
+         return $result;
+     }
+     // Sanitize a query for logging
+     // @fixme don't trim spaces in string literals
+     function sanitizeQuery($string)
+     {
+         $string = preg_replace('/\s+/', ' ', $string);
+         $string = trim($string);
+         return $string;
+     }
      // We overload so that 'SET NAMES "utf8"' is called for
      // each connection
  
                  unset($_DB_DATAOBJECT['CONNECTIONS'][$index]);
              }
          }
 -        
 +
          $result = parent::_connect();
  
          if ($result && !$exists) {