[Rt-commit] r11690 - in rt/branches/3.8-TESTING: . bin html/Ticket lib/RT/Action lib/RT/Interface/Web

ruz at bestpractical.com ruz at bestpractical.com
Fri Apr 11 15:00:58 EDT 2008


Author: ruz
Date: Fri Apr 11 15:00:58 2008
New Revision: 11690

Modified:
   rt/branches/3.8-TESTING/   (props changed)
   rt/branches/3.8-TESTING/bin/rt-crontool.in
   rt/branches/3.8-TESTING/configure.ac
   rt/branches/3.8-TESTING/html/Ticket/Display.html
   rt/branches/3.8-TESTING/lib/RT/Action/SendEmail.pm
   rt/branches/3.8-TESTING/lib/RT/Interface/Email.pm
   rt/branches/3.8-TESTING/lib/RT/Interface/Web.pm
   rt/branches/3.8-TESTING/lib/RT/Interface/Web/Request.pm
   rt/branches/3.8-TESTING/releng.cnf

Log:
3.7-RTIR-RELENG -> 3.8-TESTING

 r11102 at localhost (orig r11065):  ruz | 2008-03-13 19:56:59 +0300
 * fix typo that affects logic of operations.
   Thanks to Salih Gonullu
 
 r11206 at localhost (orig r11169):  ruz | 2008-03-25 01:34:46 +0300
 * we have new code that does the same in ListActions
 r11207 at localhost (orig r11170):  ruz | 2008-03-25 01:35:18 +0300
 * fix test, we've changed wording of messages
 r11219 at localhost (orig r11182):  ruz | 2008-03-25 07:20:36 +0300
 * bump version
 r11650 at localhost (orig r11613):  ruz | 2008-04-07 17:11:30 +0400
 * fix typos in the doc, we naver had --xxx-argument,
   it always has been --xxx-arg
 r11660 at localhost (orig r11623):  ruz | 2008-04-07 19:52:21 +0400
 * minor
 r11661 at localhost (orig r11624):  ruz | 2008-04-07 19:57:10 +0400
 * add support for `... --transaction all` variant
 * make --transaction-type a comma separated list of types
 * add back dealing with no transactions, no more defaulting to 'first'
 * it's now possible to do something like:
     ./bin/rt-crontool --verbose \
         --search RT::Search::FromSQL
         --search-arg 'id > 0'
         --action RT::Action::RTIR_FindIP
         --transaction all
         --transaction-type 'Create,Comment,Correspond'
 
 r11724 at localhost (orig r11687):  ruz | 2008-04-11 22:50:20 +0400
 * clean up callbacks, try to avoid porblems an user experience
 r11725 at localhost (orig r11688):  ruz | 2008-04-11 22:52:14 +0400
 * update license tagger


Modified: rt/branches/3.8-TESTING/bin/rt-crontool.in
==============================================================================
--- rt/branches/3.8-TESTING/bin/rt-crontool.in	(original)
+++ rt/branches/3.8-TESTING/bin/rt-crontool.in	Fri Apr 11 15:00:58 2008
@@ -92,12 +92,11 @@
 
 help() if $help or not $search or not $action;
 
-$transaction ||= 'first';
-unless ( $transaction =~ /^(first|last)$/i ) {
-    print STDERR loc("--transaction argument could be only 'first' or 'last'");
+$transaction = lc( $transaction||'' );
+if ( $transaction && $transaction !~ /^(first|all|last)$/i ) {
+    print STDERR loc("--transaction argument could be only 'first', 'last' or 'all'");
     exit 1;
 }
-$transaction = lc($transaction) eq 'first'? 'ASC': 'DESC';
 
 # We _must_ have a search object
 load_module($search);
@@ -132,9 +131,28 @@
 while ( my $ticket = $tickets->Next() ) {
     print $ticket->Id() . ": " if ($verbose);
 
-    my $transaction = get_transaction($ticket);
-    print loc("Using transaction #[_1]...", $transaction->id)
-        if $verbose && $transaction;
+    if ( $transaction ) {
+        my $txns = get_transactions($ticket);
+        my $found = 0;
+        while ( my $txn = $txns->Next ) {
+            print loc("Using transaction #[_1]...", $txn->id)
+                if $verbose;
+            process($ticket, $txn);
+            $found = 1;
+        }
+        print loc("Couldn't find suitable transaction, skipping")
+            if $verbose && !$found;
+    } else {
+        print loc("Processing without transaction, some conditions and actions may fail. Consider using --transaction argument")
+            if $verbose;
+
+        process($ticket);
+    }
+}
+
+sub process {
+    my $ticket = shift;
+    my $transaction = shift;
 
     # perform some more advanced check
     if ($condition) {
@@ -149,8 +167,8 @@
 
         # if the condition doesn't apply, get out of here
 
-        next unless ( $condition_obj->IsApplicable );
-        print loc("Condition matches...") if ($verbose);
+        return unless $condition_obj->IsApplicable;
+        print loc("Condition matches...") if $verbose;
     }
 
     #prepare our action
@@ -165,32 +183,39 @@
     );
 
     #if our preparation, move onto the next ticket
-    next unless ( $action_obj->Prepare );
-    print loc("Action prepared...") if ($verbose);
+    return unless $action_obj->Prepare;
+    print loc("Action prepared...") if $verbose;
 
     #commit our action.
-    next unless ( $action_obj->Commit );
-    print loc("Action committed.\n") if ($verbose);
+    return unless $action_obj->Commit;
+    print loc("Action committed.\n") if $verbose;
 }
 
