[Rt-commit] rt branch, 4.2/serialize-objectscrips, created. rt-4.2.6-38-gd9ad9c5

Alex Vandiver alexmv at bestpractical.com
Fri Aug 15 15:08:16 EDT 2014


The branch, 4.2/serialize-objectscrips has been created
        at  d9ad9c5dbfc86eb0f1de61dd989d652e8dee8e84 (commit)

- Log -----------------------------------------------------------------
commit d9ad9c5dbfc86eb0f1de61dd989d652e8dee8e84
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Aug 15 15:06:38 2014 -0400

    Fix dependency analysis of Scrips, ObjectScrips, and Queues
    
    The changes to apply Scrips to multiple Queues were never brought into
    the serializer.  Attempts to serialize a database with --scrips (and
    without --clone) led attempting to call ->QueueObj on a RT::Scrip
    object, which no longer has such a method; this led to the error:
    
        Can't locate object method "Id" via package "No object mapping for
        field"
    
    Rework the dependency analysis of Scrips to mirror that of CustomFields,
    in being many-to-many.

diff --git a/lib/RT/ObjectScrip.pm b/lib/RT/ObjectScrip.pm
index deab5c4..8418951 100644
--- a/lib/RT/ObjectScrip.pm
+++ b/lib/RT/ObjectScrip.pm
@@ -258,6 +258,20 @@ sub _CoreAccessible {
  }
 };
 
+sub FindDependencies {
+    my $self = shift;
+    my ($walker, $deps) = @_;
+
+    $self->SUPER::FindDependencies($walker, $deps);
+
+    $deps->Add( out => $self->ScripObj );
+    if ($self->ObjectId) {
+        my $obj = RT::Queue->new( $self->CurrentUser );
+        $obj->Load( $self->ObjectId );
+        $deps->Add( out => $obj );
+    }
+}
+
 RT::Base->_ImportOverlays();
 
 1;
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
index ea409ea..2e7017c 100644
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@ -1106,8 +1106,15 @@ sub FindDependencies {
     $deps->Add( in => $objs );
 
     # Scrips
-    $objs = RT::Scrips->new( $self->CurrentUser );
-    $objs->LimitToQueue( $self->id );
+    $objs = RT::ObjectScrips->new( $self->CurrentUser );
+    $objs->Limit( FIELD           => 'ObjectId',
+                  OPERATOR        => '=',
+                  VALUE           => $self->id,
+                  ENTRYAGGREGATOR => 'OR' );
+    $objs->Limit( FIELD           => 'ObjectId',
+                  OPERATOR        => '=',
+                  VALUE           => 0,
+                  ENTRYAGGREGATOR => 'OR' );
     $deps->Add( in => $objs );
 
     # Templates (global ones have already been dealt with)
diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
index 5e153cd..b08e6da 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -1111,9 +1111,12 @@ sub FindDependencies {
 
     $self->SUPER::FindDependencies($walker, $deps);
 
+    my $applied = RT::ObjectScrips->new( $self->CurrentUser );
+    $applied->LimitToScrip( $self->id );
+    $deps->Add( in => $applied );
+
     $deps->Add( out => $self->ScripConditionObj );
     $deps->Add( out => $self->ScripActionObj );
-    $deps->Add( out => $self->QueueObj ) if $self->QueueObj->Id;
     $deps->Add( out => $self->TemplateObj );
 }
 

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


More information about the rt-commit mailing list