]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug #93667: Move some code around, add some section heading comments.
authormatty%chariot.net.au <>
Sat, 5 Oct 2002 21:25:13 +0000 (21:25 +0000)
committermatty%chariot.net.au <>
Sat, 5 Oct 2002 21:25:13 +0000 (21:25 +0000)
sanitycheck.cgi

index caeb2513879f0be7073ca2fc654a2ee4ff15675e..bd931c03c1139e8763ee5fcd3ef15b23f713eed4 100755 (executable)
@@ -71,57 +71,6 @@ sub AlertBadVoteCache {
     $offervotecacherebuild = 1;
 }
 
-sub CrossCheck {
-    my $table = shift @_;
-    my $field = shift @_;
-
-    Status("Checking references to $table.$field");
-
-    while (@_) {
-        my $ref = shift @_;
-        my ($refertable, $referfield, $keyname, $exceptions) = @$ref;
-
-        $exceptions ||= [];
-        my %exceptions = map { $_ => 1 } @$exceptions;
-
-        Status("... from $refertable.$referfield");
-        
-        SendSQL("SELECT DISTINCT $refertable.$referfield" . ($keyname ? ", $refertable.$keyname" : '') . " " .
-                "FROM   $refertable LEFT JOIN $table " .
-                "  ON   $refertable.$referfield = $table.$field " .
-                "WHERE  $table.$field IS NULL " .
-                "  AND  $refertable.$referfield IS NOT NULL");
-
-        while (MoreSQLData()) {
-            my ($value, $key) = FetchSQLData();
-            if (!$exceptions{$value}) {
-                my $alert = "Bad value $value found in $refertable.$referfield";
-                if ($keyname) {
-                    if ($keyname eq 'bug_id') {
-                        $alert .= ' (bug ' . BugLink($key) . ')';
-                    }
-                    else {
-                        $alert .= " ($keyname == '$key')";
-                    }
-                }
-                Alert($alert);
-            }
-        }
-    }
-}
-
-sub DateCheck {
-    my $table = shift @_;
-    my $field = shift @_;
-    Status("Checking dates in $table.$field");
-    SendSQL("SELECT COUNT( $field ) FROM $table WHERE $field > NOW()");
-    my $c = FetchOneColumn();
-    if ($c) {
-        Alert("Found $c dates in future");
-    }
-}
-
-    
 my @badbugs;
 
 
@@ -151,6 +100,10 @@ if (exists $::FORM{'rebuildvotecache'}) {
     Status("Vote cache has been rebuilt.");
 }
 
+###########################################################################
+# Fix group derivations
+###########################################################################
+
 if (exists $::FORM{'rederivegroups'}) {
     Status("OK, All users' inherited permissions will be rechecked when " .
            "they next access Bugzilla.");
@@ -204,6 +157,10 @@ if (exists $::FORM{'cleangroupsnow'}) {
 
 print "OK, now running sanity checks.<p>\n";
 
+###########################################################################
+# Check enumeration values
+###########################################################################
+
 # This one goes first, because if this is wrong, then the below tests
 # will probably fail too
 
@@ -226,6 +183,45 @@ foreach my $field (("bug_severity", "bug_status", "op_sys",
 # Perform referential (cross) checks
 ###########################################################################
 
+sub CrossCheck {
+    my $table = shift @_;
+    my $field = shift @_;
+
+    Status("Checking references to $table.$field");
+
+    while (@_) {
+        my $ref = shift @_;
+        my ($refertable, $referfield, $keyname, $exceptions) = @$ref;
+
+        $exceptions ||= [];
+        my %exceptions = map { $_ => 1 } @$exceptions;
+
+        Status("... from $refertable.$referfield");
+        
+        SendSQL("SELECT DISTINCT $refertable.$referfield" . ($keyname ? ", $refertable.$keyname" : '') . " " .
+                "FROM   $refertable LEFT JOIN $table " .
+                "  ON   $refertable.$referfield = $table.$field " .
+                "WHERE  $table.$field IS NULL " .
+                "  AND  $refertable.$referfield IS NOT NULL");
+
+        while (MoreSQLData()) {
+            my ($value, $key) = FetchSQLData();
+            if (!$exceptions{$value}) {
+                my $alert = "Bad value $value found in $refertable.$referfield";
+                if ($keyname) {
+                    if ($keyname eq 'bug_id') {
+                        $alert .= ' (bug ' . BugLink($key) . ')';
+                    }
+                    else {
+                        $alert .= " ($keyname == '$key')";
+                    }
+                }
+                Alert($alert);
+            }
+        }
+    }
+}
+
 CrossCheck("keyworddefs", "id",
            ["keywords", "keywordid"]);
 
@@ -284,9 +280,6 @@ CrossCheck("products", "id",
            ["flaginclusions", "product_id", "type_id"],
            ["flagexclusions", "product_id", "type_id"]);
 
-DateCheck("groups", "last_changed");
-DateCheck("profiles", "refreshed_when");
-
 ###########################################################################
 # Perform double field referential (cross) checks
 ###########################################################################
@@ -566,6 +559,24 @@ BugCheck("bugs, products WHERE " .
          "votestoconfirm <= votes",
          "Bugs that have enough votes to be confirmed but haven't been");
 
+###########################################################################
+# Date checks
+###########################################################################
+
+sub DateCheck {
+    my $table = shift @_;
+    my $field = shift @_;
+    Status("Checking dates in $table.$field");
+    SendSQL("SELECT COUNT( $field ) FROM $table WHERE $field > NOW()");
+    my $c = FetchOneColumn();
+    if ($c) {
+        Alert("Found $c dates in future");
+    }
+}
+    
+DateCheck("groups", "last_changed");
+DateCheck("profiles", "refreshed_when");
+
 ###########################################################################
 # Unsent mail
 ###########################################################################