]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Better SQLStats output with 0 queries
authorEvan Prodromou <evan@status.net>
Sun, 10 Apr 2011 22:32:09 +0000 (18:32 -0400)
committerEvan Prodromou <evan@status.net>
Sun, 10 Apr 2011 22:32:09 +0000 (18:32 -0400)
plugins/SQLStats/SQLStatsPlugin.php

index 20a9cbada2e6f1ecf38bf2cd5ce038021b02c999..de6ea2391760ce72f2b8840d8398e473528801b6 100644 (file)
@@ -65,12 +65,16 @@ class SQLStatsPlugin extends Plugin
 
     function cleanup()
     {
-        $this->log(LOG_INFO, sprintf('%d queries this hit (total = %d, avg = %d, max = %d, min = %d)',
-                                     count($this->queryTimes),
-                                     array_sum($this->queryTimes),
-                                     array_sum($this->queryTimes)/count($this->queryTimes),
-                                     max($this->queryTimes),
-                                     min($this->queryTimes)));
+        if (count($this->queryTimes) == 0) {
+            $this->log(LOG_INFO, sprintf('0 queries this hit.'));
+        } else {
+            $this->log(LOG_INFO, sprintf('%d queries this hit (total = %d, avg = %d, max = %d, min = %d)',
+                                         count($this->queryTimes),
+                                         array_sum($this->queryTimes),
+                                         array_sum($this->queryTimes)/count($this->queryTimes),
+                                         max($this->queryTimes),
+                                         min($this->queryTimes)));
+        }
 
         $verbose = common_config('sqlstats', 'verbose');