From a7d98435f649da268f728825e64eb673c451e242 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 15 Oct 2010 11:26:06 -0700 Subject: [PATCH 1/2] Tweak DB query logging to also log queries that fail; the exceptions we get are often not very descriptive like "No such table" without saying which table. :) --- classes/Memcached_DataObject.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/classes/Memcached_DataObject.php b/classes/Memcached_DataObject.php index 8ffb46cc52..27bb5d3c9d 100644 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@ -338,13 +338,27 @@ class Memcached_DataObject extends Safe_DataObject } $start = microtime(true); - $result = parent::_query($string); + $fail = false; + try { + $result = parent::_query($string); + } catch (Exception $e) { + $fail = $e; + } $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)); + if ($fail) { + $msg = sprintf("FAILED DB query (%0.3fs): %s - %s", $delta, $fail->getMessage(), $clean); + } else { + $msg = sprintf("DB query (%0.3fs): %s", $delta, $clean); + } + common_log(LOG_DEBUG, $msg); + } + + if ($fail) { + throw $fail; } return $result; } From e0cb6d6f7fdda97cb6ed262f79706392e315c055 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 15 Oct 2010 15:01:55 -0700 Subject: [PATCH 2/2] fix notice on non-https views --- lib/statusnet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/statusnet.php b/lib/statusnet.php index 3d018f4e21..2e2359c287 100644 --- a/lib/statusnet.php +++ b/lib/statusnet.php @@ -396,7 +396,7 @@ class StatusNet static function isHTTPS() { // There are some exceptions to this; add them here! - return $_SERVER['HTTPS']; + return !empty($_SERVER['HTTPS']); } }