[Rt-commit] rt branch, 4.4/circular-link-check, created. rt-4.2.11-169-g9043ebe
Dustin Graves
dustin at bestpractical.com
Tue Aug 18 15:49:14 EDT 2015
The branch, 4.4/circular-link-check has been created
at 9043ebe1ccb748a0e2bd3f606ed69ad3d0d69fc0 (commit)
- Log -----------------------------------------------------------------
commit 9043ebe1ccb748a0e2bd3f606ed69ad3d0d69fc0
Author: Dustin Graves <dustin at bestpractical.com>
Date: Tue Aug 18 19:48:26 2015 +0000
Change circular link check to work for more than just tickets
Fixes: I#31151
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index fc8dac2..fccafb3 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1406,11 +1406,13 @@ sub _AddLink {
return ( 0, $self->loc("Can't specify both base and target") );
}
elsif ( $args{'Base'} ) {
+ $args{'Base'} =~ s/\b0+//;
$args{'Target'} = $self->URI();
$remote_link = $args{'Base'};
$direction = 'Target';
}
elsif ( $args{'Target'} ) {
+ $args{'Target'} =~ s/\b0+//;
$args{'Base'} = $self->URI();
$remote_link = $args{'Target'};
$direction = 'Base';
@@ -1452,14 +1454,21 @@ sub _AddLink {
return ( $old_link->id, $self->loc("Link already exists"), 1 );
}
+ # Check for resulting circular relationships
if ( $args{'Type'} =~ /^(?:DependsOn|MemberOf)$/ ) {
-
my @tickets = $self->_AllLinkedTickets(
LinkType => $args{'Type'},
Direction => $direction eq 'Target' ? 'Base' : 'Target',
);
- if ( grep { $_->id == ( $direction eq 'Target' ? $args{'Base'} : $args{'Target'} ) } @tickets ) {
- return ( 0, $self->loc("Refused to add link which would create a circular relationship") );
+
+ foreach my $ticket (@tickets) {
+ my $uri_prefix = '';
+ if ($ticket->isa('RT::Asset')) { $uri_prefix = 'asset:'; }
+ elsif ($ticket->isa('RT::Article')) { $uri_prefix = 'a:'; }
+
+ if ( $uri_prefix . $ticket->id eq ( $direction eq 'Target' ? $args{'Base'} : $args{'Target'} ) ) {
+ return ( 0, $self->loc("Refused to add link which would create a circular relationship") );
+ }
}
}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list