diff options
author | terry%mozilla.org <> | 2000-01-17 19:38:39 +0000 |
---|---|---|
committer | terry%mozilla.org <> | 2000-01-17 19:38:39 +0000 |
commit | 9178b8f1a5722ad7957b33ffb6f8b9ef40c8f394 (patch) | |
tree | a9b5cc11646f098d682e28ab25e1a8e6b8a7acc4 /sanitycheck.cgi | |
parent | 55a22efb11b4ae0df4d279a14f8b44785e4832fe (diff) | |
download | bugs-9178b8f1a5722ad7957b33ffb6f8b9ef40c8f394.tar bugs-9178b8f1a5722ad7957b33ffb6f8b9ef40c8f394.tar.gz bugs-9178b8f1a5722ad7957b33ffb6f8b9ef40c8f394.tar.bz2 bugs-9178b8f1a5722ad7957b33ffb6f8b9ef40c8f394.tar.xz bugs-9178b8f1a5722ad7957b33ffb6f8b9ef40c8f394.zip |
Added a "keywords" field to a bug, which is a cached string-based copy
of all the keywords assigned to the bug. Right now, we only have code
that generates and maintains this field; soon will come code that
actually uses it.
Diffstat (limited to 'sanitycheck.cgi')
-rwxr-xr-x | sanitycheck.cgi | 110 |
1 files changed, 107 insertions, 3 deletions
diff --git a/sanitycheck.cgi b/sanitycheck.cgi index bfacbf9d2..fe1708986 100755 --- a/sanitycheck.cgi +++ b/sanitycheck.cgi @@ -134,7 +134,7 @@ foreach my $ref (@checklist) { } -Status("Checking profile ids..."); +Status("Checking profile ids"); SendSQL("select userid,login_name from profiles"); @@ -154,13 +154,15 @@ undef $profid{0}; Status("Checking reporter/assigned_to/qa_contact ids"); -SendSQL("select bug_id,reporter,assigned_to,qa_contact,votes from bugs"); +SendSQL("SELECT bug_id,reporter,assigned_to,qa_contact,votes,keywords " . + "FROM bugs"); my %votes; my %bugid; +my %keyword; while (@row = FetchSQLData()) { - my($id, $reporter, $assigned_to, $qa_contact, $v) = (@row); + my($id, $reporter, $assigned_to, $qa_contact, $v, $k) = (@row); $bugid{$id} = 1; if (!defined $profid{$reporter}) { Alert("Bad reporter $reporter in " . BugLink($id)); @@ -174,6 +176,9 @@ while (@row = FetchSQLData()) { if ($v != 0) { $votes{$id} = $v; } + if ($k) { + $keyword{$id} = $k; + } } Status("Checking cached vote counts"); @@ -199,6 +204,105 @@ if ($offervotecacherebuild) { } +Status("Checking keywords table"); + +my %keywordids; +SendSQL("SELECT id, name FROM keyworddefs"); +while (@row = FetchSQLData()) { + my ($id, $name) = (@row); + if ($keywordids{$id}) { + Alert("Duplicate entry in keyworddefs for id $id"); + } + $keywordids{$id} = 1; + if ($name =~ /,/ || $name =~ /^\s/ || $name =~ /\s$/) { + Alert("Bogus name in keyworddefs for id $id"); + } +} + + +SendSQL("SELECT bug_id, keywordid FROM keywords ORDER BY bug_id, keywordid"); +my $lastid; +my $lastk; +while (@row = FetchSQLData()) { + my ($id, $k) = (@row); + if (!defined $bugid{$id}) { + Alert("Bad bugid " . BugLink($id)); + } + if (!$keywordids{$k}) { + Alert("Bogus keywordids $k found in keywords table"); + } + if (defined $lastid && $id eq $lastid && $k eq $lastk) { + Alert("Duplicate keyword ids found in bug " . BugLink($id)); + } + $lastid = $id; + $lastk = $k; +} + +Status("Checking cached keywords"); + +my %realk; + +if (exists $::FORM{'rebuildkeywordcache'}) { + SendSQL("LOCK TABLES bugs write, keywords read, keyworddefs read"); +} + +SendSQL("SELECT keywords.bug_id, keyworddefs.name " . + "FROM keywords, keyworddefs " . + "WHERE keyworddefs.id = keywords.keywordid " . + "ORDER BY keywords.bug_id, keyworddefs.name"); + +my $lastb; +my @list; +while (1) { + my ($b, $k) = (FetchSQLData()); + if (!defined $b || $b ne $lastb) { + if (@list) { + $realk{$lastb} = join(', ', @list); + } + if (!$b) { + last; + } + $lastb = $b; + @list = (); + } + push(@list, $k); +} + +my @fixlist; +foreach my $b (keys(%keyword)) { + if (!exists $realk{$b} || $realk{$b} ne $keyword{$b}) { + push(@fixlist, $b); + } +} +foreach my $b (keys(%realk)) { + if (!exists $keyword{$b}) { + push(@fixlist, $b); + } +} +if (@fixlist) { + @fixlist = sort {$a <=> $b} @fixlist; + Alert("Bug(s) found with incorrect keyword cache: " . + join(', ', @fixlist)); + if (exists $::FORM{'rebuildkeywordcache'}) { + Status("OK, now fixing keyword cache."); + foreach my $b (@fixlist) { + my $k = ''; + if (exists($realk{$b})) { + $k = $realk{$b}; + } + SendSQL("UPDATE bugs SET delta_ts = delta_ts, keywords = " . + SqlQuote($k) . + " WHERE bug_id = $b"); + } + SendSQL("UNLOCK TABLES"); + Status("Keyword cache fixed."); + } else { + print qq{<a href="sanitycheck.cgi?rebuildkeywordcache=1">Click here to rebuild the keyword cache</a><p>\n}; + } +} + + + Status("Checking CC table"); SendSQL("select bug_id,who from cc"); |