summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Keyword.pm16
-rw-r--r--Bugzilla/Object.pm26
-rw-r--r--Bugzilla/Template.pm8
3 files changed, 28 insertions, 22 deletions
diff --git a/Bugzilla/Keyword.pm b/Bugzilla/Keyword.pm
index 2152b338d..f4742bebd 100644
--- a/Bugzilla/Keyword.pm
+++ b/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<keyword_count()>
-
- 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<get_all_with_bug_count()>
Description: Returns all defined keywords. This is an efficient way
diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm
index d2e5a8dda..cfa2bfeb6 100644
--- a/Bugzilla/Object.pm
+++ b/Bugzilla/Object.pm
@@ -170,14 +170,16 @@ sub match {
elsif ( $field eq 'WHERE' ) {
# the WHERE value is a hashref where the keys are
# "column_name operator ?" and values are the placeholder's
- # value.
- foreach my $k (keys( %$value )) {
- push( @terms, $k );
- push( @values, $value->{$k} );
+ # value (either a scalar or an array of values).
+ foreach my $k (keys %$value) {
+ push(@terms, $k);
+ my @this_value = ref($value->{$k}) ? @{ $value->{$k} }
+ : ($value->{$k});
+ push(@values, @this_value);
}
next;
}
-
+
if (ref $value eq 'ARRAY') {
# IN () is invalid SQL, and if we have an empty list
# to match against, we're just returning an empty
@@ -335,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;
@@ -880,6 +891,11 @@ Returns C<1> if the passed-in value is true, C<0> otherwise.
=over
+=item C<any_exist>
+
+Returns C<1> if there are any of these objects in the database,
+C<0> otherwise.
+
=item C<get_all>
Description: Returns all objects in this table from the database.
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 49954a521..22ea4b7cc 100644
--- a/Bugzilla/Template.pm
+++ b/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 =>