[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.5-149-gf29334d
jesse
jesse at bestpractical.com
Tue Sep 29 13:43:20 EDT 2009
The branch, 3.8-trunk has been updated
via f29334d51880921f74597d09d5179dd7e2997c92 (commit)
via 9b6f4eab83856df4824144b3713dcb7d68939de0 (commit)
via c95221e470eb80c66f648e5faaa21ca3cae0d71f (commit)
via e86e90bdd5ac26292e4f4633bb7935b4a0c53b9d (commit)
from 809c552a4d5114cd04edb6ac9f23210fe257cdac (commit)
Summary of changes:
lib/RT/ACE_Overlay.pm | 2 +-
lib/RT/Interface/Web.pm | 101 +++++++++++++++++++++++++++++++++++++++++++
share/html/autohandler | 87 ++++---------------------------------
t/shredder/03plugin_users.t | 3 +-
4 files changed, 113 insertions(+), 80 deletions(-)
- Log -----------------------------------------------------------------
commit e86e90bdd5ac26292e4f4633bb7935b4a0c53b9d
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Wed Sep 30 00:19:33 2009 +0900
typo fix
diff --git a/share/html/autohandler b/share/html/autohandler
index c0aec4e..fb72d5a 100755
--- a/share/html/autohandler
+++ b/share/html/autohandler
@@ -108,7 +108,7 @@ if ( $m->request_comp->attr_exists('AutoFlush') ) {
: $_
} %ARGS;
-# Latter in the code we use
+# Later in the code we use
# $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS );
# instead of $m->call_next to avoid problems with UTF8 keys in arguments.
# The call_next method pass through original arguments and if you have
commit c95221e470eb80c66f648e5faaa21ca3cae0d71f
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Wed Sep 30 02:34:49 2009 +0900
Working to refactor the autohandler to be more maintainable
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index e5d9d19..3d5f6fb 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -317,6 +317,107 @@ sub StripContent {
}
+sub DecodeARGS {
+ my $ARGS = shift;
+
+ return map {
+
+ # if they've passed multiple values, they'll be an array. if they've
+ # passed just one, a scalar whatever they are, mark them as utf8
+ my $type = ref($_);
+ ( !$type )
+ ? Encode::is_utf8($_)
+ ? $_
+ : Encode::decode( 'UTF-8' => $_, Encode::FB_PERLQQ )
+ : ( $type eq 'ARRAY' )
+ ? [
+ map {
+ ( ref($_) or Encode::is_utf8($_) )
+ ? $_
+ : Encode::decode( 'UTF-8' => $_, Encode::FB_PERLQQ )
+ } @$_
+ ]
+ : ( $type eq 'HASH' )
+ ? {
+ map {
+ ( ref($_) or Encode::is_utf8($_) )
+ ? $_
+ : Encode::decode( 'UTF-8' => $_, Encode::FB_PERLQQ )
+ } %$_
+ }
+ : $_
+} %$ARGS;
+}
+
+
+sub PreprocessTimeUpdates {
+ my $ARGS = shift;
+
+# Later in the code we use
+# $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS );
+# instead of $m->call_next to avoid problems with UTF8 keys in arguments.
+# The call_next method pass through original arguments and if you have
+# an argument with unicode key then in a next component you'll get two
+# records in the args hash: one with key without UTF8 flag and another
+# with the flag, which may result into errors. "{ base_comp => $m->request_comp }"
+# is copied from mason's source to get the same results as we get from
+# call_next method, this feature is not documented, so we just leave it
+# here to avoid possible side effects.
+
+# This code canonicalizes time inputs in hours into minutes
+foreach my $field ( keys %$ARGS ) {
+ next unless $field =~ /^(.*)-TimeUnits$/i && $ARGS->{ $1 };
+ my $local = $1;
+ $ARGS->{$local} =~ s{\b (?: (\d+) \s+ )? (\d+)/(\d+) \b}
+ {($1 || 0) + $3 ? $2 / $3 : 0}xe;
+ if ( $ARGS->{$field} && $ARGS->{$field} =~ /hours/i ) {
+ $ARGS->{$local} *= 60;
+ }
+ delete $ARGS->{$field};
+}
+
+}
+
+
+sub MaybeEnableSQLStatementLog {
+
+my $log_sql_statements = RT->Config->Get('StatementLog');
+
+if ( $log_sql_statements ) {
+ $RT::Handle->ClearSQLStatementLog;
+ $RT::Handle->LogSQLStatements(1);
+}
+
+}
+sub LogRecordedSQLStatements {
+ my $log_sql_statements = RT->Config->Get('StatementLog');
+
+ return unless ($log_sql_statements);
+
+ my @log = $RT::Handle->SQLStatementLog;
+ $RT::Handle->ClearSQLStatementLog;
+ for my $stmt (@log) {
+ my ( $time, $sql, $bind, $duration ) = @{$stmt};
+ my @bind;
+ if ( ref $bind ) {
+ @bind = @{$bind};
+ }
+ else {
+
+ # Older DBIx-SB
+ $duration = $bind;
+ }
+ $RT::Logger->log(
+ level => $log_sql_statements,
+ message => "SQL(" . sprintf( "%.6f", $duration ) . "s): $sql;"
+ . ( @bind ? " [ bound values: @{[map{qq|'$_'|} @bind]} ]" : "" )
+ );
+ }
+
+}
+
+
+
package HTML::Mason::Commands;
use vars qw/$r $m %session/;
diff --git a/share/html/autohandler b/share/html/autohandler
index fb72d5a..fe15c2f 100755
--- a/share/html/autohandler
+++ b/share/html/autohandler
@@ -65,12 +65,8 @@ if (RT->InstallMode) {
# Roll back any dangling transactions from a previous failed connection
$RT::Handle->ForceRollback() if $RT::Handle->TransactionDepth;
-my $log_sql_statements = RT->Config->Get('StatementLog');
-if ( $log_sql_statements ) {
- $RT::Handle->ClearSQLStatementLog;
- $RT::Handle->LogSQLStatements(1);
-}
+RT::Interface::Web::MaybeEnableSQLStatementLog();
# avoid reentrancy, as suggested by masonbook
local *session unless $m->is_subrequest;
@@ -80,56 +76,12 @@ if ( $m->request_comp->attr_exists('AutoFlush') ) {
$m->autoflush( $m->request_comp->attr('AutoFlush') );
}
-%ARGS = map {
-
- # if they've passed multiple values, they'll be an array. if they've
- # passed just one, a scalar whatever they are, mark them as utf8
- my $type = ref($_);
- ( !$type )
- ? Encode::is_utf8($_)
- ? $_
- : Encode::decode( 'UTF-8' => $_, Encode::FB_PERLQQ )
- : ( $type eq 'ARRAY' )
- ? [
- map {
- ( ref($_) or Encode::is_utf8($_) )
- ? $_
- : Encode::decode( 'UTF-8' => $_, Encode::FB_PERLQQ )
- } @$_
- ]
- : ( $type eq 'HASH' )
- ? {
- map {
- ( ref($_) or Encode::is_utf8($_) )
- ? $_
- : Encode::decode( 'UTF-8' => $_, Encode::FB_PERLQQ )
- } %$_
- }
- : $_
-} %ARGS;
-
-# Later in the code we use
-# $m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS );
-# instead of $m->call_next to avoid problems with UTF8 keys in arguments.
-# The call_next method pass through original arguments and if you have
-# an argument with unicode key then in a next component you'll get two
-# records in the args hash: one with key without UTF8 flag and another
-# with the flag, which may result into errors. "{ base_comp => $m->request_comp }"
-# is copied from mason's source to get the same results as we get from
-# call_next method, this feature is not documented, so we just leave it
-# here to avoid possible side effects.
-
-# This code canonicalizes time inputs in hours into minutes
-foreach my $field ( keys %ARGS ) {
- next unless $field =~ /^(.*)-TimeUnits$/i && $ARGS{ $1 };
- my $local = $1;
- $ARGS{$local} =~ s{\b (?: (\d+) \s+ )? (\d+)/(\d+) \b}
- {($1 || 0) + $3 ? $2 / $3 : 0}xe;
- if ( $ARGS{$field} && $ARGS{$field} =~ /hours/i ) {
- $ARGS{$local} *= 60;
- }
- delete $ARGS{$field};
-}
+
+%ARGS = RT::Interface::Web::DecodeARGS(\%ARGS);
+
+RT::Interface::Web::PreprocessTimeUpdates(\%ARGS);
+
+
$m->{'rt_base_time'} = [ Time::HiRes::gettimeofday() ];
@@ -288,9 +240,7 @@ unless( $session{'CurrentUser'} ) {
# now it applies not only to home page, but any dashboard
# that can be used as a workspace
-if ( $ARGS{'HomeRefreshInterval'} ) {
- $session{'home_refresh_interval'} = $ARGS{'HomeRefreshInterval'};
-}
+$session{'home_refresh_interval'} = $ARGS{'HomeRefreshInterval'} if ( $ARGS{'HomeRefreshInterval'} );
# we've got credentials, let's serve the file up.
# Process per-page global callbacks
@@ -319,27 +269,8 @@ else {
$m->comp( { base_comp => $m->request_comp }, $m->fetch_next, %ARGS);
}
-if ( $log_sql_statements ) {
- my @log = $RT::Handle->SQLStatementLog;
- $RT::Handle->ClearSQLStatementLog;
- for my $stmt (@log) {
- my ( $time, $sql, $bind, $duration ) = @{$stmt};
- my @bind;
- if ( ref $bind ) {
- @bind = @{$bind};
- }
- else {
- # Older DBIx-SB
- $duration = $bind;
- }
- $RT::Logger->log(
- level => $log_sql_statements,
- message => "SQL(" . sprintf( "%.6f", $duration ) . "s): $sql;"
- . ( @bind ? " [ bound values: @{[map{qq|'$_'|} @bind]} ]" : "" )
- );
- }
-}
+RT::Interface::Web::LogRecordedSQLStatements();
$m->comp( '/Elements/Footer', %ARGS );
commit 9b6f4eab83856df4824144b3713dcb7d68939de0
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Wed Sep 30 02:35:07 2009 +0900
Quiet down an error that makes the test suite go crazy
diff --git a/lib/RT/ACE_Overlay.pm b/lib/RT/ACE_Overlay.pm
index 30cfdf8..f2a2efd 100755
--- a/lib/RT/ACE_Overlay.pm
+++ b/lib/RT/ACE_Overlay.pm
@@ -550,7 +550,7 @@ sub RightName {
return $right if $val eq $self->CanonicalizeRightName($right);
}
- $RT::Logger->crit("Invalid right. Couldn't canonicalize right '$val'");
+ $RT::Logger->error("Invalid right. Couldn't canonicalize right '$val'");
return $val;
}
commit f29334d51880921f74597d09d5179dd7e2997c92
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Wed Sep 30 02:43:00 2009 +0900
Test fix for shredder
diff --git a/t/shredder/03plugin_users.t b/t/shredder/03plugin_users.t
index f96a117..f8b461f 100644
--- a/t/shredder/03plugin_users.t
+++ b/t/shredder/03plugin_users.t
@@ -13,7 +13,7 @@ BEGIN {
}
-my @ARGS = sort qw(limit status name email replace_relations no_tickets);
+my @ARGS = sort qw(limit status name member_of email replace_relations no_tickets);
use_ok('RT::Shredder::Plugin::Users');
{
@@ -25,6 +25,7 @@ use_ok('RT::Shredder::Plugin::Users');
my @args = sort $plugin->SupportArgs;
cmp_deeply(\@args, \@ARGS, "support all args");
+
my ($status, $msg) = $plugin->TestArgs( name => 'r??t*' );
ok($status, "arg name = 'r??t*'") or diag("error: $msg");
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list