aboutsummaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Attachment.pm8
-rw-r--r--Bugzilla/Auth/Verify/LDAP.pm3
-rw-r--r--Bugzilla/Bug.pm14
-rw-r--r--Bugzilla/DB/Schema.pm3
-rw-r--r--Bugzilla/Install/DB.pm4
-rw-r--r--Bugzilla/Keyword.pm28
-rw-r--r--Bugzilla/Template.pm7
-rw-r--r--Bugzilla/User.pm8
-rw-r--r--Bugzilla/WebService/Bug.pm1
9 files changed, 63 insertions, 13 deletions
diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm
index 33183797b..14c81193d 100644
--- a/Bugzilla/Attachment.pm
+++ b/Bugzilla/Attachment.pm
@@ -501,9 +501,8 @@ sub _check_content_type {
# If we have autodetected application/octet-stream from the Content-Type
# header, let's have a better go using a sniffer if available.
- if (defined Bugzilla->input_params->{contenttypemethod}
- && Bugzilla->input_params->{contenttypemethod} eq 'autodetect'
- && $content_type eq 'application/octet-stream'
+ if ((Bugzilla->input_params->{contenttypemethod} // '') eq 'autodetect'
+ && ($content_type eq 'application/octet-stream' || $content_type =~ m{text/x-})
&& Bugzilla->feature('typesniffer'))
{
import File::MimeInfo::Magic qw(mimetype);
@@ -534,8 +533,7 @@ sub _check_content_type {
# Make sure patches are viewable in the browser
if (!ref($invocant)
- && defined Bugzilla->input_params->{contenttypemethod}
- && Bugzilla->input_params->{contenttypemethod} eq 'autodetect'
+ && (Bugzilla->input_params->{contenttypemethod} // '') eq 'autodetect'
&& $content_type =~ m{text/x-(?:diff|patch)})
{
$params->{ispatch} = 1;
diff --git a/Bugzilla/Auth/Verify/LDAP.pm b/Bugzilla/Auth/Verify/LDAP.pm
index e37f55793..9687363d6 100644
--- a/Bugzilla/Auth/Verify/LDAP.pm
+++ b/Bugzilla/Auth/Verify/LDAP.pm
@@ -163,7 +163,8 @@ sub ldap {
ThrowCodeError("ldap_server_not_defined") unless @servers;
foreach (@servers) {
- $self->{ldap} = new Net::LDAP(trim($_));
+ # The 'raw' attribute is used to make sure that data is correctly decoded.
+ $self->{ldap} = new Net::LDAP(trim($_), raw => ';binary');
last if $self->{ldap};
}
ThrowCodeError("ldap_connect_failed", { server => join(", ", @servers) })
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 8b4493f85..00231c1c5 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1848,6 +1848,20 @@ sub _check_keywords {
my $obj = Bugzilla::Keyword->check($keyword);
$keywords{$obj->id} = $obj;
}
+
+ my %old_kw_id;
+ if (blessed $invocant) {
+ my @old_keywords = @{$invocant->keyword_objects};
+ %old_kw_id = map { $_->id => 1 } @old_keywords;
+ }
+
+ foreach my $keyword (values %keywords) {
+ next if $keyword->is_active || exists $old_kw_id{$keyword->id};
+
+ ThrowUserError('value_inactive',
+ { value => $keyword->name, class => ref $keyword });
+ }
+
return [values %keywords];
}
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index d1c1dc7e9..d2742bc73 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -587,6 +587,8 @@ use constant ABSTRACT_SCHEMA => {
PRIMARYKEY => 1},
name => {TYPE => 'varchar(64)', NOTNULL => 1},
description => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ is_active => {TYPE => 'BOOLEAN', NOTNULL => 1,
+ DEFAULT => 'TRUE'},
],
INDEXES => [
keyworddefs_name_idx => {FIELDS => ['name'],
@@ -604,7 +606,6 @@ use constant ABSTRACT_SCHEMA => {
REFERENCES => {TABLE => 'keyworddefs',
COLUMN => 'id',
DELETE => 'CASCADE'}},
-
],
INDEXES => [
keywords_bug_id_idx => {FIELDS => [qw(bug_id keywordid)],
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index ed2539251..f7fd8b2ab 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -732,6 +732,10 @@ sub update_table_definitions {
# 2015-12-16 LpSolit@gmail.com - Bug 1232578
_sanitize_audit_log_table();
+ # 2014-11-18 dylan@mozilla.com - Bug 69267
+ $dbh->bz_add_column('keyworddefs', 'is_active',
+ {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'});
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
diff --git a/Bugzilla/Keyword.pm b/Bugzilla/Keyword.pm
index afa93e1e9..ef044a0c5 100644
--- a/Bugzilla/Keyword.pm
+++ b/Bugzilla/Keyword.pm
@@ -26,6 +26,7 @@ use constant DB_COLUMNS => qw(
keyworddefs.id
keyworddefs.name
keyworddefs.description
+ keyworddefs.is_active
);
use constant DB_TABLE => 'keyworddefs';
@@ -33,11 +34,13 @@ use constant DB_TABLE => 'keyworddefs';
use constant VALIDATORS => {
name => \&_check_name,
description => \&_check_description,
+ is_active => \&_check_is_active,
};
use constant UPDATE_COLUMNS => qw(
name
description
+ is_active
);
###############################
@@ -62,6 +65,7 @@ sub bug_count {
sub set_name { $_[0]->set('name', $_[1]); }
sub set_description { $_[0]->set('description', $_[1]); }
+sub set_is_active { $_[0]->set('is_active', $_[1]); }
###############################
#### Subroutines ######
@@ -125,6 +129,10 @@ sub _check_description {
return $desc;
}
+sub _check_is_active { return $_[1] ? 1 : 0 }
+
+sub is_active { return $_[0]->{is_active} }
+
1;
__END__
@@ -145,13 +153,13 @@ Bugzilla::Keyword - A Keyword that can be added to a bug.
Bugzilla::Keyword represents a keyword that can be added to a bug.
-This implements all standard C<Bugzilla::Object> methods. See
+This implements all standard C<Bugzilla::Object> methods. See
L<Bugzilla::Object> for more details.
-=head1 SUBROUTINES
+=head1 METHODS
-This is only a list of subroutines specific to C<Bugzilla::Keyword>.
-See L<Bugzilla::Object> for more subroutines that this object
+This is only a list of methods specific to C<Bugzilla::Keyword>.
+See L<Bugzilla::Object> for more methods that this object
implements.
=over
@@ -166,6 +174,18 @@ implements.
Returns: A reference to an array of Keyword objects, or an empty
arrayref if there are no keywords.
+=item C<is_active>
+
+ Description: Indicates if the keyword may be used on a bug
+ Params: none
+ Returns: a boolean value that is true if the keyword can be applied to bugs.
+
+=item C<set_is_active($is_active)>
+
+ Description: Set the is_active property to a boolean value
+ Params: the new value of the is_active property.
+ Returns: nothing
+
=back
=cut
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 41b9265c6..95882b65f 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -1122,11 +1122,16 @@ sub create {
# Whether or not keywords are enabled, in this Bugzilla.
'use_keywords' => sub { return Bugzilla::Keyword->any_exist; },
- # All the keywords.
+ # All the keywords
'all_keywords' => sub {
return [map { $_->name } Bugzilla::Keyword->get_all()];
},
+ # All the active keywords
+ 'active_keywords' => sub {
+ return [map { $_->name } grep { $_->is_active } Bugzilla::Keyword->get_all()];
+ },
+
'feature_enabled' => sub { return Bugzilla->feature(@_); },
# field_descs can be somewhat slow to generate, so we generate
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index 77e6cebb0..1768d7c48 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -2132,10 +2132,16 @@ sub wants_mail {
$relationship = REL_ANY;
}
+ my $wants_mail;
+ Bugzilla::Hook::process('user_wants_mail', { events => $events,
+ relationship => $relationship,
+ wants_mail => \$wants_mail });
+ return $wants_mail if defined $wants_mail;
+
# Skip DB query if relationship is explicit
return 1 if $relationship == REL_GLOBAL_WATCHER;
- my $wants_mail = grep { $self->mail_settings->{$relationship}{$_} } @$events;
+ $wants_mail = grep { $self->mail_settings->{$relationship}{$_} } @$events;
return $wants_mail ? 1 : 0;
}
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index b07d3cb01..34e6b6662 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -245,6 +245,7 @@ sub _legal_field_values {
elsif ($field_name eq 'keywords') {
my @legal_keywords = Bugzilla::Keyword->get_all;
foreach my $value (@legal_keywords) {
+ next unless $value->is_active;
push (@result, {
name => $self->type('string', $value->name),
description => $self->type('string', $value->description),