summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2010-04-08 12:12:42 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2010-04-08 12:12:42 +0200
commit51bdc50c7ff7caab9c57a67d9cc168347e2d1a11 (patch)
tree9d9a0ea35e8bfeacdd71effba5a5c19642130a5e
parentf73a86bf700c8b3e85be84966171cdc8527a204a (diff)
downloadbugzilla-51bdc50c7ff7caab9c57a67d9cc168347e2d1a11.tar.gz
bugzilla-51bdc50c7ff7caab9c57a67d9cc168347e2d1a11.tar.xz
Bug 69621: Remove the keyword cache (which is not updated on keyword rename/delete)
r/a=mkanat
-rw-r--r--Bugzilla/Bug.pm2
-rw-r--r--Bugzilla/DB/Schema.pm4
-rw-r--r--Bugzilla/Install/DB.pm46
-rw-r--r--Bugzilla/Search.pm9
-rwxr-xr-xsanitycheck.cgi93
-rw-r--r--template/en/default/admin/sanitycheck/messages.html.tmpl17
-rw-r--r--template/en/default/global/messages.html.tmpl12
7 files changed, 13 insertions, 170 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 89e47a70f..bfcca1076 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -703,8 +703,6 @@ sub update {
$dbh->do('INSERT INTO keywords (bug_id, keywordid) VALUES (?,?)',
undef, $self->id, $keyword_id);
}
- $dbh->do('UPDATE bugs SET keywords = ? WHERE bug_id = ?', undef,
- $self->keywords, $self->id);
# If any changes were found, record it in the activity log
if (scalar @$removed_kw || scalar @$added_kw) {
my $removed_keywords = Bugzilla::Keyword->new_from_list($removed_kw);
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 082fde7ef..6520766f3 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -273,10 +273,6 @@ use constant ABSTRACT_SCHEMA => {
COLUMN => 'userid'}},
status_whiteboard => {TYPE => 'MEDIUMTEXT', NOTNULL => 1,
DEFAULT => "''"},
- # Note: keywords field is only a cache; the real data
- # comes from the keywords table
- keywords => {TYPE => 'MEDIUMTEXT', NOTNULL => 1,
- DEFAULT => "''"},
lastdiffed => {TYPE => 'DATETIME'},
everconfirmed => {TYPE => 'BOOLEAN', NOTNULL => 1},
reporter_accessible => {TYPE => 'BOOLEAN',
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 1a3ffc69b..81372da71 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -147,7 +147,6 @@ sub update_table_definitions {
_add_bug_vote_cache();
_update_product_name_definition();
- _add_bug_keyword_cache();
$dbh->bz_add_column('profiles', 'disabledtext',
{TYPE => 'MEDIUMTEXT', NOTNULL => 1}, '');
@@ -358,8 +357,6 @@ sub update_table_definitions {
# Add defaults for some fields that should have them but didn't.
$dbh->bz_alter_column('bugs', 'status_whiteboard',
{TYPE => 'MEDIUMTEXT', NOTNULL => 1, DEFAULT => "''"});
- $dbh->bz_alter_column('bugs', 'keywords',
- {TYPE => 'MEDIUMTEXT', NOTNULL => 1, DEFAULT => "''"});
if ($dbh->bz_column_info('bugs', 'votes')) {
$dbh->bz_alter_column('bugs', 'votes',
{TYPE => 'INT3', NOTNULL => 1, DEFAULT => '0'});
@@ -605,6 +602,9 @@ sub update_table_definitions {
# 2009-11-14 dkl@redhat.com - Bug 310450
$dbh->bz_add_column('bugs_activity', 'comment_id', {TYPE => 'INT3'});
+ # 2010-04-07 LpSolit@gmail.com - Bug 69621
+ $dbh->bz_drop_column('bugs', 'keywords');
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
@@ -691,46 +691,6 @@ sub _update_product_name_definition {
}
}
-sub _add_bug_keyword_cache {
- my $dbh = Bugzilla->dbh;
- # 2000-01-16 Added a "keywords" field to the bugs table, which
- # contains a string copy of the entries of the keywords table for this
- # bug. This is so that I can easily sort and display a keywords
- # column in bug lists.
-
- if (!$dbh->bz_column_info('bugs', 'keywords')) {
- $dbh->bz_add_column('bugs', 'keywords',
- {TYPE => 'MEDIUMTEXT', NOTNULL => 1, DEFAULT => "''"});
-
- my @kwords;
- print "Making sure 'keywords' field of table 'bugs' is empty...\n";
- $dbh->do("UPDATE bugs SET keywords = '' WHERE keywords != ''");
- print "Repopulating 'keywords' field of table 'bugs'...\n";
- my $sth = $dbh->prepare("SELECT keywords.bug_id, keyworddefs.name " .
- "FROM keywords, keyworddefs " .
- "WHERE keyworddefs.id = keywords.keywordid " .
- "ORDER BY keywords.bug_id, keyworddefs.name");
- $sth->execute;
- my @list;
- my $bugid = 0;
- my @row;
- while (1) {
- my ($b, $k) = ($sth->fetchrow_array());
- if (!defined $b || $b ne $bugid) {
- if (@list) {
- $dbh->do("UPDATE bugs SET keywords = " .
- $dbh->quote(join(', ', @list)) .
- " WHERE bug_id = $bugid");
- }
- last if !$b;
- $bugid = $b;
- @list = ();
- }
- push(@list, $k);
- }
- }
-}
-
# A helper for the function below.
sub _write_one_longdesc {
my ($id, $who, $when, $buffer) = (@_);
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index a0d9718ec..6a9d05144 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -126,6 +126,8 @@ sub COLUMNS {
'flagtypes.name' => $dbh->sql_group_concat('DISTINCT '
. $dbh->sql_string_concat('flagtypes.name', 'flags.status'), "', '"),
+
+ 'keywords' => $dbh->sql_group_concat('DISTINCT keyworddefs.name', "', '"),
);
# Backward-compatibility for old field names. Goes new_name => old_name.
@@ -295,6 +297,11 @@ sub init {
push(@supptables, "LEFT JOIN flagtypes ON flagtypes.id = flags.type_id");
}
+ if (grep($_ eq 'keywords', @fields)) {
+ push(@supptables, "LEFT JOIN keywords ON keywords.bug_id = bugs.bug_id");
+ push(@supptables, "LEFT JOIN keyworddefs ON keyworddefs.id = keywords.keywordid");
+ }
+
# If the user has selected all of either status or resolution, change to
# selecting none. This is functionally equivalent, but quite a lot faster.
# Also, if the status is __open__ or __closed__, translate those
@@ -960,7 +967,7 @@ sub init {
# These fields never go into the GROUP BY (bug_id goes in
# explicitly, below).
next if (grep($_ eq $field, EMPTY_COLUMN,
- qw(bug_id actual_time percentage_complete flagtypes.name)));
+ qw(bug_id actual_time percentage_complete flagtypes.name keywords)));
my $col = COLUMNS->{$field}->{name};
push(@groupby, $col) if !grep($_ eq $col, @groupby);
}
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"});
@@ -99,18 +98,6 @@ unless (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) {
}
###########################################################################
-# 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();
- }
}
###########################################################################
diff --git a/template/en/default/admin/sanitycheck/messages.html.tmpl b/template/en/default/admin/sanitycheck/messages.html.tmpl
index 39e2258d0..5c2b2feb1 100644
--- a/template/en/default/admin/sanitycheck/messages.html.tmpl
+++ b/template/en/default/admin/sanitycheck/messages.html.tmpl
@@ -222,23 +222,6 @@
[% ELSIF san_tag == "keyword_check_duplicated_ids" %]
Duplicate keyword IDs found in [% PROCESS bug_link bug_id = id %].
- [% ELSIF san_tag == "keyword_cache_start" %]
- Checking cached keywords.
-
- [% ELSIF san_tag == "keyword_cache_alert" %]
- [% badbugs.size FILTER none %] [%+ terms.bugs %] found with
- incorrect keyword cache: [% INCLUDE bug_list badbugs = badbugs %]
-
- [% ELSIF san_tag == "keyword_cache_fixing" %]
- OK, now fixing keyword cache.
-
- [% ELSIF san_tag == "keyword_cache_fixed" %]
- Keyword cache fixed.
-
- [% ELSIF san_tag == "keyword_cache_rebuild" %]
- <a href="sanitycheck.cgi?rebuildkeywordcache=1">Click here to
- rebuild the keyword cache</a>.
-
[% ELSIF san_tag == "profile_login_start" %]
Checking profile logins.
diff --git a/template/en/default/global/messages.html.tmpl b/template/en/default/global/messages.html.tmpl
index 7a362374f..b45724b73 100644
--- a/template/en/default/global/messages.html.tmpl
+++ b/template/en/default/global/messages.html.tmpl
@@ -459,10 +459,6 @@
[% ELSIF message_tag == "keyword_deleted" %]
[% title = "Keyword Deleted" %]
The <em>[% keyword.name FILTER html %]</em> keyword has been deleted.
- <b>After you have finished editing keywords, you need to
- <a href="sanitycheck.cgi?rebuildkeywordcache=1">rebuild the keyword
- cache</a></b> (on a very large installation of [% terms.Bugzilla %],
- this can take several minutes).
[% ELSIF message_tag == "keyword_updated" %]
[% title = "Keyword Updated" %]
@@ -471,13 +467,7 @@
been saved:
<ul>
[% IF changes.name.defined %]
- <li>
- Keyword renamed to <em>[% keyword.name FILTER html %]</em>.
- <b>After you have finished editing keywords, you need to
- <a href="sanitycheck.cgi?rebuildkeywordcache=1">rebuild
- the keyword cache</a></b> (on a very large installation
- of [% terms.Bugzilla %], this can take several minutes).
- </li>
+ <li>Keyword renamed to <em>[% keyword.name FILTER html %]</em>.</li>
[% END %]
[% IF changes.description.defined %]
<li>Description updated to <em>[% keyword.description FILTER html %]</em></li>