'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" ),
* @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 ) {
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' );
}