From b8184fde44a6715e7b76997e1bc4d9c730395637 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Sat, 19 Sep 2009 09:01:37 +0000 Subject: [PATCH] Fix overwrite permission checking for users without reupload-shared right. --- includes/upload/UploadBase.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index dbbf1e1fad..76101075a4 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -915,14 +915,18 @@ abstract class UploadBase { global $wgUser; // First check whether the local file can be overwritten $file = $this->getLocalFile(); - if( $file->exists() ) + if( $file->exists() ) { if( !self::userCanReUpload( $wgUser, $file ) ) return 'fileexists-forbidden'; + else + return true; + } - // Check shared conflicts - $file = wfFindFile( $file->getName() ); - if ( $file && ( !$wgUser->isAllowed( 'reupload' ) || - !$wgUser->isAllowed( 'reupload-shared' ) ) ) + /* Check shared conflicts: if the local file does not exist, but + * wfFindFile finds a file, it exists in a shared repository. + */ + $file = wfFindFile( $this->getTitle() ); + if ( $file && !$wgUser->isAllowed( 'reupload-shared' ) ) return 'fileexists-shared-forbidden'; return true; -- 2.20.1