X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=blobdiff_plain;f=includes%2Fapi%2FApiFileRevert.php;h=83d078d2af86b4ae5601ddad37653d53b1c61693;hb=29719f846b8887e1190ddf85125387c079f9539b;hp=08a9c8e58c467fefeaf0db3ef688ad0e0dd56075;hpb=176119237607de5ed6659296b08209270b26b84a;p=lhc%2Fweb%2Fwiklou.git 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' ); }