From: umherirrender Date: Sat, 4 Aug 2012 13:40:36 +0000 (+0200) Subject: unknown error 'filerevert-badversion' X-Git-Tag: 1.31.0-rc.0~22848^2 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=c5d36b5b180738c03b233c2f8ed032efff644db1;p=lhc%2Fweb%2Fwiklou.git unknown error 'filerevert-badversion' Adding 'filerevert-badversion' to message map use some local vars in ApiFileRevert Change-Id: I2341f3f212af484d446a7a84c1b5c7984597468d --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 77e1356a11..38f6bc13b3 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -1318,6 +1318,7 @@ abstract class ApiBase extends ContextSource { 'nodeleteablefile' => array( 'code' => 'nodeleteablefile', 'info' => 'No such old version of the file' ), 'fileexists-forbidden' => array( 'code' => 'fileexists-forbidden', 'info' => 'A file with name "$1" already exists, and cannot be overwritten.' ), 'fileexists-shared-forbidden' => array( 'code' => 'fileexists-shared-forbidden', 'info' => 'A file with name "$1" already exists in the shared file repository, and cannot be overwritten.' ), + 'filerevert-badversion' => array( 'code' => 'filerevert-badversion', 'info' => 'There is no previous local version of this file with the provided timestamp.' ), // ApiEditPage messages 'noimageredirect-anon' => array( 'code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects" ), diff --git a/includes/api/ApiFileRevert.php b/includes/api/ApiFileRevert.php index 08a9c8e58c..83d078d2af 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' ); }