X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiRollback.php;h=55f714371957bc2347e46da4c869e483108b5ec8;hb=953932c621f24efc06760c430fdbadce21e8767b;hp=7037fb619acfa7d2fe9cab48cf973e9e5f52cbb4;hpb=a8247aba334928ac125c641cef6cdf5bb4f3ca4a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index 7037fb619a..55f7143719 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -58,7 +58,7 @@ class ApiRollback extends ApiBase { $titleObj = $this->getRbTitle( $params ); $pageObj = WikiPage::factory( $titleObj ); $summary = $params['summary']; - $details = array(); + $details = []; // If change tagging was requested, check that the user is allowed to tag, // and the tags are valid @@ -75,7 +75,8 @@ class ApiRollback extends ApiBase { $token, $params['markbot'], $details, - $user + $user, + $params['tags'] ); if ( $retval ) { @@ -91,18 +92,14 @@ class ApiRollback extends ApiBase { // Watch pages $this->setWatch( $watch, $titleObj, 'watchrollback' ); - if ( count( $params['tags'] ) ) { - ChangeTags::addTags( $params['tags'], null, intval( $details['newid'] ), null, null ); - } - - $info = array( + $info = [ 'title' => $titleObj->getPrefixedText(), 'pageid' => intval( $details['current']->getPage() ), 'summary' => $details['summary'], 'revid' => intval( $details['newid'] ), 'old_revid' => intval( $details['current']->getID() ), 'last_revid' => intval( $details['target']->getID() ) - ); + ]; $this->getResult()->addValue( null, $this->getModuleName(), $info ); } @@ -116,35 +113,35 @@ class ApiRollback extends ApiBase { } public function getAllowedParams() { - return array( + return [ 'title' => null, - 'pageid' => array( + 'pageid' => [ ApiBase::PARAM_TYPE => 'integer' - ), - 'tags' => array( - ApiBase::PARAM_TYPE => ChangeTags::listExplicitlyDefinedTags(), + ], + 'tags' => [ + ApiBase::PARAM_TYPE => 'tags', ApiBase::PARAM_ISMULTI => true, - ), - 'user' => array( - ApiBase::PARAM_TYPE => 'string', + ], + 'user' => [ + ApiBase::PARAM_TYPE => 'user', ApiBase::PARAM_REQUIRED => true - ), + ], 'summary' => '', 'markbot' => false, - 'watchlist' => array( + 'watchlist' => [ ApiBase::PARAM_DFLT => 'preferences', - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'watch', 'unwatch', 'preferences', 'nochange' - ), - ), - 'token' => array( + ], + ], + 'token' => [ // Standard definition automatically inserted - ApiBase::PARAM_HELP_MSG_APPEND => array( 'api-help-param-token-webui' ), - ), - ); + ApiBase::PARAM_HELP_MSG_APPEND => [ 'api-help-param-token-webui' ], + ], + ]; } public function needsToken() { @@ -152,10 +149,10 @@ class ApiRollback extends ApiBase { } protected function getWebUITokenSalt( array $params ) { - return array( + return [ $this->getRbTitle( $params )->getPrefixedText(), $this->getRbUser( $params ) - ); + ]; } /** @@ -173,7 +170,7 @@ class ApiRollback extends ApiBase { ? $params['user'] : User::getCanonicalName( $params['user'] ); if ( !$this->mUser ) { - $this->dieUsageMsg( array( 'invaliduser', $params['user'] ) ); + $this->dieUsageMsg( [ 'invaliduser', $params['user'] ] ); } return $this->mUser; @@ -194,12 +191,12 @@ class ApiRollback extends ApiBase { if ( isset( $params['title'] ) ) { $this->mTitleObj = Title::newFromText( $params['title'] ); if ( !$this->mTitleObj || $this->mTitleObj->isExternal() ) { - $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); + $this->dieUsageMsg( [ 'invalidtitle', $params['title'] ] ); } } elseif ( isset( $params['pageid'] ) ) { $this->mTitleObj = Title::newFromID( $params['pageid'] ); if ( !$this->mTitleObj ) { - $this->dieUsageMsg( array( 'nosuchpageid', $params['pageid'] ) ); + $this->dieUsageMsg( [ 'nosuchpageid', $params['pageid'] ] ); } } @@ -211,13 +208,13 @@ class ApiRollback extends ApiBase { } protected function getExamplesMessages() { - return array( + return [ 'action=rollback&title=Main%20Page&user=Example&token=123ABC' => 'apihelp-rollback-example-simple', 'action=rollback&title=Main%20Page&user=192.0.2.5&' . 'token=123ABC&summary=Reverting%20vandalism&markbot=1' => 'apihelp-rollback-example-summary', - ); + ]; } public function getHelpUrls() {