From 65f5aa22cfe3779d86b7e79bd5dc1ca8d5993b23 Mon Sep 17 00:00:00 2001 From: Tyler Anthony Romeo Date: Mon, 8 Oct 2012 00:04:07 -0400 Subject: [PATCH] (bug 39957) Added threshold for showing number of page watchers. 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 | 7 +++++++ includes/actions/InfoAction.php | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e12b3be3fe..c0c7d766ba 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 } /************************************************************************//** diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index fb8aea6f81..06c2894a55 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -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'] ) -- 2.20.1