From 073bc45c2b113f5bba740079f9b161178e83c225 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Thu, 29 Nov 2007 14:51:58 +0000 Subject: [PATCH] Adding apihighlimits permission. Users with this permission can request 10 times as many rows in API requests. Enabled by default for sysops and bots. --- RELEASE-NOTES | 3 ++- includes/DefaultSettings.php | 2 ++ includes/api/ApiBase.php | 2 +- includes/api/ApiMain.php | 13 ++++++++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b9768377ec..0ec26cf8d7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -196,7 +196,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN for users with special characters in their names * The number of watching users in watchlists was always reported as 1 * namespaceDupes.php no longer dies when coming across an illegal title -* Make API check for restrictions in the old format too. * (bug 12143) Do not show a link to patrol new pages for non existent pages == Parser changes in 1.12 == @@ -302,6 +301,8 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API * (bug 11206) api.php should honor maxlag * Added diff generation to prop=revisions * Added support for traditional, unified and array diffs to prop=revisions +* Make prop=info check for restrictions in the old format too. +* Add apihighlimits permission, default for sysops and bots === Languages updated in 1.12 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index b54767b174..9c8c726b98 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1072,6 +1072,7 @@ $wgGroupPermissions['bot' ]['autoconfirmed'] = true; $wgGroupPermissions['bot' ]['nominornewtalk'] = true; $wgGroupPermissions['bot' ]['autopatrol'] = true; $wgGroupPermissions['bot' ]['suppressredirect'] = true; +$wgGroupPermissions['bot' ]['apihighlimits'] = true; // Most extra permission abilities go to this group $wgGroupPermissions['sysop']['block'] = true; @@ -1099,6 +1100,7 @@ $wgGroupPermissions['sysop']['ipblock-exempt'] = true; $wgGroupPermissions['sysop']['blockemail'] = true; $wgGroupPermissions['sysop']['markbotedits'] = true; $wgGroupPermissions['sysop']['suppressredirect'] = true; +$wgGroupPermissions['sysop']['apihighlimits'] = true; #$wgGroupPermissions['sysop']['mergehistory'] = true; // Permission to change users' group assignments diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 6c97a5bec9..2191a95293 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -485,7 +485,7 @@ abstract class ApiBase { // Optimization: do not check user's bot status unless really needed -- skips db query // assumes $botMax >= $max if (!is_null($max) && $value > $max) { - if (!is_null($botMax) && ($this->getMain()->isBot() || $this->getMain()->isSysop())) { + if (!is_null($botMax) && ($this->getMain()->canApiHighLimits())) { if ($value > $botMax) { $this->dieUsage($this->encodeParamName($paramName) . " may not be over $botMax (set to $value) for bots or sysops", $paramName); } diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 6ce44a6bcf..acf3e5009e 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -467,11 +467,12 @@ class ApiMain extends ApiBase { } private $mIsBot = null; - private $mIsSysop = null; + private $mCanApiHighLimits = null; /** * Returns true if the currently logged in user is a bot, false otherwise + * OBSOLETE, use canApiHighLimits() instead */ public function isBot() { if (!isset ($this->mIsBot)) { @@ -484,6 +485,7 @@ class ApiMain extends ApiBase { /** * Similar to isBot(), this method returns true if the logged in user is * a sysop, and false if not. + * OBSOLETE, use canApiHighLimits() instead */ public function isSysop() { if (!isset ($this->mIsSysop)) { @@ -493,6 +495,15 @@ class ApiMain extends ApiBase { return $this->mIsSysop; } + + public function canApiHighLimits() { + if (!is_null ($this->mCanApiHighLimits)) { + global $wgUser; + $this->mCanApiHighLimits = $wgUser->isAllowed('apihighlimits'); + } + + return $this->mCanApiHighLimits; + } public function getShowVersions() { return $this->mShowVersions; -- 2.20.1