[Rt-commit] rt branch, 4.0/log-more-sql-queries, created. rt-4.0.7-63-g0d4f3db

Thomas Sibley trs at bestpractical.com
Thu Oct 4 00:56:09 EDT 2012


The branch, 4.0/log-more-sql-queries has been created
        at  0d4f3dbaa4763b1eddbcbbf1b9c4cc54dbaac12c (commit)

- Log -----------------------------------------------------------------
commit da2d9fe3fbcfa76b70a92b7711e1e9c93e3bfdc5
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Oct 3 21:48:11 2012 -0700

    Log SQL queries under the true request path rather than Mason component
    
    Particularly helpful when debugging requests handled by a dhandler.
    Instead of just the dhandler path you see the actual request path,
    aiding in teasing apart different requests.
    
    The components involved are recorded in the stacktrace for each query,
    so the fact that a dhandler was called isn't lost.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 99aa7b6..3f2e605 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -325,7 +325,7 @@ sub HandleRequest {
 
     ShowRequestedPage($ARGS);
     LogRecordedSQLStatements(RequestData => {
-        Path => $HTML::Mason::Commands::m->request_comp->path,
+        Path => $HTML::Mason::Commands::m->request_path,
     });
 
     # Process per-page final cleanup callbacks

commit 0d4f3dbaa4763b1eddbcbbf1b9c4cc54dbaac12c
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Oct 3 21:51:39 2012 -0700

    Log SQL queries right before we abort a request
    
    Otherwise they are lost to the ghost of requests past.
    
    This catches the two most common cases of aborted requests: Abort() and
    MaybeRedirectForResults().  Particularly useful for logging queries on
    record creation and autocomplete.

diff --git a/lib/RT/Interface/Web/Request.pm b/lib/RT/Interface/Web/Request.pm
index d086511..ee82aa4 100644
--- a/lib/RT/Interface/Web/Request.pm
+++ b/lib/RT/Interface/Web/Request.pm
@@ -165,4 +165,21 @@ sub request_path {
     return $path;
 }
 
+=head2 abort
+
+Logs any recorded SQL statements for this request before calling the standard
+abort.
+
+=cut
+
+sub abort {
+    my $self = shift;
+    RT::Interface::Web::LogRecordedSQLStatements(
+        RequestData => {
+            Path => $self->request_path,
+        },
+    );
+    return $self->SUPER::abort(@_);
+}
+
 1;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list