-=head2 get_transaction
+=head2 get_transactions
 
-Takes ticket and returns its transaction acording to command
-line arguments C<--transaction> and <--transaction-type>.
+Takes ticket and returns L<RT::Transactions> object with transactions
+of the ticket according to command line arguments C<--transaction>
+and <--transaction-type>.
 
 =cut
 
-sub get_transaction {
+sub get_transactions {
     my $ticket = shift;
     my $txns = $ticket->Transactions;
+    my $order = $transaction eq 'last'? 'DESC': 'ASC';
     $txns->OrderByCols(
-        { FIELD => 'Created', ORDER => $transaction },
-        { FIELD => 'id', ORDER => $transaction },
+        { FIELD => 'Created', ORDER => $order },
+        { FIELD => 'id', ORDER => $order },
     );
-    $txns->Limit( FIELD => 'Type', VALUE => $transaction_type )
-        if $transaction_type;
-    $txns->RowsPerPage(1);
-    return $txns->First;
+    if ( $transaction_type ) {
+        $transaction_type =~ s/^\s+//;
+        $transaction_type =~ s/\s+$//;
+        foreach my $type ( split /\s*,\s*/, $transaction_type ) {
+            $txns->Limit( FIELD => 'Type', VALUE => $type, ENTRYAGGREGATOR => 'OR' );
+        }
+    }
+    $txns->RowsPerPage(1) unless $transaction eq 'all';
+    return $txns;
 }
 
 # {{{ load_module 
@@ -236,29 +261,29 @@
       . loc( "[_1] - Specify the search module you want to use", "--search" )
       . "\n";
     print "	"
-      . loc( "[_1] - An argument to pass to [_2]", "--search-argument", "--search" )
+      . loc( "[_1] - An argument to pass to [_2]", "--search-arg", "--search" )
       . "\n";
 
     print "	"
       . loc( "[_1] - Specify the condition module you want to use", "--condition" )
       . "\n";
     print "	"
-      . loc( "[_1] - An argument to pass to [_2]", "--condition-argument", "--condition" )
+      . loc( "[_1] - An argument to pass to [_2]", "--condition-arg", "--condition" )
       . "\n";
     print "	"
       . loc( "[_1] - Specify the action module you want to use", "--action" )
       . "\n";
     print "	"
-      . loc( "[_1] - An argument to pass to [_2]", "--action-argument", "--action" )
+      . loc( "[_1] - An argument to pass to [_2]", "--action-arg", "--action" )
       . "\n";
     print "	"
       . loc( "[_1] - Specify id of the template you want to use", "--template-id" )
       . "\n";
     print "	"
-      . loc( "[_1] - Specify if you want to use either 'first' or 'last' transaction", "--transaction" )
+      . loc( "[_1] - Specify if you want to use either 'first', 'last' or 'all' transactions", "--transaction" )
       . "\n";
     print "	"
-      . loc( "[_1] - Specify the type of a transaction you want to use", "--transaction-type" )
+      . loc( "[_1] - Specify the comma separated list of transactions' types you want to use", "--transaction-type" )
       . "\n";
     print "	"
       . loc( "[_1] - Output status updates to STDOUT", "--verbose" ) . "\n";

Modified: rt/branches/3.8-TESTING/configure.ac
==============================================================================

Modified: rt/branches/3.8-TESTING/html/Ticket/Display.html
==============================================================================
--- rt/branches/3.8-TESTING/html/Ticket/Display.html	(original)
+++ rt/branches/3.8-TESTING/html/Ticket/Display.html	Fri Apr 11 15:00:58 2008
@@ -191,8 +191,6 @@
     $session{'i'}++;
 
     RT::Interface::Web::Redirect(RT->Config->Get('WebURL') ."Ticket/Display.html?id=".$TicketObj->id);
-} else {
-    @Actions = @{ delete $session{"Actions"} || [] };
 }
 
 my $attachments = $m->comp('Elements/FindAttachments', Ticket => $TicketObj, Tickets => $Tickets);

