r62404 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62403‎ | r62404 | r62405 >
Date:00:28, 13 February 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Rest of dieUsageMsg in getPossibleErrors
Modified paths:
  • /trunk/phase3/includes/api/ApiDelete.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFeedWatchlist.php (modified) (history)
  • /trunk/phase3/includes/api/ApiImport.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMove.php (modified) (history)
  • /trunk/phase3/includes/api/ApiPatrol.php (modified) (history)
  • /trunk/phase3/includes/api/ApiProtect.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBacklinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryRevisions.php (modified) (history)
  • /trunk/phase3/includes/api/ApiRollback.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUndelete.php (modified) (history)
  • /trunk/phase3/includes/api/ApiWatch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiWatch.php
@@ -91,6 +91,14 @@
9292 'Add or remove a page from/to the current user\'s watchlist'
9393 );
9494 }
 95+
 96+ public function getPossibleErrors() {
 97+ return array_merge( parent::getPossibleErrors(), array(
 98+ array( 'code' => 'notloggedin', 'info' => 'You must be logged-in to have a watchlist' ),
 99+ array( 'invalidtitle', 'title' ),
 100+ array( 'hookaborted' ),
 101+ ) );
 102+ }
95103
96104 protected function getExamples() {
97105 return array(
Index: trunk/phase3/includes/api/ApiMove.php
@@ -209,6 +209,19 @@
210210 'Move a page.'
211211 );
212212 }
 213+
 214+ public function getPossibleErrors() {
 215+ return array_merge( parent::getPossibleErrors(), array(
 216+ array( 'missingparam', 'to' ),
 217+ array( 'missingparam', 'token' ),
 218+ array( 'sessionfailure' ),
 219+ array( 'invalidtitle', 'from' ),
 220+ array( 'nosuchpageid', 'fromid' ),
 221+ array( 'notanarticle' ),
 222+ array( 'invalidtitle', 'to' ),
 223+ array( 'sharedfile-exists' ),
 224+ ) );
 225+ }
213226
214227 protected function getExamples() {
215228 return array (
Index: trunk/phase3/includes/api/ApiProtect.php
@@ -171,6 +171,23 @@
172172 'Change the protection level of a page.'
173173 );
174174 }
 175+
 176+ public function getPossibleErrors() {
 177+ return array_merge( parent::getPossibleErrors(), array(
 178+ array( 'missingparam', 'title' ),
 179+ array( 'missingparam', 'token' ),
 180+ array( 'missingparam', 'protections' ),
 181+ array( 'sessionfailure' ),
 182+ array( 'invalidtitle', 'title' ),
 183+ array( 'toofewexpiries', 'noofexpiries', 'noofprotections' ) ),
 184+ array( 'create-titleexists' ),
 185+ array( 'missingtitle-createonly' ),
 186+ array( 'protect-invalidaction', 'action'] ),
 187+ array( 'protect-invalidlevel', 'level' ),
 188+ array( 'invalidexpiry', 'expiry' ),
 189+ array( 'pastexpiry', 'expiry' ),
 190+ ) );
 191+ }
175192
176193 protected function getExamples() {
177194 return array (
Index: trunk/phase3/includes/api/ApiQueryBacklinks.php
@@ -453,6 +453,13 @@
454454 ApiBase :: dieDebug( __METHOD__, 'Unknown module name' );
455455 }
456456 }
 457+
 458+ public function getPossibleErrors() {
 459+ return array_merge( parent::getPossibleErrors(), array(
 460+ array( 'invalidtitle', 'title' ),
 461+ array( 'missingparam', 'title' ),
 462+ ) );
 463+ }
457464
458465 protected function getExamples() {
459466 static $examples = array (
Index: trunk/phase3/includes/api/ApiRollback.php
@@ -113,6 +113,17 @@
114114 'they will all be rolled back.'
115115 );
116116 }
 117+
 118+ public function getPossibleErrors() {
 119+ return array_merge( parent::getPossibleErrors(), array(
 120+ array( 'missingparam', 'title' ),
 121+ array( 'missingparam', 'user' ),
 122+ array( 'missingparam', 'token' ),
 123+ array( 'invalidtitle', 'title' ),
 124+ array( 'notanarticle' ),
 125+ array( 'invaliduser', 'user' ),
 126+ ) );
 127+ }
