r61437 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61436‎ | r61437 | r61438 >
Date:22:26, 23 January 2010
Author:reedy
Status:ok
Tags:
Comment:
Add/remove whitelines to increase readability in API code files
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiDelete.php (modified) (history)
  • /trunk/phase3/includes/api/ApiDisabled.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEmailUser.php (modified) (history)
  • /trunk/phase3/includes/api/ApiExpandTemplates.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFormatRaw.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFormatWddx.php (modified) (history)
  • /trunk/phase3/includes/api/ApiFormatYaml_spyc.php (modified) (history)
  • /trunk/phase3/includes/api/ApiImport.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMove.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryAllpages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategories.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryCategoryInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryDeletedrevs.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryDuplicateFiles.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryExternalLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryImages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryLangLinks.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUserInfo.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryUsers.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlistRaw.php (modified) (history)
  • /trunk/phase3/includes/api/ApiResult.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUndelete.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUpload.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUserrights.php (modified) (history)
  • /trunk/phase3/includes/api/ApiWatch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFormatRaw.php
@@ -46,10 +46,13 @@
4747
4848 public function getMimeType() {
4949 $data = $this->getResultData();
 50+
5051 if ( isset( $data['error'] ) )
5152 return $this->mErrorFallback->getMimeType();
 53+
5254 if ( !isset( $data['mime'] ) )
5355 ApiBase::dieDebug( __METHOD__, "No MIME type set for raw formatter" );
 56+
5457 return $data['mime'];
5558 }
5659
@@ -60,6 +63,7 @@
6164 $this->mErrorFallback->execute();
6265 return;
6366 }
 67+
6468 if ( !isset( $data['text'] ) )
6569 ApiBase::dieDebug( __METHOD__, "No text given for raw formatter" );
6670 $this->printText( $data['text'] );
Index: trunk/phase3/includes/api/ApiQueryWatchlistRaw.php
@@ -68,6 +68,7 @@
6969 $this->addWhereFld( 'wl_namespace', $params['namespace'] );
7070 $this->addWhereIf( 'wl_notificationtimestamp IS NOT NULL', isset( $show['changed'] ) );
7171 $this->addWhereIf( 'wl_notificationtimestamp IS NULL', isset( $show['!changed'] ) );
 72+
7273 if ( isset( $params['continue'] ) )
7374 {
7475 $cont = explode( '|', $params['continue'] );
@@ -80,6 +81,7 @@
8182 "(wl_namespace = '$ns' AND " .
8283 "wl_title >= '$title')" );
8384 }
 85+
8486 // Don't ORDER BY wl_namespace if it's constant in the WHERE clause
8587 if ( count( $params['namespace'] ) == 1 )
8688 $this->addOption( 'ORDER BY', 'wl_title' );
@@ -101,6 +103,7 @@
102104 break;
103105 }
104106 $t = Title::makeTitle( $row->wl_namespace, $row->wl_title );
 107+
105108 if ( is_null( $resultPageSet ) )
106109 {
107110 $vals = array();
Index: trunk/phase3/includes/api/ApiQueryLangLinks.php
@@ -63,6 +63,7 @@
6464 "(ll_from = $llfrom AND " .
6565 "ll_lang >= '$lllang')" );
6666 }
 67+
