(bug 39957) Added threshold for showing number of page watchers.
authorTyler Anthony Romeo <tylerromeo@gmail.com>
Mon, 8 Oct 2012 04:04:07 +0000 (00:04 -0400)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 20 Dec 2012 02:06:03 +0000 (02:06 +0000)
Added configuation variable that allows bypassing the unwatchedpages
permission when the number of people watching a page is greater
than a certain threshold. The default value is false, meaning the
unwatchedpages permission is always required.

Change-Id: I1cb6ee22d50d871a8c7083c5b7a091d31cf640f5

includes/DefaultSettings.php
includes/actions/InfoAction.php

index e12b3be..c0c7d76 100644 (file)
@@ -5158,6 +5158,13 @@ $wgAllowCategorizedRecentChanges = false;
  */
 $wgUseTagFilter = true;
 
+/**
+ * If set to an integer, pages that are watched by more users than this
+ * threshold will not require the unwatchedpages permission to view the
+ * number of watchers.
+ */
+$wgUnwatchedPageThreshold = false;
+
 /** @} */ # end RC/watchlist }
 
 /************************************************************************//**
index fb8aea6..06c2894 100644 (file)
@@ -165,7 +165,7 @@ class InfoAction extends FormlessAction {
         * @return array
         */
        protected function pageInfo() {
-               global $wgContLang, $wgRCMaxAge, $wgMemc;
+               global $wgContLang, $wgRCMaxAge, $wgMemc, $wgUnwatchedPageThreshold;
 
                $user = $this->getUser();
                $lang = $this->getLanguage();
@@ -265,7 +265,11 @@ class InfoAction extends FormlessAction {
                        );
                }
 
-               if ( $user->isAllowed( 'unwatchedpages' ) ) {
+               if (
+                       $user->isAllowed( 'unwatchedpages' ) ||
+                       ( $wgUnwatchedPageThreshold !== false &&
+                         $pageCounts['watchers'] >= $wgUnwatchedPageThreshold )
+               ) {
                        // Number of page watchers
                        $pageInfo['header-basic'][] = array(
                                $this->msg( 'pageinfo-watchers' ), $lang->formatNum( $pageCounts['watchers'] )