117128
118129 protected function getExamples() {
119130 return array (
Index: trunk/phase3/includes/api/ApiQueryBase.php
@@ -407,6 +407,13 @@
408408 public function keyPartToTitle( $keyPart ) {
409409 return substr( $this->keyToTitle( $keyPart . 'x' ), 0, - 1 );
410410 }
 411+
 412+ public function getPossibleErrors() {
 413+ return array_merge( parent::getPossibleErrors(), array(
 414+ array( 'invalidtitle', 'title' ),
 415+ array( 'invalidtitle', 'key' ),
 416+ ) );
 417+ }
411418
412419 /**
413420 * Get version string for use in the API help output
Index: trunk/phase3/includes/api/ApiDelete.php
@@ -209,6 +209,16 @@
210210 'Delete a page.'
211211 );
212212 }
 213+
 214+ public function getPossibleErrors() {
 215+ return array_merge( parent::getPossibleErrors(), array(
 216+ array( 'missingparam', 'token' ),
 217+ array( 'invalidtitle', 'title' ),
 218+ array( 'nosuchpageid', 'pageid' ),
 219+ array( 'notanarticle' ),
 220+ array( 'hookaborted', 'error' ),
 221+ ) );
 222+ }
213223
214224 protected function getExamples() {
215225 return array (
@@ -220,4 +230,4 @@
221231 public function getVersion() {
222232 return __CLASS__ . ': $Id$';
223233 }
224 -}
 234+}
\ No newline at end of file
Index: trunk/phase3/includes/api/ApiImport.php
@@ -140,6 +140,18 @@
141141 'Import a page from another wiki, or an XML file'
142142 );
143143 }
 144+
 145+ public function getPossibleErrors() {
 146+ return array_merge( parent::getPossibleErrors(), array(
 147+ array( 'cantimport' ),
 148+ array( 'missingparam', 'token' ),
 149+ array( 'sessionfailure' ),
 150+ array( 'missingparam', 'interwikipage' ),
 151+ array( 'cantimport-upload' ),
 152+ array( 'import-unknownerror', 'source' ),
 153+ array( 'import-unknownerror', 'result' ),
 154+ ) );
 155+ }
144156
145157 protected function getExamples() {
146158 return array(
@@ -176,4 +188,4 @@
177189 {
178190 return $this->mResultArr;
179191 }
180 -}
 192+}
\ No newline at end of file
Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -345,7 +345,47 @@
346346 protected function getDescription() {
347347 return 'Create and edit pages.';
348348 }
 349+
 350+ public function getPossibleErrors() {
 351+ return array_merge( parent::getPossibleErrors(), array(
 352+ array( 'missingparam', 'title' ),
 353+ array( 'missingtext' ),
 354+ array( 'missingparam', 'token' ),
 355+ array( 'sessionfailure' ),
 356+ array( 'invalidtitle', 'title' ),
 357+ array( 'createonly-exists' ),
 358+ array( 'nocreate-missing' ),
 359+ array( 'nosuchrevid', 'undo' ),
 360+ array( 'nosuchrevid', 'undoafter' ),
 361+ array( 'revwrongpage', 'id', 'text' ),
 362+ array( 'revwrongpage', 'id', 'text' ),
 363+ array( 'undo-failure' ),
 364+ array( 'hashcheckfailed' ),
 365+ array( 'hookaborted' ),
 366+ array( 'hookaborted' ),
 367+ array( 'noimageredirect-anon' ),
 368+ array( 'noimageredirect-logged' ),
 369+ array( 'spamdetected', 'spam' ),
 370+ array( 'filtered' ),
 371+ array( 'blockedtext' ),
 372+ array( 'contenttoobig', $this->getMaxArticleSize() ),
 373+ array( 'noedit-anon' ),
 374+ array( 'noedit' ),
 375+ array( 'actionthrottledtext' ),
 376+ array( 'wasdeleted' ),
 377+ array( 'nocreate-loggedin' ),
 378+ array( 'blankpage' ),
 379+ array( 'editconflict' ),
 380+ array( 'emptynewsection' ),
 381+ array( 'unknownerror', 'retval' ),
 382+ ) );
 383+ }
349384
 385+ private function getMaxArticleSize() {
 386+ global $wgMaxArticleSize;
 387+ return $wgMaxArticleSize;
 388+ }
 389+
350390 protected function getAllowedParams() {
351391 return array (
352392 'title' => null,
Index: trunk/phase3/includes/api/ApiPatrol.php
@@ -89,6 +89,15 @@
9090 'Patrol a page or revision. '
9191 );
9292 }
 93+
 94+ public function getPossibleErrors() {
 95+ return array_merge( parent::getPossibleErrors(), array(
 96+ array( 'missingparam', 'token' ),
 97+ array( 'missingparam', 'rcid' ),
 98+ array( 'sessionfailure' ),
 99+ array( 'nosuchrcid', 'rcid' ),
 100+ ) );
 101+ }
93102
94103 protected function getExamples() {
95104 return array(
@@ -99,4 +108,4 @@
100109 public function getVersion() {
101110 return __CLASS__ . ': $Id$';
102111 }
103 -}
 112+}
\ No newline at end of file
Index: trunk/phase3/includes/api/ApiUndelete.php
@@ -117,6 +117,18 @@
118118 'retrieved through list=deletedrevs'
119119 );
120120 }
 121+
 122+ public function getPossibleErrors() {
 123+ return array_merge( parent::getPossibleErrors(), array(
 124+ array( 'missingparam', 'title' ),
 125+ array( 'missingparam', 'token' ),
 126+ array( 'permdenied-undelete' ),
 127+ array( 'blockedtext' ),
 128+ array( 'sessionfailure' ),
 129+ array( 'invalidtitle', 'title' ),
 130+ array( 'cannotundelete' ),
 131+ ) );
 132+ }
121133
122134 protected function getExamples() {
123135 return array (
Index: trunk/phase3/includes/api/ApiQueryRevisions.php
@@ -560,6 +560,12 @@
561561 'All parameters marked as (enum) may only be used with a single page (#2).'
562562 );
563563 }
 564+
 565+ public function getPossibleErrors() {
 566+ return array_merge( parent::getPossibleErrors(), array(
 567+ array( 'nosuchrevid', 'diffto' ),
 568+ ) );
 569+ }
564570
565571 protected function getExamples() {
566572 return array (
Index: trunk/phase3/includes/api/ApiFeedWatchlist.php
@@ -116,7 +116,6 @@
117117 $feedFormat = isset( $params['feedformat'] ) ? $params['feedformat'] : 'rss';
118118 $feed = new $wgFeedClasses[$feedFormat] ( $feedTitle, htmlspecialchars( wfMsgForContent( 'watchlist' ) ), $feedUrl );
119119
120 -
121120 if ( $e instanceof UsageException ) {
122121 $errorCode = $e->getCodeString();
123122 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r62407Rem erroneous bracket, followup to r62404reedy00:49, 13 February 2010
r62461Fixup spaces to tabs from r62404reedy14:29, 14 February 2010

Comments

#Comment by Catrope (talk | contribs)   13:39, 14 February 2010
+	private function getMaxArticleSize() {
+		global $wgMaxArticleSize;
+		return $wgMaxArticleSize;
+	}
+

?

+    public function getPossibleErrors() {

Please use tabs for indentation instead of spaces. All getPossibleErrors() declarations in this commit seem to be affected.

#Comment by Reedy (talk | contribs)   14:30, 14 February 2010

for the getMaxArticleSize,

Simplest way I could think of doing it for + array( 'contenttoobig', $this->getMaxArticleSize() ),

Status & tagging log