Permalink
Browse files

Slight backflip, queries are logged by the core but only if there is …

…an authenticated user
  • Loading branch information...
1 parent 4ac641b commit 87f935db6945122a8e3066cb0b6d48050337aa6a @brendo brendo committed Dec 16, 2011
@@ -223,14 +223,33 @@ public static function render(Exception $e){
=======
>>>>>>> Symphony no longer logs queries in the core, this can be done with an extension. Remove getLastError(), there is no need as DatabaseExceptions contain all necessary information.
+<<<<<<< HEAD
return sprintf(file_get_contents(self::getTemplate('fatalerror.generic')),
+=======
+ if(is_object(Symphony::Database())){
+ $debug = Symphony::Database()->debug();
+
+ if(!empty($debug) foreach($debug as $query){
+ $queries .= sprintf(
+ '<li%s><code>%s;</code> <small>[%01.4f]</small></li>',
+ ($odd == true ? ' class="odd"' : NULL),
+ htmlspecialchars($query['query']),
+ (isset($query['execution_time']) ? $query['execution_time'] : NULL)
+ );
+ $odd = !$odd;
+ }
+ }
+
+ return sprintf(file_get_contents(TEMPLATE . '/fatalerror.generic.tpl'),
+>>>>>>> Slight backflip, queries are logged by the core but only if there is an authenticated user
($e instanceof ErrorException ? GenericErrorHandler::$errorTypeStrings[$e->getSeverity()] : 'Fatal Error'),
$e->getMessage(),
$e->getFile(),
$e->getLine(),
$markdown,
$lines,
- $trace
+ $trace,
+ $queries
);
}
@@ -117,8 +117,7 @@ protected function __construct(){
$this->initialiseExtensionManager();
$this->initialiseCookie();
- // If the user is not a logged in Author, turn off the verbose error
- // messages.
+ // If the user is not a logged in Author, turn off the verbose error messages.
if(!self::isLoggedIn() && is_null($this->Author)){
GenericExceptionHandler::$enabled = false;
}
@@ -788,6 +787,7 @@ public static function render(Exception $e){
if(is_object(Symphony::Database())){
$debug = Symphony::Database()->debug();
+<<<<<<< HEAD
if(count($debug['query']) > 0){
foreach($debug['query'] as $query){
$queries .= sprintf(
@@ -798,6 +798,16 @@ public static function render(Exception $e){
);
$odd = !$odd;
}
+=======
+ if(!empty($debug) foreach($debug as $query){
+ $queries .= sprintf(
+ '<li%s><code>%s;</code> <small>[%01.4f]</small></li>',
+ ($odd == true ? ' class="odd"' : NULL),
+ htmlspecialchars($query['query']),
+ (isset($query['execution_time']) ? $query['execution_time'] : NULL)
+ );
+ $odd = !$odd;
+>>>>>>> Slight backflip, queries are logged by the core but only if there is an authenticated user
}
}
@@ -497,7 +497,19 @@ public function query($query, $type = "OBJECT"){
'query_hash' => $query_hash,
'execution_time' => precision_timer('stop', $start)
));
+
+ // If the ExceptionHandler is enabled, then the user is authenticated
+ // or we have a serious issue, so log the query.
+ if(GenericExceptionHandler::$enabled) {
+ self::$_log[$query_hash] = array(
+ 'query' => $query,
+ 'query_hash' => $query_hash,
+ 'execution_time' => precision_timer('stop', $start)
+ );
+ }
}
+
+ // Symphony isn't ready yet. Log internally
else {
self::$_log[$query_hash] = array(
'query' => $query,
@@ -826,9 +838,7 @@ public function getStatistics() {
$query_timer = 0.0;
$slow_queries = array();
- $query_log = $this->debug();
-
- foreach($query_log as $key => $val) {
+ foreach(self::$_log as $key => $val) {
$query_timer += $val['execution_time'];
if($val['execution_time'] > 0.0999) $slow_queries[] = $val;
}
@@ -83,6 +83,9 @@
<h3>Backtrace:</h3>
<ul>%s</ul>
+
+ <h3>Database Query Log:</h3>
+ <ul>%s</ul>
</div>
</body>
</html>
@@ -98,6 +98,9 @@
<h3>Backtrace:</h3>
<ul>%s</ul>
+
+ <h3>Database Query Log:</h3>
+ <ul>%s</ul>
</div>
</body>
</html>

0 comments on commit 87f935d

Please sign in to comment.