]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 112373 you should be able to enter bug dependencies/blockers when you enter a...
authorbugreport%peshkin.net <>
Thu, 17 Oct 2002 11:31:49 +0000 (11:31 +0000)
committerbugreport%peshkin.net <>
Thu, 17 Oct 2002 11:31:49 +0000 (11:31 +0000)
patch by jhedlund
r,2xr=joel

CGI.pl
checksetup.pl
post_bug.cgi
process_bug.cgi
processmail
template/en/default/bug/create/create.html.tmpl

diff --git a/CGI.pl b/CGI.pl
index 24c006c0373dc5586619b3dcb8df510ccadf20fa..6ca5f258802cc7f9b442c57e1e6210d4a0443328 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -894,6 +894,37 @@ sub CheckIfVotedConfirmed {
     }
 
 }
+sub LogActivityEntry {
+    my ($i,$col,$removed,$added,$whoid,$timestamp) = @_;
+    # in the case of CCs, deps, and keywords, there's a possibility that someone    # might try to add or remove a lot of them at once, which might take more
+    # space than the activity table allows.  We'll solve this by splitting it
+    # into multiple entries if it's too long.
+    while ($removed || $added) {
+        my ($removestr, $addstr) = ($removed, $added);
+        if (length($removestr) > 254) {
+            my $commaposition = FindWrapPoint($removed, 254);
+            $removestr = substr($removed,0,$commaposition);
+            $removed = substr($removed,$commaposition);
+            $removed =~ s/^[,\s]+//; # remove any comma or space
+        } else {
+            $removed = ""; # no more entries
+        }
+        if (length($addstr) > 254) {
+            my $commaposition = FindWrapPoint($added, 254);
+            $addstr = substr($added,0,$commaposition);
+            $added = substr($added,$commaposition);
+            $added =~ s/^[,\s]+//; # remove any comma or space
+        } else {
+            $added = ""; # no more entries
+        }
+        $addstr = SqlQuote($addstr);
+        $removestr = SqlQuote($removestr);
+        my $fieldid = GetFieldID($col);
+        SendSQL("INSERT INTO bugs_activity " .
+                "(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
+                "($i,$whoid," . SqlQuote($timestamp) . ",$fieldid,$removestr,$addstr)");
+    }
+}
 
 sub GetBugActivity {
     my ($id, $starttime) = (@_);
index c44c032357b93e8b6ec70938d57f6d4c17e7f254..5f7ca5326c5871e70b3aa61576344470aa3c7b57 100755 (executable)
@@ -1836,8 +1836,8 @@ AddFDef("reporter", "ReportedBy", 1);
 AddFDef("votes", "Votes", 0);
 AddFDef("qa_contact", "QAContact", 1);
 AddFDef("cc", "CC", 1);
-AddFDef("dependson", "BugsThisDependsOn", 0);
-AddFDef("blocked", "OtherBugsDependingOnThis", 0);
+AddFDef("dependson", "BugsThisDependsOn", 1);
+AddFDef("blocked", "OtherBugsDependingOnThis", 1);
 AddFDef("attachments.description", "Attachment description", 0);
 AddFDef("attachments.thedata", "Attachment data", 0);
 AddFDef("attachments.filename", "Attachment filename", 0);
index d519a484c47176b815e7d5e4776cf8bfdea6038f..882bd3dd985c9c37cbb7f3a03e039dc9c92c0b7f 100755 (executable)
@@ -49,7 +49,7 @@ sub sillyness {
 use vars qw($vars $template);
 
 ConnectToDatabase();
-confirm_login();
+my $whoid = confirm_login();
 
 
 # The format of the initial comment can be structured by adding fields to the
@@ -231,6 +231,77 @@ if ($::FORM{'keywords'} && UserInGroup("editbugs")) {
     }
 }
 
+# Check for valid dependency info. 
+foreach my $field ("dependson", "blocked") {
+    if (UserInGroup("editbugs") && defined($::FORM{$field}) &&
+        $::FORM{$field} ne "") {
+        my @validvalues;
+        foreach my $id (split(/[\s,]+/, $::FORM{$field})) {
+            next unless $id;
+            ValidateBugID($id, 1);
+            push(@validvalues, $id);
+        }
+        $::FORM{$field} = join(",", @validvalues);
+    }
+}
+# Gather the dependecy list, and make sure there are no circular refs
+my %deps;
+if (UserInGroup("editbugs") && defined($::FORM{'dependson'})) {
+    my $me = "blocked";
+    my $target = "dependson";
+    my %deptree;
+    for (1..2) {
+        $deptree{$target} = [];
+        my %seen;
+        foreach my $i (split('[\s,]+', $::FORM{$target})) {
+            if (!exists $seen{$i}) {
+                push(@{$deptree{$target}}, $i);
+                $seen{$i} = 1;
+            }
+        }
+        # populate $deps{$target} as first-level deps only.
+        # and find remainder of dependency tree in $deptree{$target}
+        @{$deps{$target}} = @{$deptree{$target}};
+        my @stack = @{$deps{$target}};
+        while (@stack) {
+            my $i = shift @stack;
+            SendSQL("select $target from dependencies where $me = " .
+                    SqlQuote($i));
+            while (MoreSQLData()) {
+                my $t = FetchOneColumn();
+                if (!exists $seen{$t}) {
+                    push(@{$deptree{$target}}, $t);
+                    push @stack, $t;
+                    $seen{$t} = 1;
+                } 
+            }
+        }
+        
+        if ($me eq 'dependson') {
+            my @deps   =  @{$deptree{'dependson'}};
+            my @blocks =  @{$deptree{'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 . GetBugLink($i, "#" . $i) . " ";
+                }
+                $vars->{'both'} = $both;
+                ThrowUserError("dependency_loop_multi", undef, "abort");
+            }
+        }
+        my $tmp = $me;
+        $me = $target;
+        $target = $tmp;
+    }
+}
+
 # Build up SQL string to add bug.
 my $sql = "INSERT INTO bugs " . 
   "(" . join(",", @used_fields) . ", reporter, creation_ts, " .
@@ -300,6 +371,9 @@ SendSQL("LOCK TABLES bugs WRITE, bug_group_map WRITE, longdescs WRITE, cc WRITE,
 # Add the bug report to the DB.
 SendSQL($sql);
 
+SendSQL("select now()");
+my $timestamp = FetchOneColumn();
+
 # Get the bug ID back.
 SendSQL("select LAST_INSERT_ID()");
 my $id = FetchOneColumn();
@@ -319,11 +393,28 @@ foreach my $ccid (keys(%ccids)) {
     SendSQL("INSERT INTO cc (bug_id, who) VALUES ($id, $ccid)");
 }
 
+my @all_deps;
 if (UserInGroup("editbugs")) {
     foreach my $keyword (@keywordlist) {
         SendSQL("INSERT INTO keywords (bug_id, keywordid) 
                  VALUES ($id, $keyword)");
     }
+    if (defined $::FORM{'dependson'}) {
+        my $me = "blocked";
+        my $target = "dependson";
+        for (1..2) {
+            foreach my $i (@{$deps{$target}}) {
+                SendSQL("INSERT INTO dependencies ($me, $target) values " .
+                        "($id, $i)");
+                push(@all_deps, $i); # list for mailing dependent bugs
+                # Log the activity for the other bug:
+                LogActivityEntry($i, $me, "", $id, $whoid, $timestamp);
+            }
+            my $tmp = $me;
+            $me = $target;
+            $target = $tmp;
+        }
+    }
 }
 
 SendSQL("UNLOCK TABLES") if Param("shadowdb");
@@ -360,6 +451,21 @@ print "Content-type: text/html\n\n";
 $template->process("bug/create/created.html.tmpl", $vars)
   || ThrowTemplateError($template->error());
 
+foreach my $i (@all_deps) {
+    $vars->{'mail'} = "";
+    open(PMAIL, "-|") or exec('./processmail', $i, $::COOKIE{'Bugzilla_login'});    $vars->{'mail'} .= $_ while <PMAIL>;
+    close(PMAIL);
+
+    $vars->{'id'} = $i;
+    $vars->{'type'} = "dep";
+
+    # Let the user know we checked to see if we should email notice
+    # of this new bug to users with a relationship to the depenedant
+    # bug and who did and didn't receive email about it
+    $template->process("bug/process/results.html.tmpl", $vars) 
+      || ThrowTemplateError($template->error());
+}
+
 $::FORM{'id'} = $id;
 
 show_bug("header is already done");
index 43895ced39e7157a096a064c4b6883ce6da16109..427e622c47a4557b982f2b98dad9fb31002e4cc8 100755 (executable)
@@ -1013,49 +1013,16 @@ sub FindWrapPoint {
     return $wrappoint;
 }
 
-sub LogActivityEntry {
-    my ($i,$col,$removed,$added) = @_;
-    # in the case of CCs, deps, and keywords, there's a possibility that someone
-    # might try to add or remove a lot of them at once, which might take more
-    # space than the activity table allows.  We'll solve this by splitting it
-    # into multiple entries if it's too long.
-    while ($removed || $added) {
-        my ($removestr, $addstr) = ($removed, $added);
-        if (length($removestr) > 254) {
-            my $commaposition = FindWrapPoint($removed, 254);
-            $removestr = substr($removed,0,$commaposition);
-            $removed = substr($removed,$commaposition);
-            $removed =~ s/^[,\s]+//; # remove any comma or space
-        } else {
-            $removed = ""; # no more entries
-        }
-        if (length($addstr) > 254) {
-            my $commaposition = FindWrapPoint($added, 254);
-            $addstr = substr($added,0,$commaposition);
-            $added = substr($added,$commaposition);
-            $added =~ s/^[,\s]+//; # remove any comma or space
-        } else {
-            $added = ""; # no more entries
-        }
-        $addstr = SqlQuote($addstr);
-        $removestr = SqlQuote($removestr);
-        my $fieldid = GetFieldID($col);
-        SendSQL("INSERT INTO bugs_activity " .
-                "(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
-                "($i,$whoid," . SqlQuote($timestamp) . ",$fieldid,$removestr,$addstr)");
-        $bug_changed = 1;
-    }
-}
-
 sub LogDependencyActivity {
     my ($i, $oldstr, $target, $me) = (@_);
     my $newstr = SnapShotDeps($i, $target, $me);
     if ($oldstr ne $newstr) {
         # Figure out what's really different...
         my ($removed, $added) = DiffStrings($oldstr, $newstr);
-        LogActivityEntry($i,$target,$removed,$added);
+        LogActivityEntry($i,$target,$removed,$added,$whoid,$timestamp);
         # update timestamp on target bug so midairs will be triggered
         SendSQL("UPDATE bugs SET delta_ts=NOW() WHERE bug_id=$i");
+        $bug_changed = 1;
         return 1;
     }
     return 0;
@@ -1210,7 +1177,9 @@ foreach my $id (@idlist) {
             AppendComment($id, $::COOKIE{'Bugzilla_login'}, $::FORM{'comment'},
                 $::FORM{'commentprivacy'}, $timestamp, $::FORM{'work_time'});
             if ($::FORM{'work_time'} != 0) {
-                LogActivityEntry($id, "work_time", "", $::FORM{'work_time'});
+                LogActivityEntry($id, "work_time", "", $::FORM{'work_time'},
+                                 $whoid, $timestamp);
+                $bug_changed = 1;
             }
         }
     }
@@ -1278,7 +1247,9 @@ foreach my $id (@idlist) {
     my $groupDelNames = join(',', @groupDelNames);
     my $groupAddNames = join(',', @groupAddNames);
 
-    LogActivityEntry($id, "bug_group", $groupDelNames, $groupAddNames); 
+    LogActivityEntry($id, "bug_group", $groupDelNames, $groupAddNames,
+                     $whoid, $timestamp); 
+    $bug_changed = 1;
     
     my $removedCcString = "";
     if (defined $::FORM{newcc} || defined $::FORM{removecc} || defined $::FORM{masscc}) {
@@ -1313,7 +1284,8 @@ foreach my $id (@idlist) {
         if (scalar(@removed) || scalar(@added)) {
             my $removed = join(", ", @removed);
             my $added = join(", ", @added);
-            LogActivityEntry($id,"cc",$removed,$added);
+            LogActivityEntry($id,"cc",$removed,$added,$whoid,$timestamp);
+            $bug_changed = 1;
         }
     }
 
@@ -1499,7 +1471,8 @@ foreach my $id (@idlist) {
                 RemoveVotes($id, 0,
                             "This bug has been moved to a different product");
             }
-            LogActivityEntry($id,$col,$old,$new);
+            LogActivityEntry($id,$col,$old,$new,$whoid,$timestamp);
+            $bug_changed = 1;
         }
     }
     # Set and update flags.
@@ -1553,7 +1526,8 @@ foreach my $id (@idlist) {
         unless ($isreporter || $isoncc || ! $::FORM{'confirm_add_duplicate'}) {
             # The reporter is oblivious to the existence of the new bug and is permitted access
             # ... add 'em to the cc (and record activity)
-            LogActivityEntry($duplicate,"cc","",DBID_to_name($reporter));
+            LogActivityEntry($duplicate,"cc","",DBID_to_name($reporter),
+                             $whoid,$timestamp);
             SendSQL("INSERT INTO cc (who, bug_id) VALUES ($reporter, " . SqlQuote($duplicate) . ")");
         }
         # Bug 171639 - Duplicate notifications do not need to be private. 
index 3b421e922ceba1ed74f9b1b5472937ddc025907c..fd1f50b629a3bae2ec931fd5848ab94c8a0dcc22 100755 (executable)
@@ -131,6 +131,22 @@ sub ProcessOneBug {
     }
     $values{'estimated_time'} = FormatTimeUnit($values{'estimated_time'});
 
+    my @dependslist;
+    SendSQL("SELECT dependson FROM dependencies WHERE 
+             blocked = $id ORDER BY dependson");
+    while (MoreSQLData()) {
+        push(@dependslist, FetchOneColumn());
+    }
+    $values{'dependson'} = join(",", @dependslist);
+
+    my @blockedlist;
+    SendSQL("SELECT blocked FROM dependencies WHERE 
+             dependson = $id ORDER BY blocked");
+    while (MoreSQLData()) {
+        push(@blockedlist, FetchOneColumn());
+    }
+    $values{'blocked'} = join(",", @blockedlist);
+
     my @diffs;
 
 
index 354dd990c678216d153856fe757650cdffdbf3b4..6bc3e5441946ca3075fb160299ecb2002fffb0aa 100644 (file)
         <input name="keywords" size="60" value=""> (optional)
       </td>
     </tr>
+    <tr>
+      <td align="right">
+        <strong>Depends on:</strong>
+      </td>
+      <td>
+        <input name="dependson" accesskey="d">
+      </td>
+    </tr>
+    <tr>
+      <td align="right">
+        <strong>Blocks:</strong>
+      </td>
+      <td>
+        <input name="blocked" accesskey="b">
+      </td>
+    </tr>
   [% END %]
   
   <tr>