diff options
author | Byron Jones <bjones@mozilla.com> | 2013-12-18 06:53:52 +0100 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-12-18 06:53:52 +0100 |
commit | 0947dc7814a092dd39a50b37de2a608b0fe9e1c6 (patch) | |
tree | eb235b06d240f4b61817b1323d0b4388d0f697d0 /extensions/ComponentWatching | |
parent | fd34e8cc669933ef50ab6a866b6adea017205a62 (diff) | |
download | bugzilla-0947dc7814a092dd39a50b37de2a608b0fe9e1c6.tar.gz bugzilla-0947dc7814a092dd39a50b37de2a608b0fe9e1c6.tar.xz |
Bug 950743: Navigating to Component Watching responds with a 500 on retrieving userprefs.cgi
Diffstat (limited to 'extensions/ComponentWatching')
-rw-r--r-- | extensions/ComponentWatching/Extension.pm | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/extensions/ComponentWatching/Extension.pm b/extensions/ComponentWatching/Extension.pm index 45d6127bf..c4951d877 100644 --- a/extensions/ComponentWatching/Extension.pm +++ b/extensions/ComponentWatching/Extension.pm @@ -194,7 +194,7 @@ sub user_preferences { $ra_componentNames = [$ra_componentNames || ''] unless ref($ra_componentNames); # load product and verify access - my $product = Bugzilla::Product->new({ name => $productName }); + my $product = Bugzilla::Product->new({ name => $productName, cache => 1 }); unless ($product && $user->can_access_product($product)) { ThrowUserError('product_access_denied', { product => $productName }); } @@ -206,7 +206,9 @@ sub user_preferences { } else { # watching specific components foreach my $componentName (@$ra_componentNames) { - my $component = Bugzilla::Component->new({ name => $componentName, product => $product }); + my $component = Bugzilla::Component->new({ + name => $componentName, product => $product, cache => 1 + }); unless ($component) { ThrowUserError('product_access_denied', { product => $productName }); } @@ -258,18 +260,20 @@ sub bugmail_recipients { next if !(exists $ra->{'old'} && exists $ra->{'field_name'}); if ($ra->{'field_name'} eq 'product') { - $product = Bugzilla::Product->new({ name => $ra->{'old'} }); + $product = Bugzilla::Product->new({ name => $ra->{'old'}, cache => 1 }); $oldProductId = $product->id; } } if (!$product) { - $product = Bugzilla::Product->new($oldProductId); + $product = Bugzilla::Product->new({ id => $oldProductId, cache => 1 }); } foreach my $ra (@$diffs) { next if !(exists $ra->{'old'} && exists $ra->{'field_name'}); if ($ra->{'field_name'} eq 'component') { - my $component = Bugzilla::Component->new({ name => $ra->{'old'}, product => $product }); + my $component = Bugzilla::Component->new({ + name => $ra->{'old'}, product => $product, cache => 1 + }); $oldComponentId = $component->id; } } @@ -342,22 +346,27 @@ sub _getWatches { $sth->execute($user->id); my @watches; while (my ($productId, $componentId) = $sth->fetchrow_array) { - my $product = Bugzilla::Product->new($productId); + my $product = Bugzilla::Product->new({ id => $productId, cache => 1 }); next unless $product && $user->can_access_product($product); - my %watch = ( product => $product ); + my %watch = ( + product => $product, + product_name => $product->name, + component_name => '', + ); if ($componentId) { - my $component = Bugzilla::Component->new($componentId); + my $component = Bugzilla::Component->new({ id => $componentId, cache => 1 }); next unless $component; $watch{'component'} = $component; + $watch{'component_name'} = $component->name; } push @watches, \%watch; } @watches = sort { - $a->{'product'}->name cmp $b->{'product'}->name - || $a->{'component'}->name cmp $b->{'component'}->name + $a->{'product_name'} cmp $b->{'product_name'} + || $a->{'component_name'} cmp $b->{'component_name'} } @watches; return \@watches; @@ -377,12 +386,12 @@ sub _getUserWatches { $sth->execute($user->id); my @watches; while (my ($productId, $componentId, $login) = $sth->fetchrow_array) { - my $product = Bugzilla::Product->new($productId); + my $product = Bugzilla::Product->new({ id => $productId, cache => 1 }); next unless $product && $user->can_access_product($product); my %watch = ( product => $product, - component => Bugzilla::Component->new($componentId), + component => Bugzilla::Component->new({ id => $componentId, cache => 1 }), user => Bugzilla::User->check($login), ); push @watches, \%watch; |