[Rt-commit] rt branch, 4.4/external-storage, updated. rt-4.2.11-34-g4cfc6b5

Shawn Moore shawn at bestpractical.com
Fri May 22 14:29:22 EDT 2015


The branch, 4.4/external-storage has been updated
       via  4cfc6b50c49d7168f06df89b3cf3356c86a888a3 (commit)
      from  701dcbd4c4e42ecb421418b9dfe155ff91d048d7 (commit)

Summary of changes:
 lib/RT/ExternalStorage.pm | 28 ----------------------------
 lib/RT/Record.pm          | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 28 deletions(-)

- Log -----------------------------------------------------------------
commit 4cfc6b50c49d7168f06df89b3cf3356c86a888a3
Author: Shawn M Moore <shawn at bestpractical.com>
Date:   Fri May 22 18:22:09 2015 +0000

    Inline RT::Record::_DecodeLOB monkeypatch

diff --git a/lib/RT/ExternalStorage.pm b/lib/RT/ExternalStorage.pm
index 41a14a3..abf7ada 100644
--- a/lib/RT/ExternalStorage.pm
+++ b/lib/RT/ExternalStorage.pm
@@ -146,32 +146,4 @@ sub Store {
 }
 
 
-package RT::Record;
-
-no warnings 'redefine';
-my $__DecodeLOB = __PACKAGE__->can('_DecodeLOB');
-*_DecodeLOB = sub {
-    my $self            = shift;
-    my $ContentType     = shift || '';
-    my $ContentEncoding = shift || 'none';
-    my $Content         = shift;
-    my $Filename        = @_;
-
-    return $__DecodeLOB->($self, $ContentType, $ContentEncoding, $Content, $Filename)
-        unless $ContentEncoding eq "external";
-
-    unless ($BACKEND) {
-        RT->Logger->error( "Failed to load $Content; external storage not configured" );
-        return ("");
-    };
-
-    my ($ok, $msg) = $BACKEND->Get( $Content );
-    unless (defined $ok) {
-        RT->Logger->error( "Failed to load $Content from external storage: $msg" );
-        return ("");
-    }
-
-    return $__DecodeLOB->($self, $ContentType, 'none', $ok, $Filename);
-};
-
 1;
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 7cf116a..365b9e5 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -888,6 +888,22 @@ sub _DecodeLOB {
     my $ContentEncoding = shift || 'none';
     my $Content         = shift;
 
+    if ($ContentEncoding eq 'external') {
+        unless ($RT::ExternalStorage::BACKEND) {
+            RT->Logger->error( "Failed to load $Content; external storage not configured" );
+            return ("");
+        };
+
+        my ($ok, $msg) = $RT::ExternalStorage::BACKEND->Get( $Content );
+        unless (defined $ok) {
+            RT->Logger->error( "Failed to load $Content from external storage: $msg" );
+            return ("");
+        }
+
+        $Content = $ok;
+        $ContentEncoding = 'none';
+    }
+
     RT::Util::assert_bytes( $Content );
 
     if ( $ContentEncoding eq 'base64' ) {

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


More information about the rt-commit mailing list