[Rt-commit] rt branch, 4.2/merge-shredder-overlays, repushed
Alex Vandiver
alexmv at bestpractical.com
Fri May 23 20:16:13 EDT 2014
The branch 4.2/merge-shredder-overlays was deleted and repushed:
was d290d606ab2608c51d232bd0ae189bb5c81d1d3b
now c9957b5944952397c9ffc50ab3a87bd709603ae9
1: 19a4e5c ! 1: a4ccd1f Pack bitmask constants more densely
@@ -11,12 +11,10 @@
use constant {
- DEPENDS_ON => 0x000001,
- WIPE_AFTER => 0x000010,
-- RELATES => 0x000100,
- VARIABLE => 0x001000,
+ DEPENDS_ON => 0x01,
+ WIPE_AFTER => 0x02,
-+ RELATES => 0x04,
-+ VARIABLE => 0x08,
++ VARIABLE => 0x04,
};
=head1 STATES
@@ -27,13 +25,9 @@
- ON_STACK => 0x00000,
- IN_WIPING => 0x00001,
- WIPED => 0x00010,
-- VALID => 0x00100,
-- INVALID => 0x01000,
+ ON_STACK => 0x00,
+ IN_WIPING => 0x01,
+ WIPED => 0x02,
-+ VALID => 0x04,
-+ INVALID => 0x08,
};
our @EXPORT = qw(
2: 920c48a ! 2: 8c2f2a2 Make two bitfields not overlap, to reduce changes of mixing them
@@ -11,12 +11,10 @@
use constant {
- DEPENDS_ON => 0x01,
- WIPE_AFTER => 0x02,
-- RELATES => 0x04,
-- VARIABLE => 0x08,
+- VARIABLE => 0x04,
+ DEPENDS_ON => 0x001,
+ WIPE_AFTER => 0x002,
-+ RELATES => 0x004,
-+ VARIABLE => 0x008,
++ VARIABLE => 0x004,
};
=head1 STATES
@@ -27,13 +25,9 @@
- ON_STACK => 0x00,
- IN_WIPING => 0x01,
- WIPED => 0x02,
-- VALID => 0x04,
-- INVALID => 0x08,
+ ON_STACK => 0x000,
+ IN_WIPING => 0x010,
+ WIPED => 0x020,
-+ VALID => 0x040,
-+ INVALID => 0x080,
};
our @EXPORT = qw(
3: d95a0e7 ! 3: 5eb3f35 Make shredder constants no longer exported
@@ -23,10 +23,10 @@
@@
my $self = $_[0];
- while ( my ($k, $v) = each %{ $self->{'cache'} } ) {
-- next if $v->{'State'} & (WIPED | IN_WIPING);
-+ next if $v->{'State'} & (RT::Shredder::Constants::WIPED | RT::Shredder::Constants::IN_WIPING);
- $self->Wipeout( Object => $v->{'Object'} );
+ foreach my $cache_val ( values %{ $self->{'cache'} } ) {
+- next if $cache_val->{'State'} & (WIPED | IN_WIPING);
++ next if $cache_val->{'State'} & (RT::Shredder::Constants::WIPED | RT::Shredder::Constants::IN_WIPING);
+ $self->Wipeout( Object => $cache_val->{'Object'} );
}
}
@@
@@ -73,15 +73,6 @@
Callback => sub { $self->_Wipeout( Object => $_[0]->TargetObject ) },
);
$self->DumpObject( Object => $object, State => 'after late dependencies' );
-@@
- my %args = ( @_ );
-
- foreach my $record( values %{ $self->{'cache'} } ) {
-- next if( $record->{'State'} & VALID );
-+ next if( $record->{'State'} & RT::Shredder::Constants::VALID );
- $record->{'Object'}->ValidateRelations( Shredder => $self );
- }
- }
diff --git a/lib/RT/Shredder/ACE.pm b/lib/RT/Shredder/ACE.pm
--- a/lib/RT/Shredder/ACE.pm
@@ -95,15 +86,6 @@
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
-@@
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
diff --git a/lib/RT/Shredder/Attachment.pm b/lib/RT/Shredder/Attachment.pm
--- a/lib/RT/Shredder/Attachment.pm
@@ -117,31 +99,6 @@
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no parent attachment #". $self->Parent ." object";
- }
- }
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related transaction #". $self->TransactionId ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
diff --git a/lib/RT/Shredder/CachedGroupMember.pm b/lib/RT/Shredder/CachedGroupMember.pm
--- a/lib/RT/Shredder/CachedGroupMember.pm
@@ -155,31 +112,6 @@
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
- }
-
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
diff --git a/lib/RT/Shredder/Constants.pm b/lib/RT/Shredder/Constants.pm
--- a/lib/RT/Shredder/Constants.pm
@@ -193,20 +125,25 @@
=head1 NAME
RT::Shredder::Constants - RT::Shredder constants that is used to mark state of RT objects.
-@@
- INVALID => 0x080,
+
+ =head1 DESCRIPTION
+
+-This module exports two group of bit constants.
++This module contains two group of bit constants.
+ First group is group of flags which are used to clarify dependecies between objects, and
+ second group is states of RT objects in Shredder cache.
+
+@@
+ WIPED => 0x020,
};
-our @EXPORT = qw(
- DEPENDS_ON
- WIPE_AFTER
-- RELATES
- VARIABLE
- ON_STACK
- IN_WIPING
- WIPED
-- VALID
-- INVALID
- );
-
1;
@@ -220,43 +157,6 @@
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related queue #". $self->Queue ." object";
- }
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
-diff --git a/lib/RT/Shredder/CustomFieldValue.pm b/lib/RT/Shredder/CustomFieldValue.pm
---- a/lib/RT/Shredder/CustomFieldValue.pm
-+++ b/lib/RT/Shredder/CustomFieldValue.pm
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -284,11 +184,9 @@
- DEPENDS_ON, 'depends on',
- VARIABLE, 'resolvable dependency',
- WIPE_AFTER, 'delete after',
-- RELATES, 'relates with',
+ RT::Shredder::Constants::DEPENDS_ON, 'depends on',
+ RT::Shredder::Constants::VARIABLE, 'resolvable dependency',
+ RT::Shredder::Constants::WIPE_AFTER, 'delete after',
-+ RT::Shredder::Constants::RELATES, 'relates with',
);
sub new
@@ -332,31 +230,6 @@
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "ACLEguvivalence group have no related User #". $self->Instance ." object.";
- }
- }
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->id ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
diff --git a/lib/RT/Shredder/GroupMember.pm b/lib/RT/Shredder/GroupMember.pm
--- a/lib/RT/Shredder/GroupMember.pm
@@ -386,34 +259,9 @@
- return if $args{'Shredder'}->GetState( Object => $group ) & (WIPED|IN_WIPING);
+ return if $args{'Shredder'}->GetState( Object => $group )
+ & (RT::Shredder::Constants::WIPED|RT::Shredder::Constants::IN_WIPING);
- return unless ($group->Type || '') eq 'Owner';
+ return unless ($group->Name || '') eq 'Owner';
return unless ($group->Domain || '') eq 'RT::Ticket-Role';
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
- }
-
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
diff --git a/lib/RT/Shredder/Link.pm b/lib/RT/Shredder/Link.pm
--- a/lib/RT/Shredder/Link.pm
@@ -428,35 +276,6 @@
Shredder => $args{'Shredder'}
);
-diff --git a/lib/RT/Shredder/ObjectCustomFieldValue.pm b/lib/RT/Shredder/ObjectCustomFieldValue.pm
---- a/lib/RT/Shredder/ObjectCustomFieldValue.pm
-+++ b/lib/RT/Shredder/ObjectCustomFieldValue.pm
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
- }
-
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
diff --git a/lib/RT/Shredder/Principal.pm b/lib/RT/Shredder/Principal.pm
--- a/lib/RT/Shredder/Principal.pm
+++ b/lib/RT/Shredder/Principal.pm
@@ -466,22 +285,6 @@
BaseObject => $self,
- Flags => DEPENDS_ON,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related ". $self->Type ." #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
@@ -519,10 +322,6 @@
+ if( $args{'Flags'} & RT::Shredder::Constants::DEPENDS_ON ) {
$self->__DependsOn( %args, Dependencies => $deps );
}
-- if( $args{'Flags'} & RELATES ) {
-+ if( $args{'Flags'} & RT::Shredder::Constants::RELATES ) {
- $self->__Relates( %args, Dependencies => $deps );
- }
return $deps;
@@
@@ -533,96 +332,19 @@
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- push @{ $rec->{'Description'} },
- "Have no related User(Creator) #". $self->Creator ." object";
- }
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- push @{ $rec->{'Description'} },
- "Have no related User(LastUpdatedBy) #". $self->LastUpdatedBy ." object";
- }
-@@
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-@@
- # cause of this $self->SUPER::__Relates should be called last
- # in overridden subs
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $rec->{'State'} |= VALID unless( $rec->{'State'} & INVALID );
-+ $rec->{'State'} |= RT::Shredder::Constants::VALID
-+ unless $rec->{'State'} & RT::Shredder::Constants::INVALID;
-
- return;
- }
-@@
- }
-
- my $rec = $args{'Shredder'}->PutObject( Object => $self );
-- return if( $rec->{'State'} & VALID );
-+ return if( $rec->{'State'} & RT::Shredder::Constants::VALID );
- $self = $rec->{'Object'};
-
-- $self->_ValidateRelations( %args, Flags => RELATES );
-- $rec->{'State'} |= VALID unless( $rec->{'State'} & INVALID );
-+ $self->_ValidateRelations( %args, Flags => RT::Shredder::Constants::RELATES );
-+ $rec->{'State'} |= RT::Shredder::Constants::VALID unless( $rec->{'State'} & RT::Shredder::Constants::INVALID );
-
- return;
- }
diff --git a/lib/RT/Shredder/Scrip.pm b/lib/RT/Shredder/Scrip.pm
--- a/lib/RT/Shredder/Scrip.pm
+++ b/lib/RT/Shredder/Scrip.pm
@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
- }
-
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related ScripCondition #". $self->id ." object";
- }
- # Action
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related ScripAction #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+- Flags => DEPENDS_ON,
++ Flags => RT::Shredder::Constants::DEPENDS_ON,
+ TargetObjects => $list,
+ Shredder => $args{'Shredder'}
+ );
diff --git a/lib/RT/Shredder/ScripAction.pm b/lib/RT/Shredder/ScripAction.pm
--- a/lib/RT/Shredder/ScripAction.pm
@@ -662,24 +384,6 @@
TargetObjects => $list,
Shredder => $args{'Shredder'},
);
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
- }
-
-@@
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
diff --git a/lib/RT/Shredder/Ticket.pm b/lib/RT/Shredder/Ticket.pm
--- a/lib/RT/Shredder/Ticket.pm
@@ -693,22 +397,6 @@
TargetObjects => $list,
Shredder => $args{'Shredder'}
);
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Queue #". $self->Queue ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
diff --git a/lib/RT/Shredder/Transaction.pm b/lib/RT/Shredder/Transaction.pm
--- a/lib/RT/Shredder/Transaction.pm
@@ -722,24 +410,6 @@
TargetObjects => $self->Attachments,
Shredder => $args{'Shredder'}
);
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
- }
-
-@@
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
diff --git a/lib/RT/Shredder/User.pm b/lib/RT/Shredder/User.pm
--- a/lib/RT/Shredder/User.pm
@@ -771,29 +441,4 @@
TargetObjects => \@var_objs,
Shredder => $args{'Shredder'}
);
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related ACL equivalence Group object";
- }
-
-@@
- } else {
- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
- $self = $rec->{'Object'};
-- $rec->{'State'} |= INVALID;
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
- $rec->{'Description'} = "Have no related Principal #". $self->id ." object";
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RELATES,
-+ Flags => RT::Shredder::Constants::RELATES,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-
+
-: ------- > 4: a29baaa Replace ->_AsString with ->UID
4: eab8107 ! 5: 8702baa Merge RT::Shredder::Record into RT::Record
@@ -6,55 +6,18 @@
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@
- use warnings;
-
-
-+use RT::Link;
- use RT::Date;
- use RT::User;
-+use RT::Transactions;
- use RT::Attributes;
+ require RT::Attributes;
+ require RT::Transactions;
+ require RT::Link;
+use RT::Shredder::Constants;
+use RT::Shredder::Exceptions;
use Encode qw();
our $_TABLE_ATTR = { };
@@
-
- sub _SetLastUpdated {
- my $self = shift;
-- use RT::Date;
- my $now = RT::Date->new( $self->CurrentUser );
- $now->SetToNow();
-
-@@
- }
-
- # Check if the link already exists - we don't want duplicates
-- use RT::Link;
- my $old_link = RT::Link->new( $self->CurrentUser );
- $old_link->LoadByParams( Base => $args{'Base'},
- Type => $args{'Type'},
-@@
- sub Transactions {
- my $self = shift;
-
-- use RT::Transactions;
- my $transactions = RT::Transactions->new( $self->CurrentUser );
-
- #If the user has no rights, return an empty object
-@@
- return RT->Config->Get('WebPath'). "/index.html?q=";
+ sub PostInflate {
}
-+=head2 _AsString
-+
-+Returns string in format ClassName-ObjectId.
-+
-+=cut
-+
-+sub _AsString { return ref($_[0]) ."-". $_[0]->id }
-+
+=head2 _AsInsertQuery
+
+Returns INSERT query string that duplicates current record and
@@ -102,9 +65,6 @@
+ my $deps = RT::Shredder::Dependencies->new();
+ if( $args{'Flags'} & RT::Shredder::Constants::DEPENDS_ON ) {
+ $self->__DependsOn( %args, Dependencies => $deps );
-+ }
-+ if( $args{'Flags'} & RT::Shredder::Constants::RELATES ) {
-+ $self->__Relates( %args, Dependencies => $deps );
+ }
+ return $deps;
+}
@@ -136,12 +96,13 @@
+ push( @$list, $objs );
+
+# Links
-+ if ( $self->can('_Links') ) {
-+ # XXX: We don't use Links->Next as it's dies when object
-+ # is linked to object that doesn't exist
-+ # also, ->Next skip links to deleted tickets :(
++ if ( $self->can('Links') ) {
++ # make sure we don't skip any record
++ no warnings 'redefine';
++ local *RT::Links::IsValidLink = sub { 1 };
++
+ foreach ( qw(Base Target) ) {
-+ my $objs = $self->_Links( $_ );
++ my $objs = $self->Links( $_ );
+ $objs->_DoSearch;
+ push @$list, $objs->ItemsArrayRef;
+ }
@@ -161,107 +122,17 @@
+ return;
+}
+
-+sub __Relates
-+{
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+ if( $self->_Accessible( 'Creator', 'read' ) ) {
-+ my $obj = RT::Principal->new( $self->CurrentUser );
-+ $obj->Load( $self->Creator );
-+
-+ if( $obj && defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ push @{ $rec->{'Description'} },
-+ "Have no related User(Creator) #". $self->Creator ." object";
-+ }
-+ }
-+
-+ if( $self->_Accessible( 'LastUpdatedBy', 'read' ) ) {
-+ my $obj = RT::Principal->new( $self->CurrentUser );
-+ $obj->Load( $self->LastUpdatedBy );
-+
-+ if( $obj && defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ push @{ $rec->{'Description'} },
-+ "Have no related User(LastUpdatedBy) #". $self->LastUpdatedBy ." object";
-+ }
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+
-+ # cause of this $self->SUPER::__Relates should be called last
-+ # in overridden subs
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $rec->{'State'} |= RT::Shredder::Constants::VALID
-+ unless $rec->{'State'} & RT::Shredder::Constants::INVALID;
-+
-+ return;
-+}
-+
+# implement proxy method because some RT classes
+# override Delete method
+sub __Wipeout
+{
+ my $self = shift;
-+ my $msg = $self->_AsString ." wiped out";
++ my $msg = $self->UID ." wiped out";
+ $self->SUPER::Delete;
+ $RT::Logger->info( $msg );
+ return;
+}
+
-+sub ValidateRelations
-+{
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ @_
-+ );
-+ unless( $args{'Shredder'} ) {
-+ $args{'Shredder'} = RT::Shredder->new();
-+ }
-+
-+ my $rec = $args{'Shredder'}->PutObject( Object => $self );
-+ return if( $rec->{'State'} & RT::Shredder::Constants::VALID );
-+ $self = $rec->{'Object'};
-+
-+ $self->_ValidateRelations( %args, Flags => RT::Shredder::Constants::RELATES );
-+ $rec->{'State'} |= RT::Shredder::Constants::VALID unless( $rec->{'State'} & RT::Shredder::Constants::INVALID );
-+
-+ return;
-+}
-+
-+sub _ValidateRelations
-+{
-+ my $self = shift;
-+ my %args = ( @_ );
-+
-+ my $deps = $self->Dependencies( %args );
-+
-+ $deps->ValidateRelations( %args );
-+
-+ return;
-+}
-+
RT::Base->_ImportOverlays();
1;
@@ -300,7 +171,7 @@
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -354,14 +225,6 @@
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-
--=head2 _AsString
--
--Returns string in format ClassName-ObjectId.
--
--=cut
--
--sub _AsString { return ref($_[0]) ."-". $_[0]->id }
--
-=head2 _AsInsertQuery
-
-Returns INSERT query string that duplicates current record and
@@ -409,9 +272,6 @@
- my $deps = RT::Shredder::Dependencies->new();
- if( $args{'Flags'} & RT::Shredder::Constants::DEPENDS_ON ) {
- $self->__DependsOn( %args, Dependencies => $deps );
-- }
-- if( $args{'Flags'} & RT::Shredder::Constants::RELATES ) {
-- $self->__Relates( %args, Dependencies => $deps );
- }
- return $deps;
-}
@@ -443,12 +303,13 @@
- push( @$list, $objs );
-
-# Links
-- if ( $self->can('_Links') ) {
-- # XXX: We don't use Links->Next as it's dies when object
-- # is linked to object that doesn't exist
-- # also, ->Next skip links to deleted tickets :(
+- if ( $self->can('Links') ) {
+- # make sure we don't skip any record
+- no warnings 'redefine';
+- local *RT::Links::IsValidLink = sub { 1 };
+-
- foreach ( qw(Base Target) ) {
-- my $objs = $self->_Links( $_ );
+- my $objs = $self->Links( $_ );
- $objs->_DoSearch;
- push @$list, $objs->ItemsArrayRef;
- }
@@ -468,106 +329,16 @@
- return;
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
-- if( $self->_Accessible( 'Creator', 'read' ) ) {
-- my $obj = RT::Principal->new( $self->CurrentUser );
-- $obj->Load( $self->Creator );
--
-- if( $obj && defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- push @{ $rec->{'Description'} },
-- "Have no related User(Creator) #". $self->Creator ." object";
-- }
-- }
--
-- if( $self->_Accessible( 'LastUpdatedBy', 'read' ) ) {
-- my $obj = RT::Principal->new( $self->CurrentUser );
-- $obj->Load( $self->LastUpdatedBy );
--
-- if( $obj && defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- push @{ $rec->{'Description'} },
-- "Have no related User(LastUpdatedBy) #". $self->LastUpdatedBy ." object";
-- }
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
--
-- # cause of this $self->SUPER::__Relates should be called last
-- # in overridden subs
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $rec->{'State'} |= RT::Shredder::Constants::VALID
-- unless $rec->{'State'} & RT::Shredder::Constants::INVALID;
--
-- return;
--}
--
-# implement proxy method because some RT classes
-# override Delete method
-sub __Wipeout
-{
- my $self = shift;
-- my $msg = $self->_AsString ." wiped out";
+- my $msg = $self->UID ." wiped out";
- $self->SUPER::Delete;
- $RT::Logger->info( $msg );
- return;
-}
-
--sub ValidateRelations
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- @_
-- );
-- unless( $args{'Shredder'} ) {
-- $args{'Shredder'} = RT::Shredder->new();
-- }
--
-- my $rec = $args{'Shredder'}->PutObject( Object => $self );
-- return if( $rec->{'State'} & RT::Shredder::Constants::VALID );
-- $self = $rec->{'Object'};
--
-- $self->_ValidateRelations( %args, Flags => RT::Shredder::Constants::RELATES );
-- $rec->{'State'} |= RT::Shredder::Constants::VALID unless( $rec->{'State'} & RT::Shredder::Constants::INVALID );
--
-- return;
--}
--
--sub _ValidateRelations
--{
-- my $self = shift;
-- my %args = ( @_ );
--
-- my $deps = $self->Dependencies( %args );
--
-- $deps->ValidateRelations( %args );
--
-- return;
--}
--
-1;
5: cd66cc7 ! 6: 5486169 Add new object types which have Creator and LastUpdatedBy
@@ -24,6 +24,7 @@
+ ObjectClasses
+ ObjectCustomFieldValues
+ ObjectCustomFields
++ ObjectScrips
Principals
Queues
ScripActions
-: ------- > 7: 1a0aa76 Remove Shredder subclasses with no __DependsOn
6: a1ba1d3 ! 8: c9957b5 Fold RT::Shredder code into core record classes
@@ -7,16 +7,13 @@
the lazy-loading was a side-effect of the code having originally been
written as an extension, and is no longer necessary.
-diff --git a/lib/RT/ACE.pm b/lib/RT/ACE.pm
---- a/lib/RT/ACE.pm
-+++ b/lib/RT/ACE.pm
-@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
+--- a/lib/RT/Attachment.pm
++++ b/lib/RT/Attachment.pm
+@@
+ $deps->Add( out => $self->TransactionObj );
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -27,6 +24,20 @@
+ my $deps = $args{'Dependencies'};
+ my $list = [];
+
++ # Nested attachments
++ my $objs = RT::Attachments->new( $self->CurrentUser );
++ $objs->Limit(
++ FIELD => 'Parent',
++ OPERATOR => '=',
++ VALUE => $self->Id
++ );
++ $objs->Limit(
++ FIELD => 'id',
++ OPERATOR => '!=',
++ VALUE => $self->Id
++ );
++ push( @$list, $objs );
++
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
@@ -36,127 +47,19 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
RT::Base->_ImportOverlays();
-
-diff --git a/lib/RT/Attachment.pm b/lib/RT/Attachment.pm
---- a/lib/RT/Attachment.pm
-+++ b/lib/RT/Attachment.pm
-@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
-
- }
--};
-+}
-+
-+sub __DependsOn {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Nested attachments
-+ my $objs = RT::Attachments->new( $self->CurrentUser );
-+ $objs->Limit(
-+ FIELD => 'Parent',
-+ OPERATOR => '=',
-+ VALUE => $self->Id
-+ );
-+ $objs->Limit(
-+ FIELD => 'id',
-+ OPERATOR => '!=',
-+ VALUE => $self->Id
-+ );
-+ push( @$list, $objs );
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::DEPENDS_ON,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__DependsOn( %args );
-+}
-+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Parent, nested parts
-+ if( $self->Parent ) {
-+ if( $self->ParentObj && $self->ParentId ) {
-+ push( @$list, $self->ParentObj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no parent attachment #". $self->Parent ." object";
-+ }
-+ }
-+
-+# Transaction
-+ my $obj = $self->TransactionObj;
-+ if( defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related transaction #". $self->TransactionId ." object";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
- RT::Base->_ImportOverlays();
-
+ 1;
diff --git a/lib/RT/CachedGroupMember.pm b/lib/RT/CachedGroupMember.pm
--- a/lib/RT/CachedGroupMember.pm
+++ b/lib/RT/CachedGroupMember.pm
@@
- {read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
+ die "CachedGroupMembers should never be serialized";
+ }
- }
--};
-+}
-+
-+sub __DependsOn {
++sub __DependsOn
++{
+ my $self = shift;
+ my %args = (
+ Shredder => undef,
@@ -194,57 +97,16 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+ my $obj = $self->MemberObj;
-+ if( $obj && $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
-+ }
-+
-+ $obj = $self->GroupObj;
-+ if( $obj && $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
RT::Base->_ImportOverlays();
+ 1;
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@
- {read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
-
- }
--};
-+}
+ $deps->Add( in => $self->Values ) if $self->ValuesClass eq "RT::CustomFieldValues";
+ }
+sub __DependsOn {
+ my $self = shift;
@@ -272,97 +134,17 @@
+ );
+ return $self->SUPER::__DependsOn( %args );
+}
-+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+ my $obj = $self->Object;
-+
-+# Queue
-+# Skip if it's global CF
-+ if( $self->Queue ) {
-+ if( $self->QueueObj && $self->QueueObj->Id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related queue #". $self->Queue ." object";
-+ }
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
RT::Base->_ImportOverlays();
-diff --git a/lib/RT/CustomFieldValue.pm b/lib/RT/CustomFieldValue.pm
---- a/lib/RT/CustomFieldValue.pm
-+++ b/lib/RT/CustomFieldValue.pm
-@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
-
- }
--};
--
-+}
-
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+ my $obj = $self->CustomFieldObj;
-+ if( $obj && defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
-+ }
-
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->__Relates( %args );
-+}
-
- RT::Base->_ImportOverlays();
-
-
diff --git a/lib/RT/Group.pm b/lib/RT/Group.pm
--- a/lib/RT/Group.pm
+++ b/lib/RT/Group.pm
@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+ $deps->Add( in => $objs );
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -374,7 +156,7 @@
+ my $list = [];
+
+# User is inconsistent without own Equivalence group
-+ if ( $self->Domain eq 'ACLEquivalence' ) {
++ if( $self->Domain eq 'ACLEquivalence' ) {
+ # delete user entry after ACL equiv group
+ # in other case we will get deep recursion
+ my $objs = RT::User->new($self->CurrentUser);
@@ -432,71 +214,25 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Equivalence group id inconsistent without User
-+ if ( $self->Domain eq 'ACLEquivalence' ) {
-+ my $obj = RT::User->new($self->CurrentUser);
-+ $obj->Load( $self->Instance );
-+ if( $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "ACLEguvivalence group have no related User #". $self->Instance ." object.";
-+ }
-+ }
-+
-+# Principal
-+ my $obj = $self->PrincipalObj;
-+ if ( $obj && $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Principal #". $self->id ." object.";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-+
+sub BeforeWipeout {
+ my $self = shift;
-+ if ( $self->Domain eq 'SystemInternal' ) {
++ if( $self->Domain eq 'SystemInternal' ) {
+ RT::Shredder::Exception::Info->throw('SystemObject');
+ }
+ return $self->SUPER::BeforeWipeout( @_ );
+}
-
- RT::Base->_ImportOverlays();
-
++
+ sub Serialize {
+ my $self = shift;
+ my %args = (@_);
diff --git a/lib/RT/GroupMember.pm b/lib/RT/GroupMember.pm
--- a/lib/RT/GroupMember.pm
+++ b/lib/RT/GroupMember.pm
@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+ $deps->Add( out => $self->MemberObj->Object );
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -512,8 +248,6 @@
+ $objs->Limit( FIELD => 'ImmediateParentId', VALUE => $self->GroupId );
+ push( @$list, $objs );
+
-+ # XXX: right delegations should be cleaned here
-+
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
@@ -524,7 +258,7 @@
+ my $group = $self->GroupObj->Object;
+ # XXX: If we delete member of the ticket owner role group then we should also
+ # fix ticket object, but only if we don't plan to delete group itself!
-+ unless( ($group->Type || '') eq 'Owner' &&
++ unless( ($group->Name || '') eq 'Owner' &&
+ ($group->Domain || '') eq 'RT::Ticket-Role' ) {
+ return $self->SUPER::__DependsOn( %args );
+ }
@@ -544,28 +278,19 @@
+ my $group = $args{'TargetObject'};
+ return if $args{'Shredder'}->GetState( Object => $group )
+ & (RT::Shredder::Constants::WIPED|RT::Shredder::Constants::IN_WIPING);
-+ return unless ($group->Type || '') eq 'Owner';
++ return unless ($group->Name || '') eq 'Owner';
+ return unless ($group->Domain || '') eq 'RT::Ticket-Role';
+
+ return if $group->MembersObj->Count > 1;
+
+ my $group_member = $args{'BaseObject'};
+
-+ if ( $group_member->MemberObj->id == RT->Nobody->id ) {
++ if( $group_member->MemberObj->id == RT->Nobody->id ) {
+ RT::Shredder::Exception->throw( "Couldn't delete Nobody from owners role group" );
+ }
+
-+ my ( $status, $msg ) = $group->AddMember( RT->Nobody->id );
-+ RT::Shredder::Exception->throw( $msg ) unless $status;
-+
-+ my $ticket = RT::Ticket->new( $group->CurrentUser );
-+ $ticket->Load( $group->Instance );
-+ RT::Shredder::Exception->throw( "Couldn't load ticket" ) unless $ticket->id;
-+
-+ ( $status, $msg ) = $ticket->_Set(
-+ Field => 'Owner',
-+ Value => RT->Nobody->id,
-+ );
++ my( $status, $msg ) = $group->AddMember( RT->Nobody->id );
++
+ RT::Shredder::Exception->throw( $msg ) unless $status;
+
+ return;
@@ -575,67 +300,17 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+ my $obj = $self->MemberObj;
-+ if( $obj && $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
-+ }
-+
-+ $obj = $self->GroupObj;
-+ if( $obj && $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
- RT::Base->_ImportOverlays();
-
+ sub PreInflate {
+ my $class = shift;
+ my ($importer, $uid, $data) = @_;
diff --git a/lib/RT/Link.pm b/lib/RT/Link.pm
--- a/lib/RT/Link.pm
+++ b/lib/RT/Link.pm
@@
- sub Table {'Links'}
- use Carp;
- use RT::URI;
--
-+use RT::Shredder::Constants;
+ $deps->Add( out => $self->TargetObj ) if $self->TargetObj and $self->TargetObj->id;
+ }
-
- =head2 Create PARAMHASH
-@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
-
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -647,7 +322,7 @@
+ my $list = [];
+
+# AddLink transactions
-+ my $map = RT::Ticket->LINKTYPEMAP;
++ my $map = { %RT::Link::TYPEMAP };
+ my $link_meta = $map->{ $self->Type };
+ unless ( $link_meta && $link_meta->{'Mode'} && $link_meta->{'Type'} ) {
+ RT::Shredder::Exception->throw( 'Wrong link link_meta, no record for '. $self->Type );
@@ -694,32 +369,17 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+# FIXME: if link is local then object should exist
-+
-+ return $self->SUPER::__Relates( %args );
-+}
+ sub Serialize {
+ my $self = shift;
+ my %args = (@_);
+
+diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
+--- a/lib/RT/Principal.pm
++++ b/lib/RT/Principal.pm
+@@
+ }
+ };
- RT::Base->_ImportOverlays();
-
-
-diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
---- a/lib/RT/ObjectCustomFieldValue.pm
-+++ b/lib/RT/ObjectCustomFieldValue.pm
-@@
- {read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
-
- }
--};
-+}
+
+sub __DependsOn {
+ my $self = shift;
@@ -731,73 +391,6 @@
+ my $deps = $args{'Dependencies'};
+ my $list = [];
+
-+ return $self->SUPER::__DependsOn( %args );
-+}
-+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Ticket
-+ my $obj = $self->TicketObj;
-+ if( defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
-+ }
-+
-+# Custom Field
-+ $obj = $self->CustomFieldObj;
-+ if( defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
- RT::Base->_ImportOverlays();
-
-
-diff --git a/lib/RT/Principal.pm b/lib/RT/Principal.pm
---- a/lib/RT/Principal.pm
-+++ b/lib/RT/Principal.pm
-@@
- {read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
-
- }
--};
-+}
-+
-+sub __DependsOn {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
+# Group or User
+# Could be wiped allready
+ my $obj = $self->Object;
@@ -814,6 +407,14 @@
+ );
+ push( @$list, $objs );
+
++# AddWatcher/DelWatcher txns
++ foreach my $type ( qw(AddWatcher DelWatcher) ) {
++ my $objs = RT::Transactions->new( $self->CurrentUser );
++ $objs->Limit( FIELD => $type =~ /Add/? 'NewValue': 'OldValue', VALUE => $self->Id );
++ $objs->Limit( FIELD => 'Type', VALUE => $type );
++ push( @$list, $objs );
++ }
++
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
@@ -823,48 +424,16 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+ my $obj = $self->Object;
-+ if( defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related ". $self->Type ." #". $self->id ." object";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
RT::Base->_ImportOverlays();
+ 1;
diff --git a/lib/RT/Queue.pm b/lib/RT/Queue.pm
--- a/lib/RT/Queue.pm
+++ b/lib/RT/Queue.pm
@@
- {read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
-
- }
--};
-+}
-
+ $deps->Add( in => $objs );
+ }
+sub __DependsOn {
+ my $self = shift;
@@ -884,7 +453,7 @@
+
+# Queue role groups( Cc, AdminCc )
+ $objs = RT::Groups->new( $self->CurrentUser );
-+ $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role' );
++ $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
+ $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
+ push( @$list, $objs );
+
@@ -899,6 +468,7 @@
+
+# Custom Fields
+ $objs = RT::CustomFields->new( $self->CurrentUser );
++ $objs->SetContextObject( $self );
+ $objs->LimitToQueue( $self->id );
+ push( @$list, $objs );
+
@@ -910,32 +480,31 @@
+ );
+ return $self->SUPER::__DependsOn( %args );
+}
-
- RT::Base->_ImportOverlays();
-
++
++
+ sub PreInflate {
+ my $class = shift;
+ my ($importer, $uid, $data) = @_;
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@
- use RT::Transactions;
- use RT::Attributes;
+ require RT::Attributes;
+ require RT::Transactions;
+ require RT::Link;
++use RT::Shredder::Dependencies;
use RT::Shredder::Constants;
-+use RT::Shredder::Dependencies;
use RT::Shredder::Exceptions;
use Encode qw();
-
diff --git a/lib/RT/Scrip.pm b/lib/RT/Scrip.pm
--- a/lib/RT/Scrip.pm
+++ b/lib/RT/Scrip.pm
@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+ $deps->Add( out => $self->TemplateObj );
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -946,77 +515,31 @@
+ my $deps = $args{'Dependencies'};
+ my $list = [];
+
-+# No dependencies that should be deleted with record
-+# Scrip actions and conditions should be exported in feature with it.
++ my $objs = RT::ObjectScrips->new( $self->CurrentUser );
++ $objs->LimitToScrip( $self->Id );
++ push @$list, $objs;
++
++ $deps->_PushDependencies(
++ BaseObject => $self,
++ Flags => RT::Shredder::Constants::DEPENDS_ON,
++ TargetObjects => $list,
++ Shredder => $args{'Shredder'}
++ );
+
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Queue
-+ my $obj = $self->QueueObj;
-+ if( defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
-+ }
-+
-+# Condition
-+ $obj = $self->ConditionObj;
-+ if( defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related ScripCondition #". $self->id ." object";
-+ }
-+# Action
-+ $obj = $self->ActionObj;
-+ if( defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related ScripAction #". $self->id ." object";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+
-+ return $self->SUPER::__Relates( %args );
-+}
-
- RT::Base->_ImportOverlays();
-
+ sub PreInflate {
+ my $class = shift;
+ my ($importer, $uid, $data) = @_;
diff --git a/lib/RT/ScripAction.pm b/lib/RT/ScripAction.pm
--- a/lib/RT/ScripAction.pm
+++ b/lib/RT/ScripAction.pm
@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+ return not $importer->SkipBy( "Name", $class, $uid, $data );
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -1025,7 +548,6 @@
+ @_,
+ );
+ my $deps = $args{'Dependencies'};
-+ my $list = [];
+
+# Scrips
+ my $objs = RT::Scrips->new( $self->CurrentUser );
@@ -1040,35 +562,17 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# TODO: Check here for exec module
-+
-+ return $self->SUPER::__Relates( %args );
-+}
-+
-
RT::Base->_ImportOverlays();
+ 1;
diff --git a/lib/RT/ScripCondition.pm b/lib/RT/ScripCondition.pm
--- a/lib/RT/ScripCondition.pm
+++ b/lib/RT/ScripCondition.pm
@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+ return not $importer->SkipBy( "Name", $class, $uid, $data );
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -1077,7 +581,6 @@
+ @_,
+ );
+ my $deps = $args{'Dependencies'};
-+ my $list = [];
+
+# Scrips
+ my $objs = RT::Scrips->new( $self->CurrentUser );
@@ -1092,48 +595,23 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# TODO: Check here for exec module
-+
-+ return $self->SUPER::__Relates( %args );
-+}
-
RT::Base->_ImportOverlays();
+ 1;
diff --git a/lib/RT/Shredder.pm b/lib/RT/Shredder.pm
--- a/lib/RT/Shredder.pm
+++ b/lib/RT/Shredder.pm
@@
- our $VERSION = '0.04';
- use File::Spec ();
-
--
--BEGIN {
--# I can't use 'use lib' here since it breakes tests
--# because test suite uses old RT::Shredder setup from
--# RT lib path
--
--### after: push @INC, qw(@RT_LIB_PATH@);
-- use RT::Shredder::Constants;
-- use RT::Shredder::Exceptions;
+ ### after: push @INC, qw(@RT_LIB_PATH@);
+ use RT::Shredder::Constants;
+ use RT::Shredder::Exceptions;
-
- require RT;
-
-- require RT::Shredder::ACE;
- require RT::Shredder::Attachment;
- require RT::Shredder::CachedGroupMember;
- require RT::Shredder::CustomField;
-- require RT::Shredder::CustomFieldValue;
- require RT::Shredder::GroupMember;
- require RT::Shredder::Group;
- require RT::Shredder::Link;
@@ -1143,123 +621,12 @@
- require RT::Shredder::ScripAction;
- require RT::Shredder::ScripCondition;
- require RT::Shredder::Template;
-- require RT::Shredder::ObjectCustomFieldValue;
- require RT::Shredder::Ticket;
- require RT::Shredder::Transaction;
- require RT::Shredder::User;
--}
-+use RT::Shredder::Constants;
-+use RT::Shredder::Exceptions;
+ }
our @SUPPORTED_OBJECTS = qw(
- ACE
-
-diff --git a/lib/RT/Shredder/ACE.pm b/lib/RT/Shredder/ACE.pm
-deleted file mode 100644
---- a/lib/RT/Shredder/ACE.pm
-+++ /dev/null
-@@
--# BEGIN BPS TAGGED BLOCK {{{
--#
--# COPYRIGHT:
--#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
--# <sales at bestpractical.com>
--#
--# (Except where explicitly superseded by other copyright notices)
--#
--#
--# LICENSE:
--#
--# This work is made available to you under the terms of Version 2 of
--# the GNU General Public License. A copy of that license should have
--# been provided with this software, but in any event can be snarfed
--# from www.gnu.org.
--#
--# This work is distributed in the hope that it will be useful, but
--# WITHOUT ANY WARRANTY; without even the implied warranty of
--# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--# General Public License for more details.
--#
--# You should have received a copy of the GNU General Public License
--# along with this program; if not, write to the Free Software
--# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
--# 02110-1301 or visit their web page on the internet at
--# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
--#
--#
--# CONTRIBUTION SUBMISSION POLICY:
--#
--# (The following paragraph is not intended to limit the rights granted
--# to you to modify and distribute this software under the terms of
--# the GNU General Public License and is only of importance to you if
--# you choose to contribute your changes and enhancements to the
--# community by submitting them to Best Practical Solutions, LLC.)
--#
--# By intentionally submitting any modifications, corrections or
--# derivatives to this work, or any other work intended for use with
--# Request Tracker, to Best Practical Solutions, LLC, you confirm that
--# you are the copyright holder for those contributions and you grant
--# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
--# royalty-free, perpetual, license to use, copy, create derivative
--# works based on those contributions, and sublicense and distribute
--# those contributions and any derivatives thereof.
--#
--# END BPS TAGGED BLOCK }}}
--
--use RT::ACE ();
--package RT::ACE;
--
--use strict;
--use warnings;
--use warnings FATAL => 'redefine';
--
--use RT::Shredder::Exceptions;
--use RT::Shredder::Constants;
--use RT::Shredder::Dependencies;
--
--sub __DependsOn
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::DEPENDS_ON,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__DependsOn( %args );
--}
--
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
--1;
--
diff --git a/lib/RT/Shredder/Attachment.pm b/lib/RT/Shredder/Attachment.pm
deleted file mode 100644
@@ -1270,7 +637,7 @@
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -1359,48 +726,6 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# Parent, nested parts
-- if( $self->Parent ) {
-- if( $self->ParentObj && $self->ParentId ) {
-- push( @$list, $self->ParentObj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no parent attachment #". $self->Parent ." object";
-- }
-- }
--
--# Transaction
-- my $obj = $self->TransactionObj;
-- if( defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related transaction #". $self->TransactionId ." object";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
-1;
diff --git a/lib/RT/Shredder/CachedGroupMember.pm b/lib/RT/Shredder/CachedGroupMember.pm
@@ -1412,7 +737,7 @@
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -1508,48 +833,6 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--#TODO: If we plan write export tool we also should fetch parent groups
--# now we only wipeout things.
--
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
-- my $obj = $self->MemberObj;
-- if( $obj && $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
-- }
--
-- $obj = $self->GroupObj;
-- if( $obj && $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
-1;
diff --git a/lib/RT/Shredder/CustomField.pm b/lib/RT/Shredder/CustomField.pm
@@ -1561,7 +844,7 @@
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -1646,142 +929,6 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
-- my $obj = $self->Object;
--
--# Queue
--# Skip if it's global CF
-- if( $self->Queue ) {
-- if( $self->QueueObj && $self->QueueObj->Id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related queue #". $self->Queue ." object";
-- }
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
--
--1;
--
-
-diff --git a/lib/RT/Shredder/CustomFieldValue.pm b/lib/RT/Shredder/CustomFieldValue.pm
-deleted file mode 100644
---- a/lib/RT/Shredder/CustomFieldValue.pm
-+++ /dev/null
-@@
--# BEGIN BPS TAGGED BLOCK {{{
--#
--# COPYRIGHT:
--#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
--# <sales at bestpractical.com>
--#
--# (Except where explicitly superseded by other copyright notices)
--#
--#
--# LICENSE:
--#
--# This work is made available to you under the terms of Version 2 of
--# the GNU General Public License. A copy of that license should have
--# been provided with this software, but in any event can be snarfed
--# from www.gnu.org.
--#
--# This work is distributed in the hope that it will be useful, but
--# WITHOUT ANY WARRANTY; without even the implied warranty of
--# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--# General Public License for more details.
--#
--# You should have received a copy of the GNU General Public License
--# along with this program; if not, write to the Free Software
--# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
--# 02110-1301 or visit their web page on the internet at
--# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
--#
--#
--# CONTRIBUTION SUBMISSION POLICY:
--#
--# (The following paragraph is not intended to limit the rights granted
--# to you to modify and distribute this software under the terms of
--# the GNU General Public License and is only of importance to you if
--# you choose to contribute your changes and enhancements to the
--# community by submitting them to Best Practical Solutions, LLC.)
--#
--# By intentionally submitting any modifications, corrections or
--# derivatives to this work, or any other work intended for use with
--# Request Tracker, to Best Practical Solutions, LLC, you confirm that
--# you are the copyright holder for those contributions and you grant
--# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
--# royalty-free, perpetual, license to use, copy, create derivative
--# works based on those contributions, and sublicense and distribute
--# those contributions and any derivatives thereof.
--#
--# END BPS TAGGED BLOCK }}}
--
--use RT::CustomFieldValue ();
--package RT::CustomFieldValue;
--
--use strict;
--use warnings;
--use warnings FATAL => 'redefine';
--
--use RT::Shredder::Constants;
--use RT::Shredder::Exceptions;
--use RT::Shredder::Dependencies;
--
--# No dependencies that should be deleted with record
--# I should decide is TicketCustomFieldValue depends by this or not.
--# Today I think no. What would be tomorrow I don't know.
--
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
-- my $obj = $self->CustomFieldObj;
-- if( $obj && defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->__Relates( %args );
--}
--
-1;
diff --git a/lib/RT/Shredder/Group.pm b/lib/RT/Shredder/Group.pm
@@ -1793,7 +940,7 @@
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -1919,51 +1066,6 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# Equivalence group id inconsistent without User
-- if( $self->Domain eq 'ACLEquivalence' ) {
-- my $obj = RT::User->new($self->CurrentUser);
-- $obj->Load( $self->Instance );
-- if( $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "ACLEguvivalence group have no related User #". $self->Instance ." object.";
-- }
-- }
--
--# Principal
-- my $obj = $self->PrincipalObj;
-- if( $obj && $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Principal #". $self->id ." object.";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
--
-sub BeforeWipeout
-{
- my $self = shift;
@@ -1984,7 +1086,7 @@
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -2069,7 +1171,7 @@
- my $group = $self->GroupObj->Object;
- # XXX: If we delete member of the ticket owner role group then we should also
- # fix ticket object, but only if we don't plan to delete group itself!
-- unless( ($group->Type || '') eq 'Owner' &&
+- unless( ($group->Name || '') eq 'Owner' &&
- ($group->Domain || '') eq 'RT::Ticket-Role' ) {
- return $self->SUPER::__DependsOn( %args );
- }
@@ -2089,7 +1191,7 @@
- my $group = $args{'TargetObject'};
- return if $args{'Shredder'}->GetState( Object => $group )
- & (RT::Shredder::Constants::WIPED|RT::Shredder::Constants::IN_WIPING);
-- return unless ($group->Type || '') eq 'Owner';
+- return unless ($group->Name || '') eq 'Owner';
- return unless ($group->Domain || '') eq 'RT::Ticket-Role';
-
- return if $group->MembersObj->Count > 1;
@@ -2101,15 +1203,7 @@
- }
-
- my( $status, $msg ) = $group->AddMember( RT->Nobody->id );
-- RT::Shredder::Exception->throw( $msg ) unless $status;
--
-- my $ticket = RT::Ticket->new( $group->CurrentUser );
-- $ticket->Load( $group->Instance );
-- RT::Shredder::Exception->throw( "Couldn't load ticket" ) unless $ticket->id;
--
-- ( $status, $msg ) = $ticket->_Set( Field => 'Owner',
-- Value => RT->Nobody->id,
-- );
+-
- RT::Shredder::Exception->throw( $msg ) unless $status;
-
- return;
@@ -2117,50 +1211,6 @@
- );
-
- return $self->SUPER::__DependsOn( %args );
--}
--
--
--#TODO: If we plan write export tool we also should fetch parent groups
--# now we only wipeout things.
--
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
-- my $obj = $self->MemberObj;
-- if( $obj && $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Principal #". $self->MemberId ." object.";
-- }
--
-- $obj = $self->GroupObj;
-- if( $obj && $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Principal #". $self->GroupId ." object.";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
-}
-
-1;
@@ -2174,7 +1224,7 @@
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -2243,7 +1293,7 @@
- my $list = [];
-
-# AddLink transactions
-- my $map = RT::Ticket->LINKTYPEMAP;
+- my $map = { %RT::Link::TYPEMAP };
- my $link_meta = $map->{ $self->Type };
- unless ( $link_meta && $link_meta->{'Mode'} && $link_meta->{'Type'} ) {
- RT::Shredder::Exception->throw( 'Wrong link link_meta, no record for '. $self->Type );
@@ -2290,36 +1340,18 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--#TODO: Link record has small strength, but should be encountered
--# if we plan write export tool.
--
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--# FIXME: if link is local then object should exist
--
-- return $self->SUPER::__Relates( %args );
--}
--
-1;
-diff --git a/lib/RT/Shredder/ObjectCustomFieldValue.pm b/lib/RT/Shredder/ObjectCustomFieldValue.pm
+diff --git a/lib/RT/Shredder/Principal.pm b/lib/RT/Shredder/Principal.pm
deleted file mode 100644
---- a/lib/RT/Shredder/ObjectCustomFieldValue.pm
+--- a/lib/RT/Shredder/Principal.pm
+++ /dev/null
@@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -2363,16 +1395,17 @@
-#
-# END BPS TAGGED BLOCK }}}
-
--use RT::ObjectCustomFieldValue ();
--package RT::ObjectCustomFieldValue;
+-use RT::Principal ();
+-package RT::Principal;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
+-use RT::Shredder::Exceptions;
-use RT::Shredder::Constants;
--use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
+-
-
-sub __DependsOn
-{
@@ -2385,63 +1418,51 @@
- my $deps = $args{'Dependencies'};
- my $list = [];
-
-- return $self->SUPER::__DependsOn( %args );
--}
--
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# Ticket
-- my $obj = $self->TicketObj;
+-# Group or User
+-# Could be wiped allready
+- my $obj = $self->Object;
- if( defined $obj->id ) {
- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
- }
-
--# Custom Field
-- $obj = $self->CustomFieldObj;
-- if( defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related CustomField #". $self->id ." object";
+-# Access Control List
+- my $objs = RT::ACL->new( $self->CurrentUser );
+- $objs->Limit(
+- FIELD => 'PrincipalId',
+- OPERATOR => '=',
+- VALUE => $self->Id
+- );
+- push( @$list, $objs );
+-
+-# AddWatcher/DelWatcher txns
+- foreach my $type ( qw(AddWatcher DelWatcher) ) {
+- my $objs = RT::Transactions->new( $self->CurrentUser );
+- $objs->Limit( FIELD => $type =~ /Add/? 'NewValue': 'OldValue', VALUE => $self->Id );
+- $objs->Limit( FIELD => 'Type', VALUE => $type );
+- push( @$list, $objs );
- }
-
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
+- Flags => RT::Shredder::Constants::DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-- return $self->SUPER::__Relates( %args );
+- return $self->SUPER::__DependsOn( %args );
-}
-
-1;
-diff --git a/lib/RT/Shredder/Principal.pm b/lib/RT/Shredder/Principal.pm
+diff --git a/lib/RT/Shredder/Queue.pm b/lib/RT/Shredder/Queue.pm
deleted file mode 100644
---- a/lib/RT/Shredder/Principal.pm
+--- a/lib/RT/Shredder/Queue.pm
+++ /dev/null
@@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -2485,17 +1506,16 @@
-#
-# END BPS TAGGED BLOCK }}}
-
--use RT::Principal ();
--package RT::Principal;
+-use RT::Queue ();
+-package RT::Queue;
-
-use strict;
-use warnings;
-use warnings FATAL => 'redefine';
-
+-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
--use RT::Shredder::Constants;
-use RT::Shredder::Dependencies;
--
-
-sub __DependsOn
-{
@@ -2508,20 +1528,31 @@
- my $deps = $args{'Dependencies'};
- my $list = [];
-
--# Group or User
--# Could be wiped allready
-- my $obj = $self->Object;
-- if( defined $obj->id ) {
-- push( @$list, $obj );
-- }
--
--# Access Control List
-- my $objs = RT::ACL->new( $self->CurrentUser );
-- $objs->Limit(
-- FIELD => 'PrincipalId',
-- OPERATOR => '=',
-- VALUE => $self->Id
-- );
+-# Tickets
+- my $objs = RT::Tickets->new( $self->CurrentUser );
+- $objs->{'allow_deleted_search'} = 1;
+- $objs->Limit( FIELD => 'Queue', VALUE => $self->Id );
+- push( @$list, $objs );
+-
+-# Queue role groups( Cc, AdminCc )
+- $objs = RT::Groups->new( $self->CurrentUser );
+- $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role', CASESENSITIVE => 0 );
+- $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
+- push( @$list, $objs );
+-
+-# Scrips
+- $objs = RT::Scrips->new( $self->CurrentUser );
+- $objs->LimitToQueue( $self->id );
+- push( @$list, $objs );
+-
+-# Templates
+- $objs = $self->Templates;
+- push( @$list, $objs );
+-
+-# Custom Fields
+- $objs = RT::CustomFields->new( $self->CurrentUser );
+- $objs->SetContextObject( $self );
+- $objs->LimitToQueue( $self->id );
- push( @$list, $objs );
-
- $deps->_PushDependencies(
@@ -2533,48 +1564,18 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
-- my $obj = $self->Object;
-- if( defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related ". $self->Type ." #". $self->id ." object";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
--
-1;
-diff --git a/lib/RT/Shredder/Queue.pm b/lib/RT/Shredder/Queue.pm
+diff --git a/lib/RT/Shredder/Scrip.pm b/lib/RT/Shredder/Scrip.pm
deleted file mode 100644
---- a/lib/RT/Shredder/Queue.pm
+--- a/lib/RT/Shredder/Scrip.pm
+++ /dev/null
@@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -2618,8 +1619,8 @@
-#
-# END BPS TAGGED BLOCK }}}
-
--use RT::Queue ();
--package RT::Queue;
+-use RT::Scrip ();
+-package RT::Scrip;
-
-use strict;
-use warnings;
@@ -2640,53 +1641,32 @@
- my $deps = $args{'Dependencies'};
- my $list = [];
-
--# Tickets
-- my $objs = RT::Tickets->new( $self->CurrentUser );
-- $objs->{'allow_deleted_search'} = 1;
-- $objs->Limit( FIELD => 'Queue', VALUE => $self->Id );
-- push( @$list, $objs );
--
--# Queue role groups( Cc, AdminCc )
-- $objs = RT::Groups->new( $self->CurrentUser );
-- $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Queue-Role' );
-- $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
-- push( @$list, $objs );
--
--# Scrips
-- $objs = RT::Scrips->new( $self->CurrentUser );
-- $objs->LimitToQueue( $self->id );
-- push( @$list, $objs );
--
--# Templates
-- $objs = $self->Templates;
-- push( @$list, $objs );
--
--# Custom Fields
-- $objs = RT::CustomFields->new( $self->CurrentUser );
-- $objs->LimitToQueue( $self->id );
-- push( @$list, $objs );
+- my $objs = RT::ObjectScrips->new( $self->CurrentUser );
+- $objs->LimitToScrip( $self->Id );
+- push @$list, $objs;
-
- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::DEPENDS_ON,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
+- BaseObject => $self,
+- Flags => RT::Shredder::Constants::DEPENDS_ON,
+- TargetObjects => $list,
+- Shredder => $args{'Shredder'}
+- );
+-
- return $self->SUPER::__DependsOn( %args );
-}
-
-1;
-diff --git a/lib/RT/Shredder/Scrip.pm b/lib/RT/Shredder/Scrip.pm
+diff --git a/lib/RT/Shredder/ScripAction.pm b/lib/RT/Shredder/ScripAction.pm
deleted file mode 100644
---- a/lib/RT/Shredder/Scrip.pm
+--- a/lib/RT/Shredder/ScripAction.pm
+++ /dev/null
@@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -2730,8 +1710,8 @@
-#
-# END BPS TAGGED BLOCK }}}
-
--use RT::Scrip ();
--package RT::Scrip;
+-use RT::ScripAction ();
+-package RT::ScripAction;
-
-use strict;
-use warnings;
@@ -2752,77 +1732,31 @@
- my $deps = $args{'Dependencies'};
- my $list = [];
-
--# No dependencies that should be deleted with record
--# Scrip actions and conditions should be exported in feature with it.
+-# Scrips
+- my $objs = RT::Scrips->new( $self->CurrentUser );
+- $objs->Limit( FIELD => 'ScripAction', VALUE => $self->Id );
+- $deps->_PushDependencies(
+- BaseObject => $self,
+- Flags => RT::Shredder::Constants::DEPENDS_ON,
+- TargetObjects => $objs,
+- Shredder => $args{'Shredder'}
+- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# Queue
-- my $obj = $self->QueueObj;
-- if( defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
-- }
--
--# Condition
-- $obj = $self->ConditionObj;
-- if( defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related ScripCondition #". $self->id ." object";
-- }
--# Action
-- $obj = $self->ActionObj;
-- if( defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related ScripAction #". $self->id ." object";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
--
-- return $self->SUPER::__Relates( %args );
--}
--
-1;
-diff --git a/lib/RT/Shredder/ScripAction.pm b/lib/RT/Shredder/ScripAction.pm
+diff --git a/lib/RT/Shredder/ScripCondition.pm b/lib/RT/Shredder/ScripCondition.pm
deleted file mode 100644
---- a/lib/RT/Shredder/ScripAction.pm
+--- a/lib/RT/Shredder/ScripCondition.pm
+++ /dev/null
@@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -2866,8 +1800,8 @@
-#
-# END BPS TAGGED BLOCK }}}
-
--use RT::ScripAction ();
--package RT::ScripAction;
+-use RT::ScripCondition ();
+-package RT::ScripCondition;
-
-use strict;
-use warnings;
@@ -2890,7 +1824,7 @@
-
-# Scrips
- my $objs = RT::Scrips->new( $self->CurrentUser );
-- $objs->Limit( FIELD => 'ScripAction', VALUE => $self->Id );
+- $objs->Limit( FIELD => 'ScripCondition', VALUE => $self->Id );
- $deps->_PushDependencies(
- BaseObject => $self,
- Flags => RT::Shredder::Constants::DEPENDS_ON,
@@ -2901,34 +1835,18 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# TODO: Check here for exec module
--
-- return $self->SUPER::__Relates( %args );
--}
--
-1;
-diff --git a/lib/RT/Shredder/ScripCondition.pm b/lib/RT/Shredder/ScripCondition.pm
+diff --git a/lib/RT/Shredder/Template.pm b/lib/RT/Shredder/Template.pm
deleted file mode 100644
---- a/lib/RT/Shredder/ScripCondition.pm
+--- a/lib/RT/Shredder/Template.pm
+++ /dev/null
@@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -2972,8 +1890,8 @@
-#
-# END BPS TAGGED BLOCK }}}
-
--use RT::ScripCondition ();
--package RT::ScripCondition;
+-use RT::Template ();
+-package RT::Template;
-
-use strict;
-use warnings;
@@ -2995,47 +1913,30 @@
- my $list = [];
-
-# Scrips
-- my $objs = RT::Scrips->new( $self->CurrentUser );
-- $objs->Limit( FIELD => 'ScripCondition', VALUE => $self->Id );
+- push( @$list, $self->UsedBy );
+-
- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::DEPENDS_ON,
-- TargetObjects => $objs,
-- Shredder => $args{'Shredder'}
-- );
+- BaseObject => $self,
+- Flags => RT::Shredder::Constants::DEPENDS_ON,
+- TargetObjects => $list,
+- Shredder => $args{'Shredder'},
+- );
-
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# TODO: Check here for exec module
--
-- return $self->SUPER::__Relates( %args );
--}
--
--
-1;
-diff --git a/lib/RT/Shredder/Template.pm b/lib/RT/Shredder/Template.pm
+diff --git a/lib/RT/Shredder/Ticket.pm b/lib/RT/Shredder/Ticket.pm
deleted file mode 100644
---- a/lib/RT/Shredder/Template.pm
+--- a/lib/RT/Shredder/Ticket.pm
+++ /dev/null
@@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -3079,8 +1980,8 @@
-#
-# END BPS TAGGED BLOCK }}}
-
--use RT::Template ();
--package RT::Template;
+-use RT::Ticket ();
+-package RT::Ticket;
-
-use strict;
-use warnings;
@@ -3089,7 +1990,6 @@
-use RT::Shredder::Constants;
-use RT::Shredder::Exceptions;
-use RT::Shredder::Dependencies;
--
-
-sub __DependsOn
-{
@@ -3102,66 +2002,42 @@
- my $deps = $args{'Dependencies'};
- my $list = [];
-
--# Scrips
-- my $objs = RT::Scrips->new( $self->CurrentUser );
-- $objs->Limit( FIELD => 'Template', VALUE => $self->Id );
+-# Tickets which were merged in
+- my $objs = RT::Tickets->new( $self->CurrentUser );
+- $objs->{'allow_deleted_search'} = 1;
+- $objs->Limit( FIELD => 'EffectiveId', VALUE => $self->Id );
+- $objs->Limit( FIELD => 'id', OPERATOR => '!=', VALUE => $self->Id );
- push( @$list, $objs );
-
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::DEPENDS_ON,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'},
-- );
--
-- return $self->SUPER::__DependsOn( %args );
--}
--
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# Queue
-- my $obj = $self->QueueObj;
-- if( $obj && defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
-- }
--
--# TODO: Users(Creator, LastUpdatedBy)
--
+-# Ticket role groups( Owner, Requestors, Cc, AdminCc )
+- $objs = RT::Groups->new( $self->CurrentUser );
+- $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Ticket-Role', CASESENSITIVE => 0 );
+- $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
+- push( @$list, $objs );
+-
+-#TODO: Users, Queues if we wish export tool
- $deps->_PushDependencies(
- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
+- Flags => RT::Shredder::Constants::DEPENDS_ON,
- TargetObjects => $list,
- Shredder => $args{'Shredder'}
- );
-- return $self->SUPER::__Relates( %args );
+-
+- return $self->SUPER::__DependsOn( %args );
-}
-
-1;
-diff --git a/lib/RT/Shredder/Ticket.pm b/lib/RT/Shredder/Ticket.pm
+diff --git a/lib/RT/Shredder/Transaction.pm b/lib/RT/Shredder/Transaction.pm
deleted file mode 100644
---- a/lib/RT/Shredder/Ticket.pm
+--- a/lib/RT/Shredder/Transaction.pm
+++ /dev/null
@@
-# BEGIN BPS TAGGED BLOCK {{{
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -3205,8 +2081,8 @@
-#
-# END BPS TAGGED BLOCK }}}
-
--use RT::Ticket ();
--package RT::Ticket;
+-use RT::Transaction ();
+-package RT::Transaction;
-
-use strict;
-use warnings;
@@ -3227,138 +2103,6 @@
- my $deps = $args{'Dependencies'};
- my $list = [];
-
--# Tickets which were merged in
-- my $objs = RT::Tickets->new( $self->CurrentUser );
-- $objs->{'allow_deleted_search'} = 1;
-- $objs->Limit( FIELD => 'EffectiveId', VALUE => $self->Id );
-- $objs->Limit( FIELD => 'id', OPERATOR => '!=', VALUE => $self->Id );
-- push( @$list, $objs );
--
--# Ticket role groups( Owner, Requestors, Cc, AdminCc )
-- $objs = RT::Groups->new( $self->CurrentUser );
-- $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Ticket-Role' );
-- $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
-- push( @$list, $objs );
--
--#TODO: Users, Queues if we wish export tool
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::DEPENDS_ON,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
--
-- return $self->SUPER::__DependsOn( %args );
--}
--
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# Queue
-- my $obj = $self->QueueObj;
-- if( $obj && defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Queue #". $self->Queue ." object";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
--
--1;
-
-diff --git a/lib/RT/Shredder/Transaction.pm b/lib/RT/Shredder/Transaction.pm
-deleted file mode 100644
---- a/lib/RT/Shredder/Transaction.pm
-+++ /dev/null
-@@
--# BEGIN BPS TAGGED BLOCK {{{
--#
--# COPYRIGHT:
--#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
--# <sales at bestpractical.com>
--#
--# (Except where explicitly superseded by other copyright notices)
--#
--#
--# LICENSE:
--#
--# This work is made available to you under the terms of Version 2 of
--# the GNU General Public License. A copy of that license should have
--# been provided with this software, but in any event can be snarfed
--# from www.gnu.org.
--#
--# This work is distributed in the hope that it will be useful, but
--# WITHOUT ANY WARRANTY; without even the implied warranty of
--# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--# General Public License for more details.
--#
--# You should have received a copy of the GNU General Public License
--# along with this program; if not, write to the Free Software
--# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
--# 02110-1301 or visit their web page on the internet at
--# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
--#
--#
--# CONTRIBUTION SUBMISSION POLICY:
--#
--# (The following paragraph is not intended to limit the rights granted
--# to you to modify and distribute this software under the terms of
--# the GNU General Public License and is only of importance to you if
--# you choose to contribute your changes and enhancements to the
--# community by submitting them to Best Practical Solutions, LLC.)
--#
--# By intentionally submitting any modifications, corrections or
--# derivatives to this work, or any other work intended for use with
--# Request Tracker, to Best Practical Solutions, LLC, you confirm that
--# you are the copyright holder for those contributions and you grant
--# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
--# royalty-free, perpetual, license to use, copy, create derivative
--# works based on those contributions, and sublicense and distribute
--# those contributions and any derivatives thereof.
--#
--# END BPS TAGGED BLOCK }}}
--
--use RT::Transaction ();
--package RT::Transaction;
--
--use strict;
--use warnings;
--use warnings FATAL => 'redefine';
--
--use RT::Shredder::Constants;
--use RT::Shredder::Exceptions;
--use RT::Shredder::Dependencies;
--
--sub __DependsOn
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
-# Attachments
- $deps->_PushDependencies(
- BaseObject => $self,
@@ -3370,39 +2114,6 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# Ticket
-- my $obj = $self->TicketObj;
-- if( $obj && defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
-- }
--
--# TODO: Users(Creator, LastUpdatedBy)
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
--
-1;
diff --git a/lib/RT/Shredder/User.pm b/lib/RT/Shredder/User.pm
@@ -3414,7 +2125,7 @@
-#
-# COPYRIGHT:
-#
--# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+-# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
-# <sales at bestpractical.com>
-#
-# (Except where explicitly superseded by other copyright notices)
@@ -3484,6 +2195,7 @@
- ObjectClasses
- ObjectCustomFieldValues
- ObjectCustomFields
+- ObjectScrips
- Principals
- Queues
- ScripActions
@@ -3517,7 +2229,7 @@
-# ACL equivalence group
-# don't use LoadACLEquivalenceGroup cause it may not exists any more
- my $objs = RT::Groups->new( $self->CurrentUser );
-- $objs->Limit( FIELD => 'Domain', VALUE => 'ACLEquivalence' );
+- $objs->Limit( FIELD => 'Domain', VALUE => 'ACLEquivalence', CASESENSITIVE => 0 );
- $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
- push( @$list, $objs );
-
@@ -3540,7 +2252,7 @@
- my $class = "RT::$_";
- foreach my $method ( qw(Creator LastUpdatedBy) ) {
- my $objs = $class->new( $self->CurrentUser );
-- next unless $objs->NewItem->_Accessible( $method => 'read' );
+- next unless $objs->RecordClass->_Accessible( $method => 'read' );
- $objs->Limit( FIELD => $method, VALUE => $self->id );
- push @var_objs, $objs;
- }
@@ -3555,48 +2267,6 @@
- return $self->SUPER::__DependsOn( %args );
-}
-
--sub __Relates
--{
-- my $self = shift;
-- my %args = (
-- Shredder => undef,
-- Dependencies => undef,
-- @_,
-- );
-- my $deps = $args{'Dependencies'};
-- my $list = [];
--
--# Principal
-- my $obj = $self->PrincipalObj;
-- if( $obj && defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related ACL equivalence Group object";
-- }
--
-- $obj = RT::Group->new( RT->SystemUser );
-- $obj->LoadACLEquivalenceGroup( $self->PrincipalObj );
-- if( $obj && defined $obj->id ) {
-- push( @$list, $obj );
-- } else {
-- my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-- $self = $rec->{'Object'};
-- $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-- $rec->{'Description'} = "Have no related Principal #". $self->id ." object";
-- }
--
-- $deps->_PushDependencies(
-- BaseObject => $self,
-- Flags => RT::Shredder::Constants::RELATES,
-- TargetObjects => $list,
-- Shredder => $args{'Shredder'}
-- );
-- return $self->SUPER::__Relates( %args );
--}
--
-sub BeforeWipeout
-{
- my $self = shift;
@@ -3612,12 +2282,9 @@
--- a/lib/RT/Template.pm
+++ b/lib/RT/Template.pm
@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+ $deps->Add( out => $self->QueueObj ) if $self->QueueObj->Id;
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -3629,9 +2296,7 @@
+ my $list = [];
+
+# Scrips
-+ my $objs = RT::Scrips->new( $self->CurrentUser );
-+ $objs->Limit( FIELD => 'Template', VALUE => $self->Id );
-+ push( @$list, $objs );
++ push( @$list, $self->UsedBy );
+
+ $deps->_PushDependencies(
+ BaseObject => $self,
@@ -3643,51 +2308,17 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Queue
-+ my $obj = $self->QueueObj;
-+ if( $obj && defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Queue #". $self->id ." object";
-+ }
-+
-+# TODO: Users(Creator, LastUpdatedBy)
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
- RT::Base->_ImportOverlays();
-
+ sub PreInflate {
+ my $class = shift;
+ my ($importer, $uid, $data) = @_;
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@
- {read => 1, write => 1, sql_type => 5, length => 6, is_blob => 0, is_numeric => 1, type => 'smallint(6)', default => '0'},
+ $deps->Add( out => $self->OwnerObj );
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -3707,7 +2338,7 @@
+
+# Ticket role groups( Owner, Requestors, Cc, AdminCc )
+ $objs = RT::Groups->new( $self->CurrentUser );
-+ $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Ticket-Role' );
++ $objs->Limit( FIELD => 'Domain', VALUE => 'RT::Ticket-Role', CASESENSITIVE => 0 );
+ $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
+ push( @$list, $objs );
+
@@ -3722,49 +2353,17 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Queue
-+ my $obj = $self->QueueObj;
-+ if( $obj && defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Queue #". $self->Queue ." object";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
- RT::Base->_ImportOverlays();
-
+ sub Serialize {
+ my $self = shift;
+ my %args = (@_);
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+ }
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -3773,9 +2372,7 @@
+ @_,
+ );
+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Attachments
++
+ $deps->_PushDependencies(
+ BaseObject => $self,
+ Flags => RT::Shredder::Constants::DEPENDS_ON,
@@ -3786,51 +2383,17 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Ticket
-+ my $obj = $self->TicketObj;
-+ if( $obj && defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Ticket #". $self->id ." object";
-+ }
-+
-+# TODO: Users(Creator, LastUpdatedBy)
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-
- RT::Base->_ImportOverlays();
-
+ sub Serialize {
+ my $self = shift;
+ my %args = (@_);
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@
- {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
+ # and LastUpdatedBy columns.
+ }
- }
--};
-+}
-+
+sub __DependsOn {
+ my $self = shift;
+ my %args = (
@@ -3852,7 +2415,7 @@
+# ACL equivalence group
+# don't use LoadACLEquivalenceGroup cause it may not exists any more
+ my $objs = RT::Groups->new( $self->CurrentUser );
-+ $objs->Limit( FIELD => 'Domain', VALUE => 'ACLEquivalence' );
++ $objs->Limit( FIELD => 'Domain', VALUE => 'ACLEquivalence', CASESENSITIVE => 0 );
+ $objs->Limit( FIELD => 'Instance', VALUE => $self->Id );
+ push( @$list, $objs );
+
@@ -3870,7 +2433,6 @@
+
+# TODO: Almost all objects has Creator, LastUpdatedBy and etc. fields
+# which are references on users(Principal actualy)
-+ my @var_objs;
+ my @OBJECTS = qw(
+ ACL
+ Articles
@@ -3886,6 +2448,7 @@
+ ObjectClasses
+ ObjectCustomFieldValues
+ ObjectCustomFields
++ ObjectScrips
+ Principals
+ Queues
+ ScripActions
@@ -3896,11 +2459,12 @@
+ Transactions
+ Users
+ );
++ my @var_objs;
+ foreach( @OBJECTS ) {
+ my $class = "RT::$_";
+ foreach my $method ( qw(Creator LastUpdatedBy) ) {
+ my $objs = $class->new( $self->CurrentUser );
-+ next unless $objs->NewItem->_Accessible( $method => 'read' );
++ next unless $objs->RecordClass->_Accessible( $method => 'read' );
+ $objs->Limit( FIELD => $method, VALUE => $self->id );
+ push @var_objs, $objs;
+ }
@@ -3915,47 +2479,6 @@
+ return $self->SUPER::__DependsOn( %args );
+}
+
-+sub __Relates {
-+ my $self = shift;
-+ my %args = (
-+ Shredder => undef,
-+ Dependencies => undef,
-+ @_,
-+ );
-+ my $deps = $args{'Dependencies'};
-+ my $list = [];
-+
-+# Principal
-+ my $obj = $self->PrincipalObj;
-+ if( $obj && defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related ACL equivalence Group object";
-+ }
-+
-+ $obj = RT::Group->new( RT->SystemUser );
-+ $obj->LoadACLEquivalenceGroup( $self->PrincipalObj );
-+ if( $obj && defined $obj->id ) {
-+ push( @$list, $obj );
-+ } else {
-+ my $rec = $args{'Shredder'}->GetRecord( Object => $self );
-+ $self = $rec->{'Object'};
-+ $rec->{'State'} |= RT::Shredder::Constants::INVALID;
-+ $rec->{'Description'} = "Have no related Principal #". $self->id ." object";
-+ }
-+
-+ $deps->_PushDependencies(
-+ BaseObject => $self,
-+ Flags => RT::Shredder::Constants::RELATES,
-+ TargetObjects => $list,
-+ Shredder => $args{'Shredder'}
-+ );
-+ return $self->SUPER::__Relates( %args );
-+}
-+
+sub BeforeWipeout {
+ my $self = shift;
+ if( $self->Name =~ /^(RT_System|Nobody)$/ ) {
@@ -3963,7 +2486,7 @@
+ }
+ return $self->SUPER::BeforeWipeout( @_ );
+}
-
- RT::Base->_ImportOverlays();
-
-
++
+ sub Serialize {
+ my $self = shift;
+ return (
7: d290d60 < -: ------- Remove stub __Relates subs
More information about the rt-commit
mailing list