[Rt-commit] rt branch, 4.2/record-attachments-insert-failure, created. rt-4.2.10rc1-1-gad4925c

? sunnavy sunnavy at bestpractical.com
Mon Feb 9 15:24:41 EST 2015


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

- Log -----------------------------------------------------------------
commit ad4925c468b9a38329873e22b9f6bde7c12b5471
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 af9b088..1c0f7bb 100644
--- a/lib/RT/Attachment.pm
+++ b/lib/RT/Attachment.pm
@@ -174,6 +174,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);
         }
 
@@ -218,6 +223,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 7dc7809..e9e9d99 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1800,6 +1800,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 3b420e9..655b706 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