6768 # Don't order by ll_from if it's constant in the WHERE clause
6869 if ( count( $this->getPageSet()->getGoodTitles() ) == 1 )
6970 $this->addOption( 'ORDER BY', 'll_lang' );
Index: trunk/phase3/includes/api/ApiFormatYaml_spyc.php
@@ -159,7 +159,6 @@
160160 strpos( $value, "\n" ) ||
161161 preg_match( "/[#:]/", $value ) ||
162162 preg_match( "/^[-?,[\]{}!*&|>'\"%@`]/", $value ) ) );
163 -
164163 }
165164
166165 /**
Index: trunk/phase3/includes/api/ApiQueryUserInfo.php
@@ -62,24 +62,29 @@
6363
6464 if ( $wgUser->isAnon() )
6565 $vals['anon'] = '';
 66+
6667 if ( isset( $this->prop['blockinfo'] ) ) {
6768 if ( $wgUser->isBlocked() ) {
6869 $vals['blockedby'] = User::whoIs( $wgUser->blockedBy() );
6970 $vals['blockreason'] = $wgUser->blockedFor();
7071 }
7172 }
 73+
7274 if ( isset( $this->prop['hasmsg'] ) && $wgUser->getNewtalk() ) {
7375 $vals['messages'] = '';
7476 }
 77+
7578 if ( isset( $this->prop['groups'] ) ) {
7679 $vals['groups'] = $wgUser->getGroups();
7780 $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty
7881 }
 82+
7983 if ( isset( $this->prop['rights'] ) ) {
8084 // User::getRights() may return duplicate values, strip them
8185 $vals['rights'] = array_values( array_unique( $wgUser->getRights() ) );
8286 $result->setIndexedTagName( $vals['rights'], 'r' ); // even if empty
8387 }
 88+
8489 if ( isset( $this->prop['changeablegroups'] ) ) {
8590 $vals['changeablegroups'] = $wgUser->changeableGroups();
8691 $result->setIndexedTagName( $vals['changeablegroups']['add'], 'g' );
@@ -87,18 +92,23 @@
8893 $result->setIndexedTagName( $vals['changeablegroups']['add-self'], 'g' );
8994 $result->setIndexedTagName( $vals['changeablegroups']['remove-self'], 'g' );
9095 }
 96+
9197 if ( isset( $this->prop['options'] ) ) {
9298 $vals['options'] = $wgUser->getOptions();
9399 }
 100+
94101 if ( isset( $this->prop['preferencestoken'] ) && is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
95102 $vals['preferencestoken'] = $wgUser->editToken();
96103 }
 104+
97105 if ( isset( $this->prop['editcount'] ) ) {
98106 $vals['editcount'] = intval( $wgUser->getEditCount() );
99107 }
 108+
100109 if ( isset( $this->prop['ratelimits'] ) ) {
101110 $vals['ratelimits'] = $this->getRateLimits();
102111 }
 112+
103113 if ( isset( $this->prop['email'] ) ) {
104114 $vals['email'] = $wgUser->getEmail();
105115 $auth = $wgUser->getEmailAuthenticationTimestamp();
Index: trunk/phase3/includes/api/ApiEmailUser.php
@@ -27,7 +27,6 @@
2828 require_once ( "ApiBase.php" );
2929 }
3030
31 -
3231 /**
3332 * @ingroup API
3433 */
@@ -61,8 +60,7 @@
6261 $error = EmailUserForm::getPermissionsError( $wgUser, $params['token'] );
6362 if ( $error )
6463 $this->dieUsageMsg( array( $error ) );
65 -
66 -
 64+
6765 $form = new EmailUserForm( $targetUser, $params['text'], $params['subject'], $params['ccme'] );
6866 $retval = $form->doSubmit();
6967 if ( is_null( $retval ) )
Index: trunk/phase3/includes/api/ApiUndelete.php
@@ -48,8 +48,10 @@
4949
5050 if ( !$wgUser->isAllowed( 'undelete' ) )
5151 $this->dieUsageMsg( array( 'permdenied-undelete' ) );
 52+
5253 if ( $wgUser->isBlocked() )
5354 $this->dieUsageMsg( array( 'blockedtext' ) );
 55+
