r27949 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r27948 | r27949 (on ViewVC) | r27950 >
Date:14:51, 29 November 2007
Author:catrope
Status:ok
Tags:
Comment:Adding apihighlimits permission. Users with this permission can request 10 times as many rows in API requests. Enabled by default for sysops and bots.
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/api/ApiMain.php
===================================================================
--- trunk/phase3/includes/api/ApiMain.php	(revision 27948)
+++ trunk/phase3/includes/api/ApiMain.php	(revision 27949)
@@ -467,11 +467,12 @@
 	} 
 
 	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 @@
 	/**
 	 * 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,7 +495,16 @@
 
 		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;
 	}
Index: trunk/phase3/includes/api/ApiBase.php
===================================================================
--- trunk/phase3/includes/api/ApiBase.php	(revision 27948)
+++ trunk/phase3/includes/api/ApiBase.php	(revision 27949)
@@ -485,7 +485,7 @@
 		// 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);
 				}
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 27948)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 27949)
@@ -1072,6 +1072,7 @@
 $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']['blockemail']      = true;
 $wgGroupPermissions['sysop']['markbotedits']	= true;
 $wgGroupPermissions['sysop']['suppressredirect'] = true;
+$wgGroupPermissions['sysop']['apihighlimits']   = true;
 #$wgGroupPermissions['sysop']['mergehistory']    = true;
 
 // Permission to change users' group assignments
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 27948)
+++ trunk/phase3/RELEASE-NOTES	(revision 27949)
@@ -196,7 +196,6 @@
   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 @@
 * (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 ===
 
Views
Toolbox