diff --git a/mozilla/webtools/bugzilla/Bugzilla/Keyword.pm b/mozilla/webtools/bugzilla/Bugzilla/Keyword.pm index 2152b338d0b..f4742bebd93 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Keyword.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Keyword.pm @@ -74,12 +74,6 @@ sub set_description { $_[0]->set('description', $_[1]); } #### Subroutines ###### ############################### -sub keyword_count { - my ($count) = - Bugzilla->dbh->selectrow_array('SELECT COUNT(*) FROM keyworddefs'); - return $count; -} - sub get_all_with_bug_count { my $class = shift; my $dbh = Bugzilla->dbh; @@ -145,8 +139,6 @@ Bugzilla::Keyword - A Keyword that can be added to a bug. use Bugzilla::Keyword; - my $count = Bugzilla::Keyword::keyword_count; - my $description = $keyword->description; my $keywords = Bugzilla::Keyword->get_all_with_bug_count(); @@ -166,14 +158,6 @@ implements. =over -=item C - - Description: A utility function to get the total number - of keywords defined. Mostly used to see - if there are any keywords defined at all. - Params: none - Returns: An integer, the count of keywords. - =item C Description: Returns all defined keywords. This is an efficient way diff --git a/mozilla/webtools/bugzilla/Bugzilla/Object.pm b/mozilla/webtools/bugzilla/Bugzilla/Object.pm index 7b20cb36cb8..cfa2bfeb6b7 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Object.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Object.pm @@ -337,6 +337,15 @@ sub remove_from_db { #### Subroutines ###### ############################### +sub any_exist { + my $class = shift; + my $table = $class->DB_TABLE; + my $dbh = Bugzilla->dbh; + my $any_exist = $dbh->selectrow_array( + "SELECT 1 FROM $table " . $dbh->sql_limit(1)); + return $any_exist ? 1 : 0; +} + sub create { my ($class, $params) = @_; my $dbh = Bugzilla->dbh; @@ -882,6 +891,11 @@ Returns C<1> if the passed-in value is true, C<0> otherwise. =over +=item C + +Returns C<1> if there are any of these objects in the database, +C<0> otherwise. + =item C Description: Returns all objects in this table from the database. diff --git a/mozilla/webtools/bugzilla/Bugzilla/Template.pm b/mozilla/webtools/bugzilla/Bugzilla/Template.pm index 49954a52156..22ea4b7ccb6 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Template.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Template.pm @@ -37,7 +37,9 @@ use strict; use Bugzilla::Bug; use Bugzilla::Constants; use Bugzilla::Install::Requirements; -use Bugzilla::Install::Util qw(install_string template_include_path include_languages); +use Bugzilla::Install::Util qw(install_string template_include_path + include_languages); +use Bugzilla::Keyword; use Bugzilla::Util; use Bugzilla::User; use Bugzilla::Error; @@ -752,6 +754,10 @@ sub create { return $cache->{template_bug_fields}; }, + # Whether or not keywords are enabled, in this Bugzilla. + 'use_keywords' => sub { return Bugzilla::Keyword->any_exist; }, + + # These don't work as normal constants. DB_MODULE => \&Bugzilla::Constants::DB_MODULE, REQUIRED_MODULES => diff --git a/mozilla/webtools/bugzilla/attachment.cgi b/mozilla/webtools/bugzilla/attachment.cgi index 8614026db59..bbbf4afb3b3 100755 --- a/mozilla/webtools/bugzilla/attachment.cgi +++ b/mozilla/webtools/bugzilla/attachment.cgi @@ -523,7 +523,6 @@ sub insert { $vars->{'bugs'} = [new Bugzilla::Bug($bugid)]; $vars->{'header_done'} = 1; $vars->{'contenttypemethod'} = $cgi->param('contenttypemethod'); - $vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); print $cgi->header(); # Generate and return the UI (HTML page) from the appropriate template. @@ -644,7 +643,6 @@ sub update { $vars->{'attachment'} = $attachment; $vars->{'bugs'} = [$bug]; $vars->{'header_done'} = 1; - $vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); print $cgi->header(); @@ -716,7 +714,6 @@ sub delete_attachment { # Required to display the bug the deleted attachment belongs to. $vars->{'bugs'} = [$bug]; $vars->{'header_done'} = 1; - $vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); $template->process("attachment/updated.html.tmpl", $vars) || ThrowTemplateError($template->error()); diff --git a/mozilla/webtools/bugzilla/buglist.cgi b/mozilla/webtools/bugzilla/buglist.cgi index b96f59d6e16..47e1f4ba5b9 100755 --- a/mozilla/webtools/bugzilla/buglist.cgi +++ b/mozilla/webtools/bugzilla/buglist.cgi @@ -1139,7 +1139,6 @@ if ($dotweak && scalar @bugs) { object => 'multiple_bugs'}); } $vars->{'dotweak'} = 1; - $vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); # issue_session_token needs to write to the master DB. Bugzilla->switch_to_main_db(); diff --git a/mozilla/webtools/bugzilla/colchange.cgi b/mozilla/webtools/bugzilla/colchange.cgi index a521ee1681a..5aef57ff8a1 100755 --- a/mozilla/webtools/bugzilla/colchange.cgi +++ b/mozilla/webtools/bugzilla/colchange.cgi @@ -71,7 +71,7 @@ if (Bugzilla->params->{"useqacontact"}) { if (Bugzilla->params->{"usestatuswhiteboard"}) { push(@masterlist, "status_whiteboard"); } -if (Bugzilla::Keyword::keyword_count()) { +if (Bugzilla::Keyword->any_exist) { push(@masterlist, "keywords"); } diff --git a/mozilla/webtools/bugzilla/enter_bug.cgi b/mozilla/webtools/bugzilla/enter_bug.cgi index 408336121df..071276f1db1 100755 --- a/mozilla/webtools/bugzilla/enter_bug.cgi +++ b/mozilla/webtools/bugzilla/enter_bug.cgi @@ -380,8 +380,6 @@ $vars->{'bug_severity'} = get_legal_field_values('bug_severity'); $vars->{'rep_platform'} = get_legal_field_values('rep_platform'); $vars->{'op_sys'} = get_legal_field_values('op_sys'); -$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); - $vars->{'assigned_to'} = formvalue('assigned_to'); $vars->{'assigned_to_disabled'} = !$has_editbugs; $vars->{'cc_disabled'} = 0; diff --git a/mozilla/webtools/bugzilla/post_bug.cgi b/mozilla/webtools/bugzilla/post_bug.cgi index 997b621ad37..c6e4006e04e 100755 --- a/mozilla/webtools/bugzilla/post_bug.cgi +++ b/mozilla/webtools/bugzilla/post_bug.cgi @@ -279,7 +279,6 @@ if ($cgi->cookie("BUGLIST")) { @bug_list = split(/:/, $cgi->cookie("BUGLIST")); } $vars->{'bug_list'} = \@bug_list; -$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); if ($token) { trick_taint($token); diff --git a/mozilla/webtools/bugzilla/process_bug.cgi b/mozilla/webtools/bugzilla/process_bug.cgi index f10467d4e6a..85e6c60fc6f 100755 --- a/mozilla/webtools/bugzilla/process_bug.cgi +++ b/mozilla/webtools/bugzilla/process_bug.cgi @@ -69,7 +69,6 @@ my $cgi = Bugzilla->cgi; my $dbh = Bugzilla->dbh; my $template = Bugzilla->template; my $vars = {}; -$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); ###################################################################### # Subroutines diff --git a/mozilla/webtools/bugzilla/query.cgi b/mozilla/webtools/bugzilla/query.cgi index 57741068166..ab07fbf0fa3 100755 --- a/mozilla/webtools/bugzilla/query.cgi +++ b/mozilla/webtools/bugzilla/query.cgi @@ -230,8 +230,6 @@ if (Bugzilla->params->{'usetargetmilestone'}) { $vars->{'target_milestone'} = \@milestones; } -$vars->{'have_keywords'} = Bugzilla::Keyword::keyword_count(); - my @chfields; push @chfields, "[Bug creation]"; diff --git a/mozilla/webtools/bugzilla/show_bug.cgi b/mozilla/webtools/bugzilla/show_bug.cgi index 42fad712197..c0e54323488 100755 --- a/mozilla/webtools/bugzilla/show_bug.cgi +++ b/mozilla/webtools/bugzilla/show_bug.cgi @@ -99,7 +99,6 @@ eval { $vars->{'bugs'} = \@bugs; $vars->{'marks'} = \%marks; -$vars->{'use_keywords'} = 1 if Bugzilla::Keyword::keyword_count(); my @bugids = map {$_->bug_id} grep {!$_->error} @bugs; $vars->{'bugids'} = join(", ", @bugids); diff --git a/mozilla/webtools/bugzilla/template/en/default/search/form.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/search/form.html.tmpl index 078ff8c6b35..5df8bc0a949 100644 --- a/mozilla/webtools/bugzilla/template/en/default/search/form.html.tmpl +++ b/mozilla/webtools/bugzilla/template/en/default/search/form.html.tmpl @@ -285,7 +285,7 @@ function doOnSelectProduct(selectmode) { [% END %] [% END %] - [% IF have_keywords %] + [% IF use_keywords %] :