5456 if ( !$wgUser->matchEditToken( $params['token'] ) )
5557 $this->dieUsageMsg( array( 'sessionfailure' ) );
5658
Index: trunk/phase3/includes/api/ApiQueryExternalLinks.php
@@ -51,9 +51,11 @@
5252
5353 $this->addTables( 'externallinks' );
5454 $this->addWhereFld( 'el_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
 55+
5556 # Don't order by el_from if it's constant in the WHERE clause
5657 if ( count( $this->getPageSet()->getGoodTitles() ) != 1 )
5758 $this->addOption( 'ORDER BY', 'el_from' );
 59+
5860 $this->addOption( 'LIMIT', $params['limit'] + 1 );
5961 if ( !is_null( $params['offset'] ) )
6062 $this->addOption( 'OFFSET', $params['offset'] );
Index: trunk/phase3/includes/api/ApiBase.php
@@ -657,13 +657,16 @@
658658 return array();
659659 $sizeLimit = $this->mMainModule->canApiHighLimits() ? self::LIMIT_SML2 : self::LIMIT_SML1;
660660 $valuesList = explode( '|', $value, $sizeLimit + 1 );
 661+
661662 if ( self::truncateArray( $valuesList, $sizeLimit ) ) {
662663 $this->setWarning( "Too many values supplied for parameter '$valueName': the limit is $sizeLimit" );
663664 }
 665+
664666 if ( !$allowMultiple && count( $valuesList ) != 1 ) {
665667 $possibleValues = is_array( $allowedValues ) ? "of '" . implode( "', '", $allowedValues ) . "'" : '';
666668 $this->dieUsage( "Only one $possibleValues is allowed for parameter '$valueName'", "multival_$valueName" );
667669 }
 670+
668671 if ( is_array( $allowedValues ) ) {
669672 # Check for unknown values
670673 $unknown = array_diff( $valuesList, $allowedValues );
Index: trunk/phase3/includes/api/ApiQueryCategories.php
@@ -79,6 +79,7 @@
8080 }
8181 $this->addWhereFld( 'cl_to', $cats );
8282 }
 83+
8384 if ( !is_null( $params['continue'] ) ) {
8485 $cont = explode( '|', $params['continue'] );
8586 if ( count( $cont ) != 2 )
@@ -90,6 +91,7 @@
9192 "(cl_from = $clfrom AND " .
9293 "cl_to >= '$clto')" );
9394 }
 95+
9496 if ( isset( $show['hidden'] ) && isset( $show['!hidden'] ) )
9597 $this->dieUsage( "Incorrect parameter - mutually exclusive values may not be supplied", 'show' );
9698 if ( isset( $show['hidden'] ) || isset( $show['!hidden'] ) || isset( $prop['hidden'] ) )
Index: trunk/phase3/includes/api/ApiQueryDuplicateFiles.php
@@ -63,11 +63,13 @@
6464 'i2.img_user_text AS dup_user_text',
6565 'i2.img_timestamp AS dup_timestamp'
6666 ) );
 67+
6768 $this->addWhere( array(
6869 'i1.img_name' => array_keys( $images ),
6970 'i1.img_sha1 = i2.img_sha1',
7071 'i1.img_name != i2.img_name',
7172 ) );
 73+
7274 if ( isset( $params['continue'] ) )
7375 {
7476 $cont = explode( '|', $params['continue'] );
@@ -80,6 +82,7 @@
8183 "(i1.img_name = '$orig' AND " .
8284 "i2.img_name >= '$dup')" );
8385 }
 86+
8487 $this->addOption( 'ORDER BY', 'i1.img_name' );
8588 $this->addOption( 'LIMIT', $params['limit'] + 1 );
8689
Index: trunk/phase3/includes/api/ApiUpload.php
@@ -50,7 +50,6 @@
5151 if ( !$wgUser->matchEditToken( $this->mParams['token'] ) )
5252 $this->dieUsageMsg( array( 'sessionfailure' ) );
5353
54 -
5554 // Add the uploaded file to the params array
5655 $this->mParams['file'] = $request->getFileName( 'file' );
5756
@@ -72,7 +71,7 @@
7372
7473 $this->mUpload = new UploadFromStash();
7574 $this->mUpload->initialize( $this->mParams['filename'],
76 - $_SESSION['wsUploadData'][$this->mParams['sessionkey']] );
 75+ $_SESSION['wsUploadData'][$this->mParams['sessionkey']] );