Modified: rt/branches/3.8-TESTING/lib/RT/Action/SendEmail.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Action/SendEmail.pm	(original)
+++ rt/branches/3.8-TESTING/lib/RT/Action/SendEmail.pm	Fri Apr 11 15:00:58 2008
@@ -215,7 +215,7 @@
     my $attachment = $self->TransactionObj->Attachments->First;
     if ( $attachment && !( $attachment->GetHeader('X-RT-Encrypt') || $self->TicketObj->QueueObj->Encrypt ) ) {
         $attachment->SetHeader( 'X-RT-Encrypt' => 1 )
-            if $attachment->GetHeader("X-RT-Incoming-Encryption")||'' eq 'Success';
+            if ($attachment->GetHeader("X-RT-Incoming-Encryption")||'') eq 'Success';
     }
 
     return $result;

Modified: rt/branches/3.8-TESTING/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Interface/Email.pm	(original)
+++ rt/branches/3.8-TESTING/lib/RT/Interface/Email.pm	Fri Apr 11 15:00:58 2008
@@ -717,7 +717,7 @@
         # if the passphrase fails, either you have a bad passphrase
         # or gpg-agent has died.  That should get caught in Create and
         # Update, but at least throw an error here
-        if (($line->{'Operation'}||'' eq 'PassphraseCheck')
+        if (($line->{'Operation'}||'') eq 'PassphraseCheck'
             && $line->{'Status'} =~ /^(?:BAD|MISSING)$/ ) {
             $RT::Logger->error( "$line->{'Status'} PASSPHRASE: $line->{'Message'}" );
             return 0;

Modified: rt/branches/3.8-TESTING/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Interface/Web.pm	(original)
+++ rt/branches/3.8-TESTING/lib/RT/Interface/Web.pm	Fri Apr 11 15:00:58 2008
@@ -1239,7 +1239,7 @@
                 my $CustomFieldObj = RT::CustomField->new( $session{'CurrentUser'} );
                 $CustomFieldObj->LoadById( $cf );
                 unless ( $CustomFieldObj->id ) {
-                    $RT::Logger->warning("Couldn't load custom field #$id");
+                    $RT::Logger->warning("Couldn't load custom field #$cf");
                     next;
                 }
                 push @results, _ProcessObjectCustomFieldUpdates(

Modified: rt/branches/3.8-TESTING/lib/RT/Interface/Web/Request.pm
==============================================================================
--- rt/branches/3.8-TESTING/lib/RT/Interface/Web/Request.pm	(original)
+++ rt/branches/3.8-TESTING/lib/RT/Interface/Web/Request.pm	Fri Apr 11 15:00:58 2008
@@ -116,10 +116,11 @@
 
     my $CacheKey = "$page--$name";
     return 1 if delete $args{'CallbackOnce'} && $called{ $CacheKey };
-    ++$called{ $CacheKey };
+    $called{ $CacheKey } = 1;
 
     my $callbacks = $cache{ $CacheKey };
     unless ( $callbacks ) {
+        $callbacks = [];
         my $path  = "/Callbacks/*$page/$name";
         my @roots = map $_->[1],
                         $HTML::Mason::VERSION <= 1.28
@@ -127,18 +128,20 @@
                             : $self->interp->comp_root_array;
 
         my %seen;
-        @$callbacks = sort map { 
-                # Skip backup files, files without a leading package name,
-                # and files we've already seen
-                grep !$seen{$_}++ && !m{/\.} && !m{~$} && m{^/Callbacks/[^/]+\Q$page/$name\E$},
-                $self->interp->resolver->glob_path($path, $_);
-            } @roots;
+        @$callbacks = (
+            sort grep defined && length,
+            # Skip backup files, files without a leading package name,
+            # and files we've already seen
+            grep !$seen{$_}++ && !m{/\.} && !m{~$} && m{^/Callbacks/[^/]+\Q$page/$name\E$},
+            map $self->interp->resolver->glob_path($path, $_),
+            @roots
+        );
 
         $cache{ $CacheKey } = $callbacks unless RT->Config->Get('DevelMode');
     }
 
     my @rv;
-    push @rv, scalar $self->comp( $_, %args) foreach @$callbacks;
+    push @rv, scalar $self->comp( $_, %args ) foreach @$callbacks;
     return @rv;
 }
 }

Modified: rt/branches/3.8-TESTING/releng.cnf
==============================================================================


More information about the Rt-commit mailing list