[Rt-commit] rt branch, 4.2/record-attachments-insert-failure, created. rt-4.2.5-167-gb877ec6

? sunnavy sunnavy at bestpractical.com
Mon Feb 9 10:32:34 EST 2015


The branch, 4.2/record-attachments-insert-failure has been created
        at  b877ec6fa9d7ff82f9e7abf2e821088253c9941c (commit)

- Log -----------------------------------------------------------------
commit b877ec6fa9d7ff82f9e7abf2e821088253c9941c
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Oct 1 10:14:21 2014 +0800

    record attachment insert error to txn
    
    Fixes: #30419

diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
index 4c5322f..842857b 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -177,6 +177,11 @@ sub Create {
 
         unless ($id) {
             $RT::Logger->crit("Attachment insert failed - ". $RT::Handle->dbh->errstr);
+            my $txn = RT::Transaction->new($self->CurrentUser);
+            $txn->Load($args{'TransactionId'});
+            if ( $txn->id ) {
+                $txn->Object->_NewTransaction( Type => 'AttachmentError', ActivateScrips => 0, Data => $Filename );
+            }
             return ($id);
         }
 
@@ -221,6 +226,11 @@ sub Create {
         }
         else {
             $RT::Logger->crit("Attachment insert failed: ". $RT::Handle->dbh->errstr);
+            my $txn = RT::Transaction->new($self->CurrentUser);
+            $txn->Load($args{'TransactionId'});
+            if ( $txn->id ) {
+                $txn->Object->_NewTransaction( Type => 'AttachmentError', ActivateScrips => 0, Data => $Filename );
+            }
         }
         return $id;
     }
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 5ef69c6..aa57946 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1797,6 +1797,7 @@ our %TRANSACTION_CLASSIFICATION = (
     SystemError => 'error',
     AttachmentTruncate => 'attachment-truncate',
     AttachmentDrop => 'attachment-drop',
+    AttachmentError => 'error',
     __default => 'other',
 );
 
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index ae97628..df8a535 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -863,6 +863,15 @@ sub _FormatUser {
                 $self->OldValue, $self->NewValue ); #loc()
         }
     },
+    AttachmentError => sub {
+        my $self = shift;
+        if ( defined $self->Data ) {
+            return ( "File '[_1]' insert failed. See error log for details.", $self->Data ); #loc()
+        }
+        else {
+            return ( "Content insert failed. See error log for details." ); #loc()
+        }
+    },
     "Forward Transaction" => sub {
         my $self = shift;
         my $recipients = join ", ", map {

-----------------------------------------------------------------------


More information about the rt-commit mailing list