Merge lp:~lifeless/launchpad/bug-717394-3 into lp:launchpad

Proposed by Robert Collins
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 12436
Proposed branch: lp:~lifeless/launchpad/bug-717394-3
Merge into: lp:launchpad
Prerequisite: lp:~lifeless/launchpad/bug-717394-2
Diff against target: 36 lines (+14/-4)
1 file modified
lib/lp/bugs/model/bug.py (+14/-4)
To merge this branch: bzr merge lp:~lifeless/launchpad/bug-717394-3
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+50546@code.launchpad.net

Commit message

[r=lifeless][bug=722421] Fix a regression in Bug._known_viewers causing late evaluation of all bugtasks and pillars on every bug shown in a bug search.

Description of the change

Fix a regression in Bug._known_viewers causing a full bugtask lookup for every row in a bugsearch - whether the bugs were private or public. https://bugs.launchpad.net/launchpad/+bug/702429/comments/3 describes this more.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Self reviewing.

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

See also bug 702429 which is mentioned in the rev (12156.8.20) that introduced the regression.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/model/bug.py'
2--- lib/lp/bugs/model/bug.py 2011-02-17 01:03:34 +0000
3+++ lib/lp/bugs/model/bug.py 2011-02-21 02:55:12 +0000
4@@ -1779,11 +1779,15 @@
5 def _known_viewers(self):
6 """A set of known persons able to view this bug.
7
8- Seed it by including the list of all owners of pillars for bugtasks
9- for the bug.
10+ This method must return an empty set or bug searches will trigger late
11+ evaluation. Any 'should be set on load' propertis must be done by the
12+ bug search.
13+
14+ If you are tempted to change this method, don't. Instead see
15+ userCanView which defines the just-in-time policy for bug visibility,
16+ and BugTask._search which honours visibility rules.
17 """
18- pillar_owners = [bt.pillar.owner.id for bt in self.bugtasks]
19- return set(pillar_owners)
20+ return set()
21
22 def userCanView(self, user):
23 """See `IBug`.
24@@ -1819,6 +1823,12 @@
25 if user.inTeam(subscription.person):
26 self._known_viewers.add(user.id)
27 return True
28+ # Pillar owners can view it. Note that this is contentious and
29+ # possibly incorrect: see bug 702429.
30+ for pillar_owner in [bt.pillar.owner for bt in self.bugtasks]:
31+ if user.inTeam(pillar_owner):
32+ self._known_viewers.add(user.id)
33+ return True
34 return False
35
36 def linkHWSubmission(self, submission):