summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDavid Lawrence <dlawrence@mozilla.com>2011-09-30 23:50:01 +0200
committerDavid Lawrence <dlawrence@mozilla.com>2011-09-30 23:50:01 +0200
commit77f1cffd26e4e306b46558142a432acdbb67b9f1 (patch)
treee79f3e29d233c0afbc8c7928b408b8a6119847dc /Bugzilla
parentf6e81df17967ab414235bcc12d3432df69192f1a (diff)
parentf517974618ba835014e9d2a3565109af469f5d34 (diff)
downloadbugzilla-77f1cffd26e4e306b46558142a432acdbb67b9f1.tar.gz
bugzilla-77f1cffd26e4e306b46558142a432acdbb67b9f1.tar.xz
merged with bugzilla/4.2
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Bug.pm9
-rw-r--r--Bugzilla/BugUrl/Bugzilla/Local.pm15
-rw-r--r--Bugzilla/FlagType.pm22
-rw-r--r--Bugzilla/Object.pm2
-rw-r--r--Bugzilla/Product.pm4
-rw-r--r--Bugzilla/WebService/Bug.pm4
-rw-r--r--Bugzilla/WebService/Product.pm48
7 files changed, 78 insertions, 26 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index 8beecdcd2..175bcd050 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1130,9 +1130,7 @@ sub remove_from_db {
# The bugs_fulltext table doesn't support transactions.
$dbh->do("DELETE FROM bugs_fulltext WHERE bug_id = ?", undef, $bug_id);
- # Now this bug no longer exists
- $self->DESTROY;
- return $self;
+ undef $self;
}
#####################################################################
@@ -2891,7 +2889,8 @@ sub remove_see_also {
# Since we remove also the url from the referenced bug,
# we need to notify changes for that bug too.
$removed_bug_url = $removed_bug_url->[0];
- if ($removed_bug_url->isa('Bugzilla::BugUrl::Bugzilla::Local')
+ if ($removed_bug_url
+ and $removed_bug_url->isa('Bugzilla::BugUrl::Bugzilla::Local')
and defined $removed_bug_url->ref_bug_url)
{
push @{ $self->{see_also_changes} },
@@ -3385,7 +3384,7 @@ sub reporter {
sub see_also {
my ($self) = @_;
return [] if $self->{'error'};
- if (!defined $self->{see_also}) {
+ if (!exists $self->{see_also}) {
my $ids = Bugzilla->dbh->selectcol_arrayref(
'SELECT id FROM bug_see_also WHERE bug_id = ?',
undef, $self->id);
diff --git a/Bugzilla/BugUrl/Bugzilla/Local.pm b/Bugzilla/BugUrl/Bugzilla/Local.pm
index 233acbe66..bdfae2835 100644
--- a/Bugzilla/BugUrl/Bugzilla/Local.pm
+++ b/Bugzilla/BugUrl/Bugzilla/Local.pm
@@ -95,13 +95,20 @@ sub remove_from_db {
sub should_handle {
my ($class, $uri) = @_;
- return $uri->as_string =~ m/^\w+$/ ? 1 : 0;
+ # Check if it is either a bug id number or an alias.
+ return 1 if $uri->as_string =~ m/^\w+$/;
+ # Check if it is a local Bugzilla uri and call
+ # Bugzilla::BugUrl::Bugzilla to check if it's a valid Bugzilla
+ # see also url.
my $canonical_local = URI->new($class->local_uri)->canonical;
+ if ($canonical_local->authority eq $uri->canonical->authority
+ and $canonical_local->path eq $uri->canonical->path)
+ {
+ return $class->SUPER::should_handle($uri);
+ }
- # Treating the domain case-insensitively and ignoring http(s)://
- return ($canonical_local->authority eq $uri->canonical->authority
- and $canonical_local->path eq $uri->canonical->path) ? 1 : 0;
+ return 0;
}
sub _check_value {
diff --git a/Bugzilla/FlagType.pm b/Bugzilla/FlagType.pm
index bd3f7b054..ea81dfe46 100644
--- a/Bugzilla/FlagType.pm
+++ b/Bugzilla/FlagType.pm
@@ -118,6 +118,8 @@ sub create {
$class->check_required_create_fields(@_);
my $params = $class->run_create_validators(@_);
+ # In the DB, only the first character of the target type is stored.
+ $params->{target_type} = substr($params->{target_type}, 0, 1);
# Extract everything which is not a valid column name.
$params->{grant_group_id} = delete $params->{grant_group};
@@ -357,7 +359,15 @@ sub set_request_group { $_[0]->set('request_group_id', $_[1]); }
sub set_clusions {
my ($self, $list) = @_;
+ my $user = Bugzilla->user;
my %products;
+ my $params = {};
+
+ # If the user has editcomponents privs, then we only need to make sure
+ # that the product exists.
+ if ($user->in_group('editcomponents')) {
+ $params->{allow_inaccessible} = 1;
+ }
foreach my $category (keys %$list) {
my %clusions;
@@ -369,8 +379,16 @@ sub set_clusions {
my $comp_name = '__Any__';
# Does the product exist?
if ($prod_id) {
- $products{$prod_id} ||= Bugzilla::Product->check({ id => $prod_id });
- detaint_natural($prod_id);
+ detaint_natural($prod_id)
+ || ThrowCodeError('param_must_be_numeric',
+ { function => 'Bugzilla::FlagType::set_clusions' });
+
+ if (!$products{$prod_id}) {
+ $params->{id} = $prod_id;
+ $products{$prod_id} = Bugzilla::Product->check($params);
+ $user->in_group('editcomponents', $prod_id)
+ || ThrowUserError('product_access_denied', $params);
+ }
$prod_name = $products{$prod_id}->name;
# Does the component belong to this product?
diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm
index 1cad3e829..29a6415b9 100644
--- a/Bugzilla/Object.pm
+++ b/Bugzilla/Object.pm
@@ -441,6 +441,8 @@ sub audit_log {
# During update, it's the actual %changes hash produced by update().
foreach my $field (keys %$changes) {
+ # Skip private changes.
+ next if $field =~ /^_/;
my ($from, $to) = @{ $changes->{$field} };
$sth->execute($user_id, $class, $self->id, $field, $from, $to);
}
diff --git a/Bugzilla/Product.pm b/Bugzilla/Product.pm
index 85524ac47..a0079a033 100644
--- a/Bugzilla/Product.pm
+++ b/Bugzilla/Product.pm
@@ -223,7 +223,7 @@ sub update {
$new_setting->{group}->name,
Bugzilla->user->id, $timestamp);
}
- push(@{$changes->{'group_controls'}->{'now_mandatory'}},
+ push(@{$changes->{'_group_controls'}->{'now_mandatory'}},
{name => $new_setting->{group}->name,
bug_count => scalar @$bug_ids});
}
@@ -248,7 +248,7 @@ sub update {
$old_setting->{group}->name, '',
Bugzilla->user->id, $timestamp);
}
- push(@{$changes->{'group_controls'}->{'now_na'}},
+ push(@{$changes->{'_group_controls'}->{'now_na'}},
{name => $old_setting->{group}->name,
bug_count => scalar @$bug_ids});
}
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index da2393033..fb2b7b65d 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -204,7 +204,7 @@ sub _legal_field_values {
name => $self->type('string', $status->name),
is_open => $self->type('boolean', $status->is_open),
sort_key => $self->type('int', $status->sortkey),
- sortkey => $self->type('int', $status->sortkey), # depricated
+ sortkey => $self->type('int', $status->sortkey), # deprecated
can_change_to => \@can_change_to,
visibility_values => [],
});
@@ -218,7 +218,7 @@ sub _legal_field_values {
push(@result, {
name => $self->type('string', $value->name),
sort_key => $self->type('int' , $value->sortkey),
- sortkey => $self->type('int' , $value->sortkey), # depricated
+ sortkey => $self->type('int' , $value->sortkey), # deprecated
visibility_values => [
defined $vis_val ? $self->type('string', $vis_val->name)
: ()
diff --git a/Bugzilla/WebService/Product.pm b/Bugzilla/WebService/Product.pm
index 9aeb8597a..842657575 100644
--- a/Bugzilla/WebService/Product.pm
+++ b/Bugzilla/WebService/Product.pm
@@ -122,11 +122,13 @@ sub _product_to_hash {
my ($self, $params, $product) = @_;
my $field_data = {
- internals => $product,
id => $self->type('int', $product->id),
name => $self->type('string', $product->name),
description => $self->type('string', $product->description),
is_active => $self->type('boolean', $product->is_active),
+ default_milestone => $self->type('string', $product->default_milestone),
+ has_unconfirmed => $self->type('boolean', $product->allows_unconfirmed),
+ classification => $self->_classification_to_hash($product->classification),
};
if (filter_wants($params, 'components')) {
$field_data->{components} = [map {
@@ -146,6 +148,20 @@ sub _product_to_hash {
return filter($params, $field_data);
}
+sub _classification_to_hash {
+ my ($self, $classification) = @_;
+ return {
+ id =>
+ $self->type('int', $classification->id),
+ name =>
+ $self->type('string', $classification->name),
+ description =>
+ $self->type('string' , $classification->description),
+ sort_key =>
+ $self->type('int', $classification->sortkey),
+ };
+}
+
sub _component_to_hash {
my ($self, $component) = @_;
return {
@@ -318,7 +334,7 @@ hashes. Each hash describes a product, and has the following items:
=item C<id>
-C<int> An integer id uniquely idenfifying the product in this installation only.
+C<int> An integer id uniquely identifying the product in this installation only.
=item C<name>
@@ -333,6 +349,20 @@ C<string> A description of the product, which may contain HTML.
C<boolean> A boolean indicating if the product is active.
+=item C<default_milestone>
+
+C<string> The name of the default milestone for the product.
+
+=item C<has_unconfirmed>
+
+C<boolean> Indicates whether the UNCONFIRMED bug status is available
+for this product.
+
+=item C<classification>
+
+C<hash> Contains the classification C<id>, C<name>, C<description>
+and C<sort_key> as keys.
+
=item C<components>
C<array> An array of hashes, where each hash describes a component, and has the
@@ -342,7 +372,7 @@ following items:
=item C<id>
-C<int> An integer id uniquely idenfifying the component in this installation
+C<int> An integer id uniquely identifying the component in this installation
only.
=item C<name>
@@ -386,12 +416,6 @@ following items: C<name>, C<sort_key> and C<is_active>.
C<array> An array of hashes, where each hash describes a milestone, and has the
following items: C<name>, C<sort_key> and C<is_active>.
-=item C<internals>
-
-B<UNSTABLE>
-
-An internal representation of the product.
-
=back
Note, that if the user tries to access a product that is not in the
@@ -407,8 +431,10 @@ is returned.
=item In Bugzilla B<4.2>, C<names> was added as an input parameter.
-=item In Bugzilla B<4.2> C<components>, C<versions>, and C<milestones>
-were added to the fields returned by C<get>.
+=item In Bugzilla B<4.2>, C<classification>, C<components>, C<versions>,
+C<milestones>, C<default_milestone> and C<has_unconfirmed> were added to
+the fields returned by C<get> as a replacement for C<internals>, which has
+been removed.
=back