Merge lp://staging/~jcsackett/launchpad/bugtasks-deacitvated-context-632847 into lp://staging/launchpad

Proposed by j.c.sackett
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 12363
Proposed branch: lp://staging/~jcsackett/launchpad/bugtasks-deacitvated-context-632847
Merge into: lp://staging/launchpad
Diff against target: 201 lines (+73/-16)
4 files modified
lib/lp/bugs/browser/tests/test_buglisting.py (+47/-2)
lib/lp/bugs/model/bugtask.py (+12/-0)
lib/lp/registry/browser/tests/test_milestone.py (+11/-7)
lib/lp/registry/browser/tests/test_person_view.py (+3/-7)
To merge this branch: bzr merge lp://staging/~jcsackett/launchpad/bugtasks-deacitvated-context-632847
Reviewer Review Type Date Requested Status
Robert Collins (community) Needs Fixing
Graham Binns (community) code Approve
Review via email: mp+48925@code.staging.launchpad.net

Commit message

[r=gmb][bug=632847] Adds check to prevent bugtasks for deactivated products from showing up for people who can't see the product.

Description of the change

Summary
=======

Per bug 632847, bugtasks for deactivated projects can show up in search results. Users clicking on links for these bugtasks then get a 404. The best fix for this is to make sure that users that can't verify the deactivated project (i.e. aren't registry admins) don't see those bugtasks.

Preimplementation
=================

Spoke with Deryck Hodge and Curtis Hovey

Proposed Fix
============

Add a step in the query building for bug search that checks is the searching user is in registry admins; if they're not, filter out bugtasks for deactivated products.

Implementation
==============

lib/lp/bugs/browser/tests/test_buglisting.py
--------------------------------------------
Tests added.

lib/lp/bugs/model/bugtask.py
----------------------------
A check is added to see if the searching user is in registry admins; if they're not, an extra clause is added to the query to remove products that are deactivated.

lib/lp/registry/browser/tests/test_person_view.py
-------------------------------------------------
Drive by clean up of whitespace while trying to decide where to place new tests.

Tests
=====

bin/test -t test_buglisting

Demo & QA
=========

Using the link provided in the bug (though switch to qastaging). If you are signed in and are a member of registry admins, you should see the bugtask reported as problematic in the bugtask. If you are not in registry admins (or logout), you should not see it.

Lint
====

make lint output:

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/bugs/browser/tests/test_buglisting.py
  lib/lp/bugs/model/bugtask.py
  lib/lp/registry/browser/tests/test_person_view.py

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

Just one comment: test_listing_seen_with_permission needs a comment at the start of it stating the expected behaviour (it's obvious from the test, but I don't want to have to parse the test to understand what it's testing).

Other than that this is great; r=me.

review: Approve (code)
Revision history for this message
Robert Collins (lifeless) wrote :

Uhm
this is a correlated subquery; generally this about the worst performing thing we can do: it repeats the same work hundreds of thousands of times.

Worse, we're adding a lookup to product for every bug found, even if we're search in a context where this is impossible and irrelevant - e.g. distro or product searches.

I'm going to roll this back out today to avoid blocking deploys : we have massive issues with bug search already.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.