[Rt-commit] rt branch, 4.2/serialize-objectscrips, created. rt-4.2.6-38-gfe3b6ed
Alex Vandiver
alexmv at bestpractical.com
Thu Nov 6 15:55:15 EST 2014
The branch, 4.2/serialize-objectscrips has been created
at fe3b6edf8057fde660f07c08811e603b815be320 (commit)
- Log -----------------------------------------------------------------
commit fe3b6edf8057fde660f07c08811e603b815be320
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/Migrate/Serializer.pm b/lib/RT/Migrate/Serializer.pm
index 2c23833..c7c83f2 100644
--- a/lib/RT/Migrate/Serializer.pm
+++ b/lib/RT/Migrate/Serializer.pm
@@ -398,7 +398,7 @@ sub Observe {
return $self->{FollowTickets};
} elsif ($obj->isa("RT::ACE")) {
return $self->{FollowACL};
- } elsif ($obj->isa("RT::Scrip") or $obj->isa("RT::Template")) {
+ } elsif ($obj->isa("RT::Scrip") or $obj->isa("RT::Template") or $obj->isa("RT::ObjectScrip")) {
return $self->{FollowScrips};
} elsif ($obj->isa("RT::GroupMember")) {
my $grp = $obj->GroupObj->Object;
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..144f13c 100644
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@ -1111,30 +1111,15 @@ 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 );
}
-sub PreInflate {
- my $class = shift;
- my ($importer, $uid, $data) = @_;
-
- $class->SUPER::PreInflate( $importer, $uid, $data );
-
- if ($data->{Queue} == 0) {
- my $obj = RT::Scrip->new( RT->SystemUser );
- $obj->LoadByCols( Queue => 0, Description => $data->{Description} );
- if ($obj->Id) {
- $importer->Resolve( $uid => ref($obj) => $obj->Id );
- return;
- }
- }
-
- return 1;
-}
-
RT::Base->_ImportOverlays();
1;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list