From d375317c7f4fc78adcba1eee3efb1b634c93b07e Mon Sep 17 00:00:00 2001
From: Evan Prodromou <evan@status.net>
Date: Sun, 10 Apr 2011 18:32:09 -0400
Subject: [PATCH] Better SQLStats output with 0 queries

---
 plugins/SQLStats/SQLStatsPlugin.php | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/plugins/SQLStats/SQLStatsPlugin.php b/plugins/SQLStats/SQLStatsPlugin.php
index 20a9cbada2..de6ea23917 100644
--- a/plugins/SQLStats/SQLStatsPlugin.php
+++ b/plugins/SQLStats/SQLStatsPlugin.php
@@ -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');
 
-- 
2.39.5