[Rt-commit] rt branch, 4.4/rt-munge-attachments, repushed

Craig Kaiser craig at bestpractical.com
Tue Dec 4 14:20:21 EST 2018


The branch 4.4/rt-munge-attachments was deleted and repushed:
       was 4a2c28789f7b623233ffd5fe9cc12d30c297004c
       now ba71083b7f650008cd620799350bd222f70dd715

1: 8b89c18ea ! 1: c2bc4a96d Create ReplaceAttachments, ReplaceHeader and ReplaceContent Methods
    @@ -23,7 +23,7 @@
     +sub ReplaceHeaders {
     +    my $self = shift;
     +    my %args = (
    -+        Search   => undef,
    ++        Search      => undef,
     +        Replacement => '',
     +        @_,
     +    );
    @@ -33,8 +33,8 @@
     +    foreach my $header ($self->SplitHeaders) {
     +        my ( $tag, $value ) = split /:/, $header, 2;
     +        if ( $value =~ s/\Q$args{Search}\E/$args{Replacement}/ig ) {
    -+            my ( $ret, $msg ) = $self->SetHeader( $tag, $value );
    -+            return ($ret, $msg) unless $ret;
    ++            my $ret = $self->SetHeader( $tag, $value );
    ++            RT::Logger->error("Could not set header: $tag to $value") unless $ret;
     +        }
     +    }
     +    return (1, 'Headers cleared');
    @@ -62,7 +62,7 @@
     +
     +    if ( $content && $content =~ s/\Q$args{Search}\E/$args{Replacement}/ig ) {
     +        my ($ret, $msg) = $self->_Set( Field => 'Content', Value => $content );
    -+        return ($ret, $msg);
    ++        return ($ret, 'Content replaced');
     +    }
     +    return(1, 'No content matches found');
     +}
    @@ -105,7 +105,6 @@
     +        VALUE           => $args{Search},
     +        SUBCLAUSE       => 'Attachments',
     +    ) if $args{Headers};
    -+
     +    $self->Limit(
     +        ENTRYAGGREGATOR => 'OR',
     +        FIELD           => 'Content',
    @@ -129,24 +128,27 @@
     +        my $content_replaced;
     +        if ( $args{Headers} ) {
     +            ($ret, $msg) = $attachment->ReplaceHeaders(Search => $args{Search}, Replacement => $args{Replacement});
    ++            $content_replaced ||= $ret;
    ++
     +            RT::Logger->error($msg) unless $ret;
    -+            $content_replaced ||= $ret;
     +        }
    -+        RT::Logger->error($msg) unless $ret;
    ++
     +        if ( $args{Content} ) {
     +            ($ret, $msg) = $attachment->ReplaceContent(Search => $args{Search}, Replacement => $args{Replacement});
    ++            $content_replaced ||= $ret;
    ++
     +            RT::Logger->error($msg) unless $ret;
    -+            $content_replaced ||= $ret;
     +        }
    -+        RT::Logger->error($msg) unless $ret;
    ++
     +        my $ticket = $attachment->TransactionObj->TicketObj;
     +        $tickets{$ticket->Id} ||= $ticket if $content_replaced;
     +    }
    -+     foreach my $id ( sort { $a <=> $b } keys %tickets ) {
    -+        (my $trans, $msg) = $tickets{$id}->_NewTransaction (
    ++
    ++    foreach my $id ( sort { $a <=> $b } keys %tickets ) {
    ++        (my $transaction, $msg, my $trans) = $tickets{$id}->_NewTransaction (
     +            Type     => "Munge",
     +        );
    -+        RT::Logger->error($msg) unless $trans;
    ++        RT::Logger->error($msg) unless $transaction;
     +    }
     +    my $count = scalar keys %tickets;
     +    return (1, "Updated $count ticket's attachment content");
2: e77f0b59d = 2: 95698719d Create rt-munge-attachments executable
3: 4a2c28789 ! 3: ba71083b7 Add tests for methods that munge the attachments table
    @@ -38,7 +38,7 @@
     +    is $attachments->Count, 1, 'Found content with "test"';
     +
     +    # Replace attachment value for 'test' in Conetent col
    -+    my ($ret, $msg) = $attachments->ReplaceAttachments(Search => 'test', Replacement => 'new_value', Header => 0);
    ++    my ($ret, $msg) = $attachments->ReplaceAttachments(Search => 'test', Replacement => 'new_value', Headers => 0);
     +    ok $ret, $msg;
     +
     +    $attachments->CleanSlate;



More information about the rt-commit mailing list