[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-507-g57cc84f
Jesse Vincent
jesse at bestpractical.com
Mon Aug 23 19:18:10 EDT 2010
The branch, 3.9-trunk has been updated
via 57cc84f2056eb712cead16d37db211ad44897769 (commit)
via 9c29878405db2b3bf6a18e08500a75b68c7efbf7 (commit)
via e34ee8e75b30a68b27cbbf17b1d0cdd19aadedf7 (commit)
via 4f61ec1cf8eb5ae7a2c97fe86c9026c5de1b4c3f (commit)
via 922f30f5c4ef06a560ead0ecafb3a54986cdcab4 (commit)
via e9cbc5fc500ee6970009b63b0a21b6371297b688 (commit)
via fc931e9d40d3a6f9180be3b8c7ca28252cd4dbe5 (commit)
via fbc6b053376ad5a2aef6a604c3a095aa8dbcf1cb (commit)
via b651b273662485ed8129af395159f460f1056475 (commit)
from f35e290ff40fe14fbe387d385850dd988a5b4571 (commit)
Summary of changes:
lib/RT/Config.pm | 23 ++++++++++++-----------
lib/RT/CurrentUser.pm | 4 +---
lib/RT/Handle.pm | 8 ++++----
lib/RT/Record.pm | 17 +++++++++++++++--
lib/RT/Ticket_Overlay.pm | 15 +++++++++++----
lib/RT/Transaction_Overlay.pm | 18 +++++++++++++++---
t/web/basic.t | 11 ++---------
t/web/compilation_errors.t | 12 ++----------
t/web/rights1.t | 28 ++--------------------------
9 files changed, 64 insertions(+), 72 deletions(-)
- Log -----------------------------------------------------------------
commit b651b273662485ed8129af395159f460f1056475
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 14:59:05 2010 -0400
Avoid using a temporary variable on CurrentUser's CurrentUser
diff --git a/lib/RT/CurrentUser.pm b/lib/RT/CurrentUser.pm
index a506b9e..3a4bff6 100755
--- a/lib/RT/CurrentUser.pm
+++ b/lib/RT/CurrentUser.pm
@@ -266,9 +266,7 @@ Return the current currentuser object
=cut
sub CurrentUser {
- my $self = shift;
- return($self);
-
+ return shift;
}
=head2 Authenticate
commit fbc6b053376ad5a2aef6a604c3a095aa8dbcf1cb
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 14:59:28 2010 -0400
Move our use of File::Spec up to where it's a bit more obvious
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 0d5cb3a..880fd22 100755
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -70,7 +70,7 @@ package RT::Handle;
use strict;
use warnings;
-use vars qw/@ISA/;
+use File::Spec;
=head1 METHODS
@@ -129,7 +129,6 @@ from the config.
=cut
-require File::Spec;
sub BuildDSN {
my $self = shift;
commit fc931e9d40d3a6f9180be3b8c7ca28252cd4dbe5
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 14:59:54 2010 -0400
Remove string eval to set the RT::Handle's superclass
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 880fd22..ddbdb0d 100755
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -82,8 +82,9 @@ L<DBIx::SearchBuilder::Handle>, using the C<DatabaseType> configuration.
=cut
sub FinalizeDatabaseType {
- eval "use DBIx::SearchBuilder::Handle::". RT->Config->Get('DatabaseType') .";
- \@ISA= qw(DBIx::SearchBuilder::Handle::". RT->Config->Get('DatabaseType') .");";
+ eval {
+ use base "DBIx::SearchBuilder::Handle::". RT->Config->Get('DatabaseType');
+ };
if ($@) {
die "Unable to load DBIx::SearchBuilder database handle for '". RT->Config->Get('DatabaseType') ."'.\n".
commit e9cbc5fc500ee6970009b63b0a21b6371297b688
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 15:09:59 2010 -0400
move our reference sigil table outside of the method that uses it to
avoid repeated reinitialization
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index c377308..ef1274d 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -903,6 +903,13 @@ sub SetFromConfig {
return 1;
}
+ our %REF_SYMBOLS = (
+ SCALAR => '$',
+ ARRAY => '@',
+ HASH => '%',
+ CODE => '&',
+ );
+
{
my $last_pack = '';
@@ -917,12 +924,6 @@ sub SetFromConfig {
$pack ||= 'main::';
$pack .= '::' unless substr( $pack, -2 ) eq '::';
- my %ref_sym = (
- SCALAR => '$',
- ARRAY => '@',
- HASH => '%',
- CODE => '&',
- );
no strict 'refs';
my $name = undef;
@@ -956,7 +957,7 @@ sub SetFromConfig {
# if references are equal then we've found
if ( $entry_ref == $ref ) {
$last_pack = $pack;
- return ( $ref_sym{ ref($ref) } || '*' ) . $pack . $k;
+ return ( $REF_SYMBOLS{ ref($ref) } || '*' ) . $pack . $k;
}
}
return '';
commit 922f30f5c4ef06a560ead0ecafb3a54986cdcab4
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 15:11:08 2010 -0400
Use the same idiom for determining if a string ends in "::" as we use
earlier, as it's 7x as fast as a regex match
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index ef1274d..016cf36 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -930,12 +930,12 @@ sub SetFromConfig {
# scan $pack's nametable(hash)
foreach my $k ( keys %{$pack} ) {
- # hash for main:: has reference on itself
+ # The hash for main:: has a reference to itself
next if $k eq 'main::';
- # if entry has trailing '::' then
- # it is link to other name space
- if ( $k =~ /::$/ ) {
+ # if the entry has a trailing '::' then
+ # it is a link to another name space
+ if ( substr( $k, -2 ) eq '::') {
$name = $self->__GetNameByRef( $ref, $k );
return $name if $name;
}
commit 4f61ec1cf8eb5ae7a2c97fe86c9026c5de1b4c3f
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 15:42:39 2010 -0400
Override bits of SearchBuilder that RT doesn't need to be calling since
we always use 'id' as a pkey. Should shave just a bit off runtime
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 022767e..691c190 100755
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -92,7 +92,6 @@ sub _Init {
# }}}
-# {{{ _PrimaryKeys
=head2 _PrimaryKeys
@@ -101,8 +100,22 @@ The primary keys for RT classes is 'id'
=cut
sub _PrimaryKeys { return ['id'] }
+# short circuit many, many thousands of calls from searchbuilder
+sub _PrimaryKey { 'id' }
+
+=head2 Id
+
+Override L<DBIx::SearchBuilder/Id> to avoid a few lookups RT doesn't do
+on a very common codepath
+
+C<id> is an alias to C<Id> and is the preferred way to call this method.
+
+=cut
+
+sub Id {
+ return shift->{values}->{id};
+}
-# }}}
=head2 Delete
commit e34ee8e75b30a68b27cbbf17b1d0cdd19aadedf7
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 16:14:41 2010 -0400
Cache the ticket's QueueObj from the first time we look at it until the
ticket's queue is changed
diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm
index c863189..8dc06b6 100755
--- a/lib/RT/Ticket_Overlay.pm
+++ b/lib/RT/Ticket_Overlay.pm
@@ -1807,7 +1807,11 @@ sub SetQueue {
my ($status, $msg) = $self->_Set( Field => 'Queue', Value => $NewQueueObj->Id() );
+
if ( $status ) {
+ # Clear the queue object cache;
+ $self->{_queue_obj} = undef;
+
# On queue change, change queue for reminders too
my $reminder_collection = $self->Reminders->Collection;
while ( my $reminder = $reminder_collection->Next ) {
@@ -1832,11 +1836,14 @@ Takes nothing. returns this ticket's queue object
sub QueueObj {
my $self = shift;
- my $queue_obj = RT::Queue->new( $self->CurrentUser );
+ if(!$self->{_queue_obj} || ! $self->{_queue_obj}->id) {
- #We call __Value so that we can avoid the ACL decision and some deep recursion
- my ($result) = $queue_obj->Load( $self->__Value('Queue') );
- return ($queue_obj);
+ $self->{_queue_obj} = RT::Queue->new( $self->CurrentUser );
+
+ #We call __Value so that we can avoid the ACL decision and some deep recursion
+ my ($result) = $self->{_queue_obj}->Load( $self->__Value('Queue') );
+ }
+ return ($self->{_queue_obj});
}
# }}}
commit 9c29878405db2b3bf6a18e08500a75b68c7efbf7
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 18:52:49 2010 -0400
Replace older login infrastructure from a few test files with RT core
login routines that don't break on new WWW::Mechanize
diff --git a/t/web/basic.t b/t/web/basic.t
index bc4d655..3f94e73 100644
--- a/t/web/basic.t
+++ b/t/web/basic.t
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Encode;
-use RT::Test tests => 24;
+use RT::Test tests => 21;
$RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
my ($baseurl, $agent) = RT::Test->started_ok;
@@ -20,15 +20,8 @@ diag $url if $ENV{TEST_VERBOSE};
# test a login
{
- ok($agent->{form}->find_input('user'));
- ok($agent->{form}->find_input('pass'));
-
- ok($agent->{'content'} =~ /username:/i);
- $agent->field( 'user' => 'root' );
- $agent->field( 'pass' => 'password' );
-
+ $agent->login('root' => 'password');
# the field isn't named, so we have to click link 0
- $agent->click(0);
is( $agent->{'status'}, 200, "Fetched the page ok");
ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
}
diff --git a/t/web/compilation_errors.t b/t/web/compilation_errors.t
index e8cfca7..0607e7a 100644
--- a/t/web/compilation_errors.t
+++ b/t/web/compilation_errors.t
@@ -7,7 +7,7 @@ BEGIN {
sub wanted {
-f && /\.html$/ && $_ !~ /Logout.html$/;
}
- my $tests = 7;
+ my $tests = 4;
find( sub { wanted() and $tests += 4 }, 'share/html/' );
plan tests => $tests;
}
@@ -36,15 +36,7 @@ is ($agent->{'status'}, 200, "Loaded a page");
# {{{ test a login
# follow the link marked "Login"
-
-ok($agent->{form}->find_input('user'));
-
-ok($agent->{form}->find_input('pass'));
-like ($agent->{'content'} , qr/username:/i);
-$agent->field( 'user' => 'root' );
-$agent->field( 'pass' => 'password' );
-# the field isn't named, so we have to click link 0
-$agent->click(0);
+$agent->login(root => 'password');
is($agent->{'status'}, 200, "Fetched the page ok");
like( $agent->{'content'} , qr/Logout/i, "Found a logout link");
diff --git a/t/web/rights1.t b/t/web/rights1.t
index 6da204c..c8892f2 100644
--- a/t/web/rights1.t
+++ b/t/web/rights1.t
@@ -2,7 +2,7 @@
use strict;
use HTTP::Cookies;
-use RT::Test tests => 35;
+use RT::Test tests => 29;
my ($baseurl, $agent) = RT::Test->started_ok;
# Create a user with basically no rights, to start.
@@ -26,7 +26,7 @@ $agent->cookie_jar($cookie_jar);
no warnings 'once';
# get the top page
-login($agent, $user_obj);
+$agent->login( $user_obj->Name, 'customer');
# Test for absence of Configure and Preferences tabs.
ok(!$agent->find_link( url => "$RT::WebPath/Admin/",
@@ -107,28 +107,4 @@ ok($agent->form_name('BuildQuery'), "Yep, form is still there");
my $input = $agent->current_form->find_input('ValueOfActor');
ok(grep(/customer-$$/, $input->value_names()), "Found self in the actor listing");
-sub login {
- my $agent = shift;
-
- my $url = "http://localhost:" . RT->Config->Get('WebPort') . RT->Config->Get('WebPath') . "/";
- $agent->get($url);
- is( $agent->{'status'}, 200,
- "Loaded a page - http://localhost" . RT->Config->Get('WebPath') );
-
- # {{{ test a login
-
- # follow the link marked "Login"
-
- ok( $agent->{form}->find_input('user') );
-
- ok( $agent->{form}->find_input('pass') );
- like( $agent->{'content'} , qr/username:/i );
- $agent->field( 'user' => $user_obj->Name );
- $agent->field( 'pass' => 'customer' );
-
- # the field isn't named, so we have to click link 0
- $agent->click(0);
- is( $agent->{'status'}, 200, "Fetched the page ok" );
- like( $agent->{'content'} , qr/Logout/i, "Found a logout link" );
-}
1;
commit 57cc84f2056eb712cead16d37db211ad44897769
Author: Jesse Vincent <jesse at bestpractical.com>
Date: Mon Aug 23 19:18:59 2010 -0400
Fix t/web/ticket_txn_content.t by actually making
Transaction->ContentObj recurse on multipart/mixed.
diff --git a/lib/RT/Transaction_Overlay.pm b/lib/RT/Transaction_Overlay.pm
index a838579..c462184 100755
--- a/lib/RT/Transaction_Overlay.pm
+++ b/lib/RT/Transaction_Overlay.pm
@@ -415,11 +415,16 @@ Returns the RT::Attachment object which contains the content for this Transactio
sub ContentObj {
my $self = shift;
- my %args = ( Type => $PreferredContentType, @_ );
+ my %args = ( Type => $PreferredContentType, Attachment => undef, @_ );
# If we don't have any content, return undef now.
# Get the set of toplevel attachments to this transaction.
- return undef unless my $Attachment = $self->Attachments->First;
+
+ my $Attachment = $args{'Attachment'};
+
+ $Attachment ||= $self->Attachments->First;
+
+ return undef unless ($Attachment);
# If it's a textual part, just return the body.
if ( RT::I18N::IsTextualContentType($Attachment->ContentType) ) {
@@ -429,7 +434,14 @@ sub ContentObj {
# If it's a multipart object, first try returning the first part with preferred
# MIME type ('text/plain' by default).
- elsif ( $Attachment->ContentType =~ '^multipart/' ) {
+ elsif ( $Attachment->ContentType =~ qr|^multipart/mixed|i ) {
+ my $kids = $Attachment->Children;
+ while (my $child = $kids->Next) {
+ my $ret = $self->ContentObj(%args, Attachment => $child);
+ return $ret if ($ret);
+ }
+ }
+ elsif ( $Attachment->ContentType =~ qr|^multipart/|i ) {
if ( $args{Type} ) {
my $plain_parts = $Attachment->Children;
$plain_parts->ContentType( VALUE => $args{Type} );
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list