summaryrefslogtreecommitdiff
path: root/includes/api/ApiFileRevert.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /includes/api/ApiFileRevert.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'includes/api/ApiFileRevert.php')
-rw-r--r--includes/api/ApiFileRevert.php38
1 files changed, 29 insertions, 9 deletions
diff --git a/includes/api/ApiFileRevert.php b/includes/api/ApiFileRevert.php
index 7ef1da0a..83d078d2 100644
--- a/includes/api/ApiFileRevert.php
+++ b/includes/api/ApiFileRevert.php
@@ -71,9 +71,10 @@ class ApiFileRevert extends ApiBase {
* @param $user User The user to check.
*/
protected function checkPermissions( $user ) {
+ $title = $this->file->getTitle();
$permissionErrors = array_merge(
- $this->file->getTitle()->getUserPermissionsErrors( 'edit' , $user ),
- $this->file->getTitle()->getUserPermissionsErrors( 'upload' , $user )
+ $title->getUserPermissionsErrors( 'edit' , $user ),
+ $title->getUserPermissionsErrors( 'upload' , $user )
);
if ( $permissionErrors ) {
@@ -91,15 +92,17 @@ class ApiFileRevert extends ApiBase {
if ( is_null( $title ) ) {
$this->dieUsageMsg( array( 'invalidtitle', $this->params['filename'] ) );
}
+ $localRepo = RepoGroup::singleton()->getLocalRepo();
+
// Check if the file really exists
- $this->file = wfLocalFile( $title );
+ $this->file = $localRepo->newFile( $title );
if ( !$this->file->exists() ) {
$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 );
+ $oldFile = $localRepo->newFromArchiveName( $title, $this->archiveName );
if ( !$oldFile->exists() ) {
$this->dieUsageMsg( 'filerevert-badversion' );
}
@@ -126,21 +129,38 @@ class ApiFileRevert extends ApiBase {
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true,
),
- 'token' => null,
+ 'token' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true
+ ),
);
}
public function getParamDescription() {
- $params = array(
- 'filename' => 'Target filename',
+ return array(
+ 'filename' => 'Target filename without the File: prefix',
'token' => 'Edit token. You can get one of these through prop=info',
'comment' => 'Upload comment',
'archivename' => 'Archive name of the revision to revert to',
);
+ }
- return $params;
-
+ public function getResultProperties() {
+ return array(
+ '' => array(
+ 'result' => array(
+ ApiBase::PROP_TYPE => array(
+ 'Success',
+ 'Failure'
+ )
+ ),
+ 'errors' => array(
+ ApiBase::PROP_TYPE => 'string',
+ ApiBase::PROP_NULLABLE => true
+ )
+ )
+ );
}
public function getDescription() {