]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
fix for bug 51670: Dependency loops are possible
authorcyeh%bluemartini.com <>
Tue, 27 Feb 2001 06:50:58 +0000 (06:50 +0000)
committercyeh%bluemartini.com <>
Tue, 27 Feb 2001 06:50:58 +0000 (06:50 +0000)
we now search each list (dependson, blocks) to see if a bug number shows
up in each list. a bug can't be dependent upon and block the same bug.
also make it so you can't set a bug blocking or dependent on itself.

process_bug.cgi

index 74780acb767c7041c38f6c2da5ce59e6f2449169..061dadc93bcae1e306ff0706b56a9a2a2d1a4827 100755 (executable)
@@ -755,6 +755,9 @@ The changes made were:
                 if ($comp ne $i) {
                     PuntTryAgain("$i is not a legal bug number");
                 }
+                if ($id eq $i) {
+                    PuntTryAgain("You can't make a bug blocked or dependent on itself.");
+                }
                 if (!exists $seen{$i}) {
                     push(@{$deps{$target}}, $i);
                     $seen{$i} = 1;
@@ -778,8 +781,27 @@ The changes made were:
                     }
                 }
             }
-                        
 
+           if ($me eq 'dependson') {
+                my @deps   =  @{$deps{'dependson'}};
+                my @blocks =  @{$deps{'blocked'}};
+                my @union = ();
+                my @isect = ();
+                my %union = ();
+                my %isect = ();
+                foreach my $b (@deps, @blocks) { $union{$b}++ && $isect{$b}++ }
+                @union = keys %union;
+                @isect = keys %isect;
+               if (@isect > 0) {
+                    my $both;
+                    foreach my $i (@isect) {
+                       $both = $both . "#" . $i . " "; 
+                    }
+                    PuntTryAgain("Dependency loop detected!<P>" .
+                                 "This bug can't be both blocked and dependent " .
+                                 "on bug "  . $both . "!");
+                }
+            }
             my $tmp = $me;
             $me = $target;
             $target = $tmp;