summaryrefslogtreecommitdiff
path: root/includes/api/ApiRollback.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
commit222b01f5169f1c7e69762e0e8904c24f78f71882 (patch)
tree8e932e12546bb991357ec48eb1638d1770be7a35 /includes/api/ApiRollback.php
parent00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff)
update to MediaWiki 1.16.0
Diffstat (limited to 'includes/api/ApiRollback.php')
-rw-r--r--includes/api/ApiRollback.php76
1 files changed, 42 insertions, 34 deletions
diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php
index 0f0eae10..5c259f4e 100644
--- a/includes/api/ApiRollback.php
+++ b/includes/api/ApiRollback.php
@@ -22,9 +22,9 @@
* http://www.gnu.org/copyleft/gpl.html
*/
-if (!defined('MEDIAWIKI')) {
+if ( !defined( 'MEDIAWIKI' ) ) {
// Eclipse helper - will be ignored in production
- require_once ("ApiBase.php");
+ require_once ( "ApiBase.php" );
}
/**
@@ -32,53 +32,51 @@ if (!defined('MEDIAWIKI')) {
*/
class ApiRollback extends ApiBase {
- public function __construct($main, $action) {
- parent :: __construct($main, $action);
+ public function __construct( $main, $action ) {
+ parent :: __construct( $main, $action );
}
public function execute() {
$params = $this->extractRequestParams();
- $titleObj = NULL;
- if(!isset($params['title']))
- $this->dieUsageMsg(array('missingparam', 'title'));
- if(!isset($params['user']))
- $this->dieUsageMsg(array('missingparam', 'user'));
- if(!isset($params['token']))
- $this->dieUsageMsg(array('missingparam', 'token'));
-
- $titleObj = Title::newFromText($params['title']);
- if(!$titleObj)
- $this->dieUsageMsg(array('invalidtitle', $params['title']));
- if(!$titleObj->exists())
- $this->dieUsageMsg(array('notanarticle'));
-
- #We need to be able to revert IPs, but getCanonicalName rejects them
- $username = User::isIP($params['user'])
+ $titleObj = null;
+ if ( !isset( $params['title'] ) )
+ $this->dieUsageMsg( array( 'missingparam', 'title' ) );
+ if ( !isset( $params['user'] ) )
+ $this->dieUsageMsg( array( 'missingparam', 'user' ) );
+
+ $titleObj = Title::newFromText( $params['title'] );
+ if ( !$titleObj )
+ $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
+ if ( !$titleObj->exists() )
+ $this->dieUsageMsg( array( 'notanarticle' ) );
+
+ // We need to be able to revert IPs, but getCanonicalName rejects them
+ $username = User::isIP( $params['user'] )
? $params['user']
- : User::getCanonicalName($params['user']);
- if(!$username)
- $this->dieUsageMsg(array('invaliduser', $params['user']));
+ : User::getCanonicalName( $params['user'] );
+ if ( !$username )
+ $this->dieUsageMsg( array( 'invaliduser', $params['user'] ) );
- $articleObj = new Article($titleObj);
- $summary = (isset($params['summary']) ? $params['summary'] : "");
+ $articleObj = new Article( $titleObj );
+ $summary = ( isset( $params['summary'] ) ? $params['summary'] : "" );
$details = null;
- $retval = $articleObj->doRollback($username, $summary, $params['token'], $params['markbot'], $details);
+ $retval = $articleObj->doRollback( $username, $summary, $params['token'], $params['markbot'], $details );
- if($retval)
+ if ( $retval )
// We don't care about multiple errors, just report one of them
- $this->dieUsageMsg(reset($retval));
+ $this->dieUsageMsg( reset( $retval ) );
$info = array(
'title' => $titleObj->getPrefixedText(),
- 'pageid' => intval($details['current']->getPage()),
+ 'pageid' => intval( $details['current']->getPage() ),
'summary' => $details['summary'],
- 'revid' => intval($titleObj->getLatestRevID()),
- 'old_revid' => intval($details['current']->getID()),
- 'last_revid' => intval($details['target']->getID())
+ 'revid' => intval( $details['newid'] ),
+ 'old_revid' => intval( $details['current']->getID() ),
+ 'last_revid' => intval( $details['target']->getID() )
);
- $this->getResult()->addValue(null, $this->getModuleName(), $info);
+ $this->getResult()->addValue( null, $this->getModuleName(), $info );
}
public function mustBePosted() { return true; }
@@ -113,6 +111,16 @@ class ApiRollback extends ApiBase {
'they will all be rolled back.'
);
}
+
+ public function getPossibleErrors() {
+ return array_merge( parent::getPossibleErrors(), array(
+ array( 'missingparam', 'title' ),
+ array( 'missingparam', 'user' ),
+ array( 'invalidtitle', 'title' ),
+ array( 'notanarticle' ),
+ array( 'invaliduser', 'user' ),
+ ) );
+ }
protected function getExamples() {
return array (
@@ -122,6 +130,6 @@ class ApiRollback extends ApiBase {
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiRollback.php 48122 2009-03-07 12:58:41Z catrope $';
+ return __CLASS__ . ': $Id: ApiRollback.php 65371 2010-04-21 10:41:25Z tstarling $';
}
}