]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 279740 : Move CountOpenDependencies out of globals.pl
authortravis%sedsystems.ca <>
Wed, 2 Feb 2005 01:43:26 +0000 (01:43 +0000)
committertravis%sedsystems.ca <>
Wed, 2 Feb 2005 01:43:26 +0000 (01:43 +0000)
Patch by Max Kanat-Alexander <mkanat@kerio.com>  r=wurblzap  a=justdave

Bugzilla/Bug.pm
globals.pl
process_bug.cgi

index ad48e763f17c8a2420de20d27c5322c34cfea7a9..8f08d8c2569c6359ea7d8f66f2afc7a146c383c2 100755 (executable)
@@ -536,6 +536,32 @@ sub GetComments {
     return \@comments;
 }
 
+# CountOpenDependencies counts the number of open dependent bugs for a
+# list of bugs and returns a list of bug_id's and their dependency count
+# It takes one parameter:
+#  - A list of bug numbers whose dependencies are to be checked
+sub CountOpenDependencies {
+    my (@bug_list) = @_;
+    my @dependencies;
+    my $dbh = Bugzilla->dbh;
+
+    my $sth = $dbh->prepare(
+          "SELECT blocked, count(bug_status) " .
+            "FROM bugs, dependencies " .
+           "WHERE blocked IN (" . (join "," , @bug_list) . ") " .
+             "AND bug_id = dependson " .
+             "AND bug_status IN ('" . (join "','", &::OpenStates())  . "') " .
+        "GROUP BY blocked ");
+    $sth->execute();
+
+    while (my ($bug_id, $dependencies) = $sth->fetchrow_array()) {
+        push(@dependencies, { bug_id       => $bug_id,
+                              dependencies => $dependencies });
+    }
+
+    return @dependencies;
+}
+
 sub AUTOLOAD {
   use vars qw($AUTOLOAD);
   my $attr = $AUTOLOAD;
index 1529a0f6aae76171817c96c4dbdbb64a68bd71a7..b48963412efab2269cf23e9cce5d3798a09ec465 100644 (file)
@@ -999,38 +999,6 @@ sub GetBugLink {
     }
 }
 
-# CountOpenDependencies counts the number of open dependent bugs for a
-# list of bugs and returns a list of bug_id's and their dependency count
-# It takes one parameter:
-#  - A list of bug numbers whose dependencies are to be checked
-
-sub CountOpenDependencies {
-    my (@bug_list) = @_;
-    my @dependencies;
-    
-    # Make sure any unfetched data from a currently running query
-    # is saved off rather than overwritten
-    PushGlobalSQLState();
-   
-    SendSQL("SELECT blocked, count(bug_status) " .
-            "FROM bugs, dependencies " .
-            "WHERE blocked IN (" . (join "," , @bug_list) . ") " .
-            "AND bug_id = dependson " .
-            "AND bug_status IN ('" . (join "','", OpenStates())  . "') " .
-            "GROUP BY blocked ");
-   
-    while (MoreSQLData()) {
-        my ($bug_id, $dependencies) = FetchSQLData();
-        push(@dependencies, { bug_id       => $bug_id, 
-                              dependencies => $dependencies });
-    }
-
-    # All done with this sidetrip
-    PopGlobalSQLState();
-
-    return @dependencies;
-}
-
 sub GetLongDescriptionAsText {
     my ($id, $start, $end) = (@_);
     my $result = "";
index 2efc62d5937dddc8cf359e4b5f3dd084266a2888..c560e90ffefbd7c85207a8143d70da16e4d0bae4 100755 (executable)
@@ -935,7 +935,7 @@ SWITCH: for ($::FORM{'knob'}) {
         if (Param("noresolveonopenblockers")
             && $::FORM{'resolution'} eq 'FIXED')
         {
-            my @dependencies = CountOpenDependencies(@idlist);
+            my @dependencies = Bugzilla::Bug::CountOpenDependencies(@idlist);
             if (scalar @dependencies > 0) {
                 ThrowUserError("still_unresolved_bugs",
                                { dependencies     => \@dependencies,