7776 } else {
7877 /**
7978 * Upload from url, etc
@@ -113,7 +112,6 @@
114113 if ( ! $wgUser->isAllowed( 'upload_by_url' ) )
115114 $this->dieUsageMsg( array( 'badaccess-groups' ) );
116115
117 -
118116 $this->mUpload = new UploadFromUrl();
119117 $this->mUpload->initialize( $this->mParams['filename'],
120118 $this->mParams['url'] );
Index: trunk/phase3/includes/api/ApiQueryUsers.php
@@ -33,7 +33,6 @@
3434 *
3535 * @ingroup API
3636 */
37 -
3837 class ApiQueryUsers extends ApiQueryBase {
3938
4039 public function __construct( $query, $moduleName ) {
@@ -104,6 +103,7 @@
105104 else
106105 $goodNames[] = $n;
107106 }
 107+
108108 if ( count( $goodNames ) )
109109 {
110110 $db = $this->getDb();
Index: trunk/phase3/includes/api/ApiQueryImages.php
@@ -71,6 +71,7 @@
7272 "(il_from = $ilfrom AND " .
7373 "il_to >= '$ilto')" );
7474 }
 75+
7576 # Don't order by il_from if it's constant in the WHERE clause
7677 if ( count( $this->getPageSet()->getGoodTitles() ) == 1 )
7778 $this->addOption( 'ORDER BY', 'il_to' );
Index: trunk/phase3/includes/api/ApiWatch.php
@@ -43,12 +43,16 @@
4444 global $wgUser;
4545 if ( !$wgUser->isLoggedIn() )
4646 $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
 47+
4748 $params = $this->extractRequestParams();
4849 $title = Title::newFromText( $params['title'] );
 50+
4951 if ( !$title )
5052 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
 53+
5154 $article = new Article( $title );
5255 $res = array( 'title' => $title->getPrefixedText() );
 56+
5357 if ( $params['unwatch'] )
5458 {
5559 $res['unwatched'] = '';
Index: trunk/phase3/includes/api/ApiMove.php
@@ -63,6 +63,7 @@
6464 if ( !$fromTitle )
6565 $this->dieUsageMsg( array( 'nosuchpageid', $params['fromid'] ) );
6666 }
 67+
6768 if ( !$fromTitle->exists() )
6869 $this->dieUsageMsg( array( 'notanarticle' ) );
6970 $fromTalk = $fromTitle->getTalkPage();
Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -137,8 +137,6 @@
138138 if ( $forceNameTitleIndex )
139139 $this->addOption( 'USE INDEX', 'name_title' );
140140
141 -
142 -
143141 $limit = $params['limit'];
144142 $this->addOption( 'LIMIT', $limit + 1 );
145143 $res = $this->select( __METHOD__ );
Index: trunk/phase3/includes/api/ApiFormatWddx.php
@@ -80,8 +80,7 @@
8181 if ( $cnt == 0 || array_keys( $elemValue ) === range( 0, $cnt - 1 ) ) {
8282 // Regular array
8383 $this->printText( $indstr . Xml::element( 'array', array(
84 - 'length' => $cnt
85 - ), null ) . $nl );
 84+ 'length' => $cnt ), null ) . $nl );
8685 foreach ( $elemValue as $subElemValue )
8786 $this->slowWddxPrinter( $subElemValue, $indent + 2 );
8887 $this->printText( "$indstr</array>$nl" );
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php
@@ -202,8 +202,7 @@
203203 $rev['user'] = $row->ar_user_text;
204204 if ( $fld_comment )
205205 $rev['comment'] = $row->ar_comment;
206 - if ( $fld_minor )
207 - if ( $row->ar_minor_edit == 1 )
 206+ if ( $fld_minor && $row->ar_minor_edit == 1)
208207 $rev['minor'] = '';
209208 if ( $fld_len )
210209 $rev['len'] = $row->ar_len;
Index: trunk/phase3/includes/api/ApiExpandTemplates.php
@@ -55,6 +55,7 @@
5656 // Parse text
5757 global $wgParser;
5858 $options = new ParserOptions();
 59+
