Description

The getSubscribers function in Page.py tests every user's permission to read the page in question, rather than only testing the permission of the users who actually are subscribed to the page. If the permission test is slow (in my case, it involves an LDAP query to a remote server) and there are many users, this can create a huge performance penalty on every non-trivial change to the wiki.

Steps to reproduce

  1. Have a wiki with 1400 registered users.
  2. Have a slow permission function (say, one requiring an LDAP lookup).
  3. Save a page to which no one subscribes.
  4. Wait a long time while the save completes.

Fix

Change page.py as follows (based on the current 1.5 code in Mercurial):

@@ -936,9 +936,7 @@
             if not subscriber.email: continue # skip empty email addresses
             if trivial and not subscriber.want_trivial: continue # skip uninterested subscribers

-            if not UserPerms(subscriber).read(self.page_name): continue
-
-            if subscriber.isSubscribedTo(pageList):
+            if subscriber.isSubscribedTo(pageList) and UserPerms(subscriber).read(self.page_name):
                 lang = subscriber.language or request.cfg.language_default
                 if not lang in subscriber_list:
                     subscriber_list[lang] = []

This way, only users who are subscribed to the page have their permissions checked.

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/GetSubscribersPerformanceProblem (last edited 2008-03-18 15:52:44 by JohannesBerg)