From 51bdc50c7ff7caab9c57a67d9cc168347e2d1a11 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Thu, 8 Apr 2010 12:12:42 +0200 Subject: Bug 69621: Remove the keyword cache (which is not updated on keyword rename/delete) r/a=mkanat --- sanitycheck.cgi | 93 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 92 deletions(-) (limited to 'sanitycheck.cgi') diff --git a/sanitycheck.cgi b/sanitycheck.cgi index 4b6e524c2..c298d1250 100755 --- a/sanitycheck.cgi +++ b/sanitycheck.cgi @@ -88,7 +88,6 @@ print $cgi->header() unless Bugzilla->usage_mode == USAGE_MODE_CMDLINE; # As this script can now alter the group_control_map table, we no longer # let users with editbugs privs run it anymore. $user->in_group("editcomponents") - || ($user->in_group('editkeywords') && $cgi->param('rebuildkeywordcache')) || ThrowUserError("auth_failure", {group => "editcomponents", action => "run", object => "sanity_check"}); @@ -98,18 +97,6 @@ unless (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) { || ThrowTemplateError($template->error()); } -########################################################################### -# Users with 'editkeywords' privs only can only check keywords. -########################################################################### -unless ($user->in_group('editcomponents')) { - check_keywords(); - Status('checks_completed'); - - $template->process('global/footer.html.tmpl', $vars) - || ThrowTemplateError($template->error()); - exit; -} - ########################################################################### # Create missing group_control_map entries ########################################################################### @@ -658,18 +645,13 @@ while (my ($id, $email) = $sth->fetchrow_array) { } ########################################################################### -# Perform keyword cache checks +# Perform keyword checks ########################################################################### sub check_keywords { my $dbh = Bugzilla->dbh; my $cgi = Bugzilla->cgi; - my %keyword = @{ $dbh->selectcol_arrayref( - q{SELECT bug_id, keywords FROM bugs WHERE keywords != ''}, - {Columns=>[1,2]}) }; - - Status('keyword_check_start'); my %keywordids; @@ -703,79 +685,6 @@ sub check_keywords { $lastid = $id; $lastk = $k; } - - Status('keyword_cache_start'); - - if ($cgi->param('rebuildkeywordcache')) { - $dbh->bz_start_transaction(); - } - - my $query = q{SELECT keywords.bug_id, keyworddefs.name - FROM keywords - INNER JOIN keyworddefs - ON keyworddefs.id = keywords.keywordid - INNER JOIN bugs - ON keywords.bug_id = bugs.bug_id - ORDER BY keywords.bug_id, keyworddefs.name}; - - $sth = $dbh->prepare($query); - $sth->execute; - - my $lastb = 0; - my @list; - my %realk; - while (1) { - my ($b, $k) = $sth->fetchrow_array; - if (!defined $b || $b != $lastb) { - if (@list) { - $realk{$lastb} = join(', ', @list); - } - last unless $b; - - $lastb = $b; - @list = (); - } - push(@list, $k); - } - - my @badbugs = (); - - foreach my $b (keys(%keyword)) { - if (!exists $realk{$b} || $realk{$b} ne $keyword{$b}) { - push(@badbugs, $b); - } - } - foreach my $b (keys(%realk)) { - if (!exists $keyword{$b}) { - push(@badbugs, $b); - } - } - if (@badbugs) { - @badbugs = sort {$a <=> $b} @badbugs; - - if ($cgi->param('rebuildkeywordcache')) { - my $sth_update = $dbh->prepare(q{UPDATE bugs - SET keywords = ? - WHERE bug_id = ?}); - - Status('keyword_cache_fixing'); - foreach my $b (@badbugs) { - my $k = ''; - if (exists($realk{$b})) { - $k = $realk{$b}; - } - $sth_update->execute($k, $b); - } - Status('keyword_cache_fixed'); - } else { - Status('keyword_cache_alert', {badbugs => \@badbugs}, 'alert'); - Status('keyword_cache_rebuild'); - } - } - - if ($cgi->param('rebuildkeywordcache')) { - $dbh->bz_commit_transaction(); - } } ########################################################################### -- cgit v1.2.3-24-g4f1b