5960 if ( $params['generatexml'] )
6061 {
6162 $wgParser->startExternalParse( $title_obj, $options, OT_PREPROCESS );
Index: trunk/phase3/includes/api/ApiUserrights.php
@@ -27,7 +27,6 @@
2828 require_once ( "ApiBase.php" );
2929 }
3030
31 -
3231 /**
3332 * @ingroup API
3433 */
@@ -49,8 +48,8 @@
5049 $user = $form->fetchUser( $params['user'] );
5150 if ( $user instanceof WikiErrorMsg )
5251 $this->dieUsageMsg( array_merge(
53 - (array)$user->getMessageKey(),
54 - $user->getMessageArgs() ) );
 52+ (array)$user->getMessageKey(), $user->getMessageArgs() ) );
 53+
5554 if ( !$wgUser->matchEditToken( $params['token'], $user->getName() ) )
5655 $this->dieUsageMsg( array( 'sessionfailure' ) );
5756
Index: trunk/phase3/includes/api/ApiDelete.php
@@ -27,7 +27,6 @@
2828 require_once ( "ApiBase.php" );
2929 }
3030
31 -
3231 /**
3332 * API module that facilitates deleting pages. The API eqivalent of action=delete.
3433 * Requires API write mode to be enabled.
@@ -74,15 +73,13 @@
7574 if ( $titleObj->getNamespace() == NS_FILE ) {
7675 $retval = self::deleteFile( $params['token'], $titleObj, $params['oldimage'], $reason, false );
7776 if ( count( $retval ) )
78 - // We don't care about multiple errors, just report one of them
79 - $this->dieUsageMsg( reset( $retval ) );
 77+ $this->dieUsageMsg( reset( $retval ) ); // We don't care about multiple errors, just report one of them
8078 } else {
8179 $articleObj = new Article( $titleObj );
8280 $retval = self::delete( $articleObj, $params['token'], $reason );
8381
8482 if ( count( $retval ) )
85 - // We don't care about multiple errors, just report one of them
86 - $this->dieUsageMsg( reset( $retval ) );
 83+ $this->dieUsageMsg( reset( $retval ) ); // We don't care about multiple errors, just report one of them
8784
8885 if ( $params['watch'] || $wgUser->getOption( 'watchdeletion' ) )
8986 $articleObj->doWatch();
Index: trunk/phase3/includes/api/ApiDisabled.php
@@ -27,7 +27,6 @@
2828 require_once ( "ApiBase.php" );
2929 }
3030
31 -
3231 /**
3332 * API module that dies with an error immediately.
3433 *
Index: trunk/phase3/includes/api/ApiImport.php
@@ -91,8 +91,8 @@
9292 $result->mByte . $result->mContext,
9393 xml_error_string( $result->mXmlError ) ) );
9494 else if ( WikiError::isError( $result ) )
95 - // This shouldn't happen
96 - $this->dieUsageMsg( array( 'import-unknownerror', $result->getMessage() ) );
 95+ $this->dieUsageMsg( array( 'import-unknownerror', $result->getMessage() ) ); // This shouldn't happen
 96+
9797 $resultData = $reporter->getData();
9898 $this->getResult()->setIndexedTagName( $resultData, 'page' );
9999 $this->getResult()->addValue( null, $this->getModuleName(), $resultData );
Index: trunk/phase3/includes/api/ApiResult.php
@@ -199,17 +199,16 @@
200200 * @param $arr array
201201 * @param $tag string Tag name
202202 */
203 - public function setIndexedTagName_recursive( &$arr, $tag )
204 - {
205 - if ( !is_array( $arr ) )
206 - return;
207 - foreach ( $arr as &$a )
208 - {
209 - if ( !is_array( $a ) )
210 - continue;
211 - $this->setIndexedTagName( $a, $tag );
212 - $this->setIndexedTagName_recursive( $a, $tag );
213 - }
 203+ public function setIndexedTagName_recursive( &$arr, $tag ) {
 204+ if ( !is_array( $arr ) )
 205+ return;
 206+ foreach ( $arr as &$a )
 207+ {
 208+ if ( !is_array( $a ) )
 209+ continue;
 210+ $this->setIndexedTagName( $a, $tag );
 211+ $this->setIndexedTagName_recursive( $a, $tag );
 212+ }
214213 }
215214
216215 /**
Index: trunk/phase3/includes/api/ApiQueryCategoryInfo.php
@@ -65,8 +65,10 @@
6666 'pp_page=page_id',
6767 'pp_propname' => 'hiddencat' ) ),
6868 ) );
 69+
6970 $this->addFields( array( 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files', 'pp_propname AS cat_hidden' ) );
7071 $this->addWhere( array( 'cat_title' => $cattitles ) );
 72+
7173 if ( !is_null( $params['continue'] ) )
7274 {
7375 $title = $this->getDB()->addQuotes( $params['continue'] );
Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -44,14 +44,18 @@
4545 public function execute() {
4646 global $wgUser;
4747 $params = $this->extractRequestParams();
 48+
4849 if ( is_null( $params['title'] ) )
4950 $this->dieUsageMsg( array( 'missingparam', 'title' ) );
 51+
5052 if ( is_null( $params['text'] ) && is_null( $params['appendtext'] ) &&
5153 is_null( $params['prependtext'] ) &&
5254 $params['undo'] == 0 )
5355 $this->dieUsageMsg( array( 'missingtext' ) );
 56+
5457 if ( is_null( $params['token'] ) )
5558 $this->dieUsageMsg( array( 'missingparam', 'token' ) );
 59+
5660 if ( !$wgUser->matchEditToken( $params['token'] ) )
5761 $this->dieUsageMsg( array( 'sessionfailure' ) );
5862
@@ -113,14 +117,17 @@
114118 $undoRev = Revision::newFromID( $params['undo'] );
115119 if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) )
116120 $this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) );
 121+
117122 if ( $params['undoafter'] == 0 )
118123 $undoafterRev = $undoRev->getPrevious();
119124 if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) )
120125 $this->dieUsageMsg( array( 'nosuchrevid', $params['undoafter'] ) );
 126+
121127 if ( $undoRev->getPage() != $articleObj->getID() )
122128 $this->dieUsageMsg( array( 'revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText() ) );
123129 if ( $undoafterRev->getPage() != $articleObj->getID() )
124130 $this->dieUsageMsg( array( 'revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText() ) );
 131+
125132 $newtext = $articleObj->getUndoText( $undoRev, $undoafterRev );
126133 if ( $newtext === false )
127134 $this->dieUsageMsg( array( 'undo-failure' ) );
@@ -132,9 +139,8 @@
133140 }
134141
135142 # See if the MD5 hash checks out
136 - if ( !is_null( $params['md5'] ) )
137 - if ( md5( $toMD5 ) !== $params['md5'] )
138 - $this->dieUsageMsg( array( 'hashcheckfailed' ) );
 143+ if ( !is_null( $params['md5'] ) && md5( $toMD5 ) !== $params['md5'] )
 144+ $this->dieUsageMsg( array( 'hashcheckfailed' ) );
139145
140146 $ep = new EditPage( $articleObj );
141147 // EditPage wants to parse its stuff from a WebRequest
@@ -143,23 +149,28 @@
144150 'wpEditToken' => $params['token'],
145151 'wpIgnoreBlankSummary' => ''
146152 );
 153+
147154 if ( !is_null( $params['summary'] ) )
148155 $reqArr['wpSummary'] = $params['summary'];
 156+
149157 # Watch out for basetimestamp == ''
150158 # wfTimestamp() treats it as NOW, almost certainly causing an edit conflict
151159 if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' )
152160 $reqArr['wpEdittime'] = wfTimestamp( TS_MW, $params['basetimestamp'] );
153161 else
154162 $reqArr['wpEdittime'] = $articleObj->getTimestamp();
 163+
155164 if ( !is_null( $params['starttimestamp'] ) && $params['starttimestamp'] != '' )
156165 $reqArr['wpStarttime'] = wfTimestamp( TS_MW, $params['starttimestamp'] );
157166 else
158 - # Fake wpStartime
159 - $reqArr['wpStarttime'] = $reqArr['wpEdittime'];
 167+ $reqArr['wpStarttime'] = $reqArr['wpEdittime']; # Fake wpStartime
 168+
160169 if ( $params['minor'] || ( !$params['notminor'] && $wgUser->getOption( 'minordefault' ) ) )
161170 $reqArr['wpMinoredit'] = '';
 171+
162172 if ( $params['recreate'] )
163173 $reqArr['wpRecreate'] = '';
 174+
164175 if ( !is_null( $params['section'] ) )
165176 {
166177 $section = intval( $params['section'] );
@@ -208,6 +219,7 @@
209220 $wgRequest->setVal( 'wpCaptchaId', $params['captchaid'] );
210221 if ( !is_null( $params['captchaword'] ) )
211222 $wgRequest->setVal( 'wpCaptchaWord', $params['captchaword'] );
 223+
212224 $r = array();
213225 if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) )
214226 {
@@ -236,39 +248,55 @@
237249 case EditPage::AS_HOOK_ERROR:
238250 case EditPage::AS_HOOK_ERROR_EXPECTED:
239251 $this->dieUsageMsg( array( 'hookaborted' ) );
 252+
240253 case EditPage::AS_IMAGE_REDIRECT_ANON:
241254 $this->dieUsageMsg( array( 'noimageredirect-anon' ) );
 255+
242256 case EditPage::AS_IMAGE_REDIRECT_LOGGED:
243257 $this->dieUsageMsg( array( 'noimageredirect-logged' ) );
 258+
244259 case EditPage::AS_SPAM_ERROR:
245260 $this->dieUsageMsg( array( 'spamdetected', $result['spam'] ) );
 261+
246262 case EditPage::AS_FILTERING:
247263 $this->dieUsageMsg( array( 'filtered' ) );
 264+
248265 case EditPage::AS_BLOCKED_PAGE_FOR_USER:
249266 $this->dieUsageMsg( array( 'blockedtext' ) );
 267+
250268 case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
251269 case EditPage::AS_CONTENT_TOO_BIG:
252270 global $wgMaxArticleSize;
253271 $this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) );
 272+
254273 case EditPage::AS_READ_ONLY_PAGE_ANON:
255274 $this->dieUsageMsg( array( 'noedit-anon' ) );
 275+
256276 case EditPage::AS_READ_ONLY_PAGE_LOGGED:
257277 $this->dieUsageMsg( array( 'noedit' ) );
 278+
258279 case EditPage::AS_READ_ONLY_PAGE:
259280 $this->dieReadOnly();
 281+
260282 case EditPage::AS_RATE_LIMITED:
261283 $this->dieUsageMsg( array( 'actionthrottledtext' ) );
 284+
262285 case EditPage::AS_ARTICLE_WAS_DELETED:
263286 $this->dieUsageMsg( array( 'wasdeleted' ) );
 287+
264288 case EditPage::AS_NO_CREATE_PERMISSION:
265289 $this->dieUsageMsg( array( 'nocreate-loggedin' ) );
 290+
266291 case EditPage::AS_BLANK_ARTICLE:
267292 $this->dieUsageMsg( array( 'blankpage' ) );
 293+
268294 case EditPage::AS_CONFLICT_DETECTED:
269295 $this->dieUsageMsg( array( 'editconflict' ) );
 296+
270297 # case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary
271298 case EditPage::AS_TEXTBOX_EMPTY:
272299 $this->dieUsageMsg( array( 'emptynewsection' ) );
 300+
273301 case EditPage::AS_SUCCESS_NEW_ARTICLE:
274302 $r['new'] = '';
275303 case EditPage::AS_SUCCESS_UPDATE:
@@ -291,6 +319,7 @@
292320 $newArticle->getTimestamp() );
293321 }
294322 break;
 323+
295324 case EditPage::AS_END:
296325 # This usually means some kind of race condition
297326 # or DB weirdness occurred. Fall through to throw an unknown

Follow-up revisions

RevisionCommit summaryAuthorDate
r61442More of r61437 (adding/removing whitespace)reedy22:47, 23 January 2010

Status & tagging log