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
=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py 2011-02-17 01:03:34 +0000
+++ lib/lp/bugs/model/bug.py 2011-02-21 02:55:12 +0000
@@ -1779,11 +1779,15 @@
1779 def _known_viewers(self):1779 def _known_viewers(self):
1780 """A set of known persons able to view this bug.1780 """A set of known persons able to view this bug.
17811781
1782 Seed it by including the list of all owners of pillars for bugtasks1782 This method must return an empty set or bug searches will trigger late
1783 for the bug.1783 evaluation. Any 'should be set on load' propertis must be done by the
1784 bug search.
1785
1786 If you are tempted to change this method, don't. Instead see
1787 userCanView which defines the just-in-time policy for bug visibility,
1788 and BugTask._search which honours visibility rules.
1784 """1789 """
1785 pillar_owners = [bt.pillar.owner.id for bt in self.bugtasks]1790 return set()
1786 return set(pillar_owners)
17871791
1788 def userCanView(self, user):1792 def userCanView(self, user):
1789 """See `IBug`.1793 """See `IBug`.
@@ -1819,6 +1823,12 @@
1819 if user.inTeam(subscription.person):1823 if user.inTeam(subscription.person):
1820 self._known_viewers.add(user.id)1824 self._known_viewers.add(user.id)
1821 return True1825 return True
1826 # Pillar owners can view it. Note that this is contentious and
1827 # possibly incorrect: see bug 702429.
1828 for pillar_owner in [bt.pillar.owner for bt in self.bugtasks]:
1829 if user.inTeam(pillar_owner):
1830 self._known_viewers.add(user.id)
1831 return True
1822 return False1832 return False
18231833
1824 def linkHWSubmission(self, submission):1834 def linkHWSubmission(self, submission):