From: Antoine Musso Date: Thu, 19 May 2011 17:51:16 +0000 (+0000) Subject: Single messages can be passed as strings to Api::dieUsageMsg() X-Git-Tag: 1.31.0-rc.0~30075 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=6a8e32e986bc92773c5564b1a3a36daa8ce7fd0a;p=lhc%2Fweb%2Fwiklou.git Single messages can be passed as strings to Api::dieUsageMsg() Since r88045 --- diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index e0a35062f4..94a85464f2 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -58,7 +58,7 @@ class ApiBlock extends ApiBase { } if ( !$wgUser->isAllowed( 'block' ) ) { - $this->dieUsageMsg( array( 'cantblock' ) ); + $this->dieUsageMsg( 'cantblock' ); } # bug 15810: blocked admins should have limited access here if ( $wgUser->isBlocked() ) { @@ -68,10 +68,10 @@ class ApiBlock extends ApiBase { } } if ( $params['hidename'] && !$wgUser->isAllowed( 'hideuser' ) ) { - $this->dieUsageMsg( array( 'canthide' ) ); + $this->dieUsageMsg( 'canthide' ); } if ( $params['noemail'] && !SpecialBlock::canBlockEmail( $wgUser ) ) { - $this->dieUsageMsg( array( 'cantblock-email' ) ); + $this->dieUsageMsg( 'cantblock-email' ); } $data = array( diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index c5cf855b2c..06e0c64f21 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -65,7 +65,7 @@ class ApiDelete extends ApiBase { } } if ( !$titleObj->exists() ) { - $this->dieUsageMsg( array( 'notanarticle' ) ); + $this->dieUsageMsg( 'notanarticle' ); } $reason = ( isset( $params['reason'] ) ? $params['reason'] : null ); diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 3536fdfedd..cda342939e 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -50,7 +50,7 @@ class ApiEditPage extends ApiBase { is_null( $params['prependtext'] ) && $params['undo'] == 0 ) { - $this->dieUsageMsg( array( 'missingtext' ) ); + $this->dieUsageMsg( 'missingtext' ); } $titleObj = Title::newFromText( $params['title'] ); @@ -93,10 +93,10 @@ class ApiEditPage extends ApiBase { $wgTitle = $titleObj; if ( $params['createonly'] && $titleObj->exists() ) { - $this->dieUsageMsg( array( 'createonly-exists' ) ); + $this->dieUsageMsg( 'createonly-exists' ); } if ( $params['nocreate'] && !$titleObj->exists() ) { - $this->dieUsageMsg( array( 'nocreate-missing' ) ); + $this->dieUsageMsg( 'nocreate-missing' ); } // Now let's check whether we're even allowed to do this @@ -164,7 +164,7 @@ class ApiEditPage extends ApiBase { $newtext = $articleObj->getUndoText( $undoRev, $undoafterRev ); if ( $newtext === false ) { - $this->dieUsageMsg( array( 'undo-failure' ) ); + $this->dieUsageMsg( 'undo-failure' ); } $params['text'] = $newtext; // If no summary was given and we only undid one rev, @@ -176,7 +176,7 @@ class ApiEditPage extends ApiBase { // See if the MD5 hash checks out if ( !is_null( $params['md5'] ) && md5( $toMD5 ) !== $params['md5'] ) { - $this->dieUsageMsg( array( 'hashcheckfailed' ) ); + $this->dieUsageMsg( 'hashcheckfailed' ); } $ep = new EditPage( $articleObj ); @@ -259,7 +259,7 @@ class ApiEditPage extends ApiBase { $this->getResult()->addValue( null, $this->getModuleName(), $r ); return; } else { - $this->dieUsageMsg( array( 'hookaborted' ) ); + $this->dieUsageMsg( 'hookaborted' ); } } @@ -278,54 +278,54 @@ class ApiEditPage extends ApiBase { switch( $retval ) { case EditPage::AS_HOOK_ERROR: case EditPage::AS_HOOK_ERROR_EXPECTED: - $this->dieUsageMsg( array( 'hookaborted' ) ); + $this->dieUsageMsg( 'hookaborted' ); case EditPage::AS_IMAGE_REDIRECT_ANON: - $this->dieUsageMsg( array( 'noimageredirect-anon' ) ); + $this->dieUsageMsg( 'noimageredirect-anon' ); case EditPage::AS_IMAGE_REDIRECT_LOGGED: - $this->dieUsageMsg( array( 'noimageredirect-logged' ) ); + $this->dieUsageMsg( 'noimageredirect-logged' ); case EditPage::AS_SPAM_ERROR: $this->dieUsageMsg( array( 'spamdetected', $result['spam'] ) ); case EditPage::AS_FILTERING: - $this->dieUsageMsg( array( 'filtered' ) ); + $this->dieUsageMsg( 'filtered' ); case EditPage::AS_BLOCKED_PAGE_FOR_USER: - $this->dieUsageMsg( array( 'blockedtext' ) ); + $this->dieUsageMsg( 'blockedtext' ); case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED: case EditPage::AS_CONTENT_TOO_BIG: $this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) ); case EditPage::AS_READ_ONLY_PAGE_ANON: - $this->dieUsageMsg( array( 'noedit-anon' ) ); + $this->dieUsageMsg( 'noedit-anon' ); case EditPage::AS_READ_ONLY_PAGE_LOGGED: - $this->dieUsageMsg( array( 'noedit' ) ); + $this->dieUsageMsg( 'noedit' ); case EditPage::AS_READ_ONLY_PAGE: $this->dieReadOnly(); case EditPage::AS_RATE_LIMITED: - $this->dieUsageMsg( array( 'actionthrottledtext' ) ); + $this->dieUsageMsg( 'actionthrottledtext' ); case EditPage::AS_ARTICLE_WAS_DELETED: - $this->dieUsageMsg( array( 'wasdeleted' ) ); + $this->dieUsageMsg( 'wasdeleted' ); case EditPage::AS_NO_CREATE_PERMISSION: - $this->dieUsageMsg( array( 'nocreate-loggedin' ) ); + $this->dieUsageMsg( 'nocreate-loggedin' ); case EditPage::AS_BLANK_ARTICLE: - $this->dieUsageMsg( array( 'blankpage' ) ); + $this->dieUsageMsg( 'blankpage' ); case EditPage::AS_CONFLICT_DETECTED: - $this->dieUsageMsg( array( 'editconflict' ) ); + $this->dieUsageMsg( 'editconflict' ); // case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary case EditPage::AS_TEXTBOX_EMPTY: - $this->dieUsageMsg( array( 'emptynewsection' ) ); + $this->dieUsageMsg( 'emptynewsection' ); case EditPage::AS_SUCCESS_NEW_ARTICLE: $r['new'] = ''; @@ -351,7 +351,7 @@ class ApiEditPage extends ApiBase { break; case EditPage::AS_SUMMARY_NEEDED: - $this->dieUsageMsg( array( 'summaryrequired' ) ); + $this->dieUsageMsg( 'summaryrequired' ); case EditPage::AS_END: // This usually means some kind of race condition diff --git a/includes/api/ApiFileRevert.php b/includes/api/ApiFileRevert.php index c89d7abd4d..371ef67833 100644 --- a/includes/api/ApiFileRevert.php +++ b/includes/api/ApiFileRevert.php @@ -101,14 +101,14 @@ class ApiFileRevert extends ApiBase { // Check if the file really exists $this->file = wfLocalFile( $title ); if ( !$this->file->exists() ) { - $this->dieUsageMsg( array( 'notanarticle' ) ); + $this->dieUsageMsg( 'notanarticle' ); } // Check if the archivename is valid for this file $this->archiveName = $this->params['archivename']; $oldFile = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $title, $this->archiveName ); if ( !$oldFile->exists() ) { - $this->dieUsageMsg( array( 'filerevert-badversion' ) ); + $this->dieUsageMsg( 'filerevert-badversion' ); } } diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php index f01035cc76..5c05daf321 100644 --- a/includes/api/ApiImport.php +++ b/includes/api/ApiImport.php @@ -48,7 +48,7 @@ class ApiImport extends ApiBase { $isUpload = false; if ( isset( $params['interwikisource'] ) ) { if ( !$wgUser->isAllowed( 'import' ) ) { - $this->dieUsageMsg( array( 'cantimport' ) ); + $this->dieUsageMsg( 'cantimport' ); } if ( !isset( $params['interwikipage'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'interwikipage' ) ); @@ -62,7 +62,7 @@ class ApiImport extends ApiBase { } else { $isUpload = true; if ( !$wgUser->isAllowed( 'importupload' ) ) { - $this->dieUsageMsg( array( 'cantimport-upload' ) ); + $this->dieUsageMsg( 'cantimport-upload' ); } $source = ImportStreamSource::newFromUpload( 'xml' ); } diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index cf06e5a567..a15faeefa8 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -568,7 +568,7 @@ class ApiMain extends ApiBase { } else { global $wgUser; if ( !$wgUser->matchEditToken( $moduleParams['token'], $salt, $this->getMain()->getRequest() ) ) { - $this->dieUsageMsg( array( 'sessionfailure' ) ); + $this->dieUsageMsg( 'sessionfailure' ); } } } @@ -611,14 +611,14 @@ class ApiMain extends ApiBase { if ( $module->isReadMode() && !in_array( 'read', User::getGroupPermissions( array( '*' ) ), true ) && !$wgUser->isAllowed( 'read' ) ) { - $this->dieUsageMsg( array( 'readrequired' ) ); + $this->dieUsageMsg( 'readrequired' ); } if ( $module->isWriteMode() ) { if ( !$this->mEnableWrite ) { - $this->dieUsageMsg( array( 'writedisabled' ) ); + $this->dieUsageMsg( 'writedisabled' ); } if ( !$wgUser->isAllowed( 'writeapi' ) ) { - $this->dieUsageMsg( array( 'writerequired' ) ); + $this->dieUsageMsg( 'writerequired' ); } if ( wfReadOnly() ) { $this->dieReadOnly(); diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 3132de6e09..85bd5ad17d 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -61,7 +61,7 @@ class ApiMove extends ApiBase { } if ( !$fromTitle->exists() ) { - $this->dieUsageMsg( array( 'notanarticle' ) ); + $this->dieUsageMsg( 'notanarticle' ); } $fromTalk = $fromTitle->getTalkPage(); @@ -76,9 +76,9 @@ class ApiMove extends ApiBase { && wfFindFile( $toTitle ) ) { if ( !$params['ignorewarnings'] && $wgUser->isAllowed( 'reupload-shared' ) ) { - $this->dieUsageMsg( array( 'sharedfile-exists' ) ); + $this->dieUsageMsg( 'sharedfile-exists' ); } elseif ( !$wgUser->isAllowed( 'reupload-shared' ) ) { - $this->dieUsageMsg( array( 'cantoverwrite-sharedfile' ) ); + $this->dieUsageMsg( 'cantoverwrite-sharedfile' ); } } diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 34c56d72b1..ccb7efe40f 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -73,10 +73,10 @@ class ApiProtect extends ApiBase { $protections[$p[0]] = ( $p[1] == 'all' ? '' : $p[1] ); if ( $titleObj->exists() && $p[0] == 'create' ) { - $this->dieUsageMsg( array( 'create-titleexists' ) ); + $this->dieUsageMsg( 'create-titleexists' ); } if ( !$titleObj->exists() && $p[0] != 'create' ) { - $this->dieUsageMsg( array( 'missingtitle-createonly' ) ); + $this->dieUsageMsg( 'missingtitle-createonly' ); } if ( !in_array( $p[0], $restrictionTypes ) && $p[0] != 'create' ) { diff --git a/includes/api/ApiQueryCategories.php b/includes/api/ApiQueryCategories.php index b65ea4bf06..f1440affbb 100644 --- a/includes/api/ApiQueryCategories.php +++ b/includes/api/ApiQueryCategories.php @@ -104,7 +104,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase { } if ( isset( $show['hidden'] ) && isset( $show['!hidden'] ) ) { - $this->dieUsageMsg( array( 'show' ) ); + $this->dieUsageMsg( 'show' ); } if ( isset( $show['hidden'] ) || isset( $show['!hidden'] ) || isset( $prop['hidden'] ) ) { diff --git a/includes/api/ApiQueryQueryPage.php b/includes/api/ApiQueryQueryPage.php index d6d3ebc1b7..5b379d92f2 100644 --- a/includes/api/ApiQueryQueryPage.php +++ b/includes/api/ApiQueryQueryPage.php @@ -82,7 +82,7 @@ class ApiQueryQueryPage extends ApiQueryGeneratorBase { $qp = new $this->qpMap[$params['page']](); if ( !$qp->userCanExecute( $wgUser ) ) { - $this->dieUsageMsg( array( 'specialpage-cantexecute' ) ); + $this->dieUsageMsg( 'specialpage-cantexecute' ); } $r = array( 'name' => $params['page'] ); diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index b00db352ff..896914fdb8 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -158,7 +158,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase { || ( isset( $show['redirect'] ) && isset( $show['!redirect'] ) ) || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) ) { - $this->dieUsageMsg( array( 'show' ) ); + $this->dieUsageMsg( 'show' ); } // Check permissions diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index 5c863f95d4..9e68b0f360 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -189,7 +189,7 @@ class ApiQueryContributions extends ApiQueryBase { $show = array_flip( $show ); if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) ) || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) ) { - $this->dieUsageMsg( array( 'show' ) ); + $this->dieUsageMsg( 'show' ); } $this->addWhereIf( 'rev_minor_edit = 0', isset( $show['!minor'] ) ); diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index fe0c180926..1aaa450fb8 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -147,7 +147,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { || ( isset ( $show['patrolled'] ) && isset ( $show['!patrolled'] ) ) ) { - $this->dieUsageMsg( array( 'show' ) ); + $this->dieUsageMsg( 'show' ); } // Check permissions. diff --git a/includes/api/ApiQueryWatchlistRaw.php b/includes/api/ApiQueryWatchlistRaw.php index fa76956a38..126f6d899c 100644 --- a/includes/api/ApiQueryWatchlistRaw.php +++ b/includes/api/ApiQueryWatchlistRaw.php @@ -63,7 +63,7 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { $prop = array_flip( (array)$params['prop'] ); $show = array_flip( (array)$params['show'] ); if ( isset( $show['changed'] ) && isset( $show['!changed'] ) ) { - $this->dieUsageMsg( array( 'show' ) ); + $this->dieUsageMsg( 'show' ); } $this->addTables( 'watchlist' ); @@ -207,4 +207,4 @@ class ApiQueryWatchlistRaw extends ApiQueryGeneratorBase { public function getVersion() { return __CLASS__ . ': $Id$'; } -} \ No newline at end of file +} diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index fee9622baf..e845df6633 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -178,7 +178,7 @@ class ApiRollback extends ApiBase { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } if ( !$this->mTitleObj->exists() ) { - $this->dieUsageMsg( array( 'notanarticle' ) ); + $this->dieUsageMsg( 'notanarticle' ); } return $this->mTitleObj; diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index bdafe135c5..6865787281 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -55,20 +55,20 @@ class ApiUnblock extends ApiBase { } if ( is_null( $params['id'] ) && is_null( $params['user'] ) ) { - $this->dieUsageMsg( array( 'unblock-notarget' ) ); + $this->dieUsageMsg( 'unblock-notarget' ); } if ( !is_null( $params['id'] ) && !is_null( $params['user'] ) ) { - $this->dieUsageMsg( array( 'unblock-idanduser' ) ); + $this->dieUsageMsg( 'unblock-idanduser' ); } if ( !$wgUser->isAllowed( 'block' ) ) { - $this->dieUsageMsg( array( 'cantunblock' ) ); + $this->dieUsageMsg( 'cantunblock' ); } # bug 15810: blocked admins should have limited access here if ( $wgUser->isBlocked() ) { $status = SpecialBlock::checkUnblockSelf( $params['user'] ); if ( $status !== true ) { - $this->dieUsageMsg( array( $status ) ); + $this->dieUsageMsg( $status ); } } diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index a027b7f0e0..615b224628 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -43,11 +43,11 @@ class ApiUndelete extends ApiBase { $params = $this->extractRequestParams(); if ( !$wgUser->isAllowed( 'undelete' ) ) { - $this->dieUsageMsg( array( 'permdenied-undelete' ) ); + $this->dieUsageMsg( 'permdenied-undelete' ); } if ( $wgUser->isBlocked() ) { - $this->dieUsageMsg( array( 'blockedtext' ) ); + $this->dieUsageMsg( 'blockedtext' ); } $titleObj = Title::newFromText( $params['title'] ); @@ -69,7 +69,7 @@ class ApiUndelete extends ApiBase { $pa = new PageArchive( $titleObj ); $retval = $pa->undelete( ( isset( $params['timestamps'] ) ? $params['timestamps'] : array() ), $params['reason'] ); if ( !is_array( $retval ) ) { - $this->dieUsageMsg( array( 'cannotundelete' ) ); + $this->dieUsageMsg( 'cannotundelete' ); } if ( $retval[1] ) { diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 46043a738f..5c39e2149e 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -50,7 +50,7 @@ class ApiUpload extends ApiBase { // Check whether upload is enabled if ( !UploadBase::isEnabled() ) { - $this->dieUsageMsg( array( 'uploaddisabled' ) ); + $this->dieUsageMsg( 'uploaddisabled' ); } // Parameter handling @@ -208,7 +208,7 @@ class ApiUpload extends ApiBase { // Upload stashed in a previous request $sessionData = $request->getSessionData( UploadBase::getSessionKeyName() ); if ( !UploadFromStash::isValidSessionKey( $this->mParams['sessionkey'], $sessionData ) ) { - $this->dieUsageMsg( array( 'invalid-session-key' ) ); + $this->dieUsageMsg( 'invalid-session-key' ); } $this->mUpload = new UploadFromStash(); @@ -225,7 +225,7 @@ class ApiUpload extends ApiBase { } elseif ( isset( $this->mParams['url'] ) ) { // Make sure upload by URL is enabled: if ( !UploadFromUrl::isEnabled() ) { - $this->dieUsageMsg( array( 'copyuploaddisabled' ) ); + $this->dieUsageMsg( 'copyuploaddisabled' ); } $async = false; @@ -265,7 +265,7 @@ class ApiUpload extends ApiBase { if ( !$user->isLoggedIn() ) { $this->dieUsageMsg( array( 'mustbeloggedin', 'upload' ) ); } else { - $this->dieUsageMsg( array( 'badaccess-groups' ) ); + $this->dieUsageMsg( 'badaccess-groups' ); } } } diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 685306dff3..7eb61689f2 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -66,7 +66,7 @@ class ApiWatch extends ApiBase { $success = Action::factory( 'watch', $article )->execute(); } if ( !$success ) { - $this->dieUsageMsg( array( 'hookaborted' ) ); + $this->dieUsageMsg( 'hookaborted' ); } $this->getResult()->addValue( null, $this->getModuleName(), $res ); }