Skip to content

Commit d52271b

Browse files
committed
Fix shredding users with their own attributes failing without a resolver
The @objects loop in RT::User::__DependsOn included Attributes, causing all attributes where Creator/LastUpdatedBy matched the user being shredded to be added as VARIABLE (resolvable) dependencies. This required a resolver to be registered, which is only done when the replace_relations option is set. As a result, shredding a user with a RecentlyViewedTickets attribute (or any own attribute) always failed with "Couldn't find resolver for dependency". The user's own attributes are already handled as direct DEPENDS_ON (delete) dependencies via $self->Attributes in RT::Record::__DependsOn, so they don't need to appear as VARIABLE dependencies too.
1 parent 54c2ef8 commit d52271b

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

lib/RT/User.pm

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3180,7 +3180,6 @@ sub __DependsOn {
31803180
ACL
31813181
Articles
31823182
Attachments
3183-
Attributes
31843183
CachedGroupMembers
31853184
Classes
31863185
CustomFieldValues
@@ -3215,6 +3214,23 @@ sub __DependsOn {
32153214
push @var_objs, $objs;
32163215
}
32173216
}
3217+
3218+
# Attributes of other objects (not owned by this user) that reference this
3219+
# user in Creator/LastUpdatedBy. The user's own attributes are already
3220+
# handled as direct DEPENDS_ON dependencies via $self->Attributes, so
3221+
# exclude them to avoid a duplicate VARIABLE dependency without a resolver.
3222+
for my $method (qw(Creator LastUpdatedBy)) {
3223+
my $objs = RT::Attributes->new( $self->CurrentUser );
3224+
$objs->Limit( FIELD => $method, VALUE => $self->id );
3225+
$objs->Limit( FIELD => 'ObjectType', OPERATOR => '!=', VALUE => ref $self );
3226+
push @var_objs, $objs;
3227+
3228+
my $other_user_attrs = RT::Attributes->new( $self->CurrentUser );
3229+
$other_user_attrs->Limit( FIELD => $method, VALUE => $self->id );
3230+
$other_user_attrs->Limit( FIELD => 'ObjectType', VALUE => ref $self );
3231+
$other_user_attrs->Limit( FIELD => 'ObjectId', OPERATOR => '!=', VALUE => $self->id );
3232+
push @var_objs, $other_user_attrs;
3233+
}
32183234
$deps->_PushDependencies(
32193235
BaseObject => $self,
32203236
Flags => RT::Shredder::Constants::DEPENDS_ON | RT::Shredder::Constants::VARIABLE,

0 commit comments

Comments
 (0)