[Rt-commit] rt branch, 4.2/remove-misleading-scrips-debug-line, created. rt-4.1.8-505-gabb4f03
Alex Vandiver
alexmv at bestpractical.com
Tue May 28 19:48:13 EDT 2013
The branch, 4.2/remove-misleading-scrips-debug-line has been created
at abb4f03266f0f6d01ade8f541aad42169fcaeef3 (commit)
- Log -----------------------------------------------------------------
commit abb4f03266f0f6d01ade8f541aad42169fcaeef3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Tue May 28 19:33:31 2013 -0400
Do not log "About to think about scrips" for non-Tickets
This debug message is misleading, as it implies that scrips might
possibly be able to fire on a non-Ticket object -- omit it entirely for
non-ticket objects.
There is one other case where it was not immediately followed by "About
to prepare scrips": for outgoing mail transactions. For such cases,
instead emit an explicit "Skipping scrips" debug message.
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index a7f87bd..0102384 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -172,41 +172,47 @@ sub Create {
Content => RT::User->CanonicalizeEmailAddress($_)
) for @{$args{'SquelchMailTo'} || []};
- #Provide a way to turn off scrips if we need to
- $RT::Logger->debug('About to think about scrips for transaction #' .$self->Id);
- if ( $args{'ActivateScrips'} and $args{'ObjectType'} eq 'RT::Ticket' ) {
- $self->{'scrips'} = RT::Scrips->new(RT->SystemUser);
-
- $RT::Logger->debug('About to prepare scrips for transaction #' .$self->Id);
-
- $self->{'scrips'}->Prepare(
- Stage => 'TransactionCreate',
- Type => $args{'Type'},
- Ticket => $args{'ObjectId'},
- Transaction => $self->id,
- );
+ my @return = ( $id, $self->loc("Transaction Created") );
- # Entry point of the rule system
- my $ticket = RT::Ticket->new(RT->SystemUser);
- $ticket->Load($args{'ObjectId'});
- my $txn = RT::Transaction->new($RT::SystemUser);
- $txn->Load($self->id);
-
- my $rules = $self->{rules} = RT::Ruleset->FindAllRules(
- Stage => 'TransactionCreate',
- Type => $args{'Type'},
- TicketObj => $ticket,
- TransactionObj => $txn,
- );
-
- if ($args{'CommitScrips'} ) {
- $RT::Logger->debug('About to commit scrips for transaction #' .$self->Id);
- $self->{'scrips'}->Commit();
- RT::Ruleset->CommitRules($rules);
- }
+ return @return unless $args{'ObjectType'} eq 'RT::Ticket';
+
+ # Provide a way to turn off scrips if we need to
+ unless ( $args{'ActivateScrips'} ) {
+ $RT::Logger->debug('Skipping scrips for transaction #' .$self->Id);
+ return @return;
+ }
+
+ $self->{'scrips'} = RT::Scrips->new(RT->SystemUser);
+
+ $RT::Logger->debug('About to prepare scrips for transaction #' .$self->Id);
+
+ $self->{'scrips'}->Prepare(
+ Stage => 'TransactionCreate',
+ Type => $args{'Type'},
+ Ticket => $args{'ObjectId'},
+ Transaction => $self->id,
+ );
+
+ # Entry point of the rule system
+ my $ticket = RT::Ticket->new(RT->SystemUser);
+ $ticket->Load($args{'ObjectId'});
+ my $txn = RT::Transaction->new($RT::SystemUser);
+ $txn->Load($self->id);
+
+ my $rules = $self->{rules} = RT::Ruleset->FindAllRules(
+ Stage => 'TransactionCreate',
+ Type => $args{'Type'},
+ TicketObj => $ticket,
+ TransactionObj => $txn,
+ );
+
+ if ($args{'CommitScrips'} ) {
+ $RT::Logger->debug('About to commit scrips for transaction #' .$self->Id);
+ $self->{'scrips'}->Commit();
+ RT::Ruleset->CommitRules($rules);
}
- return ( $id, $self->loc("Transaction Created") );
+ return @return;
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list