Fix overwrite permission checking for users without reupload-shared right.
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 19 Sep 2009 09:01:37 +0000 (09:01 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Sat, 19 Sep 2009 09:01:37 +0000 (09:01 +0000)
includes/upload/UploadBase.php

index dbbf1e1..7610107 100644 (file)
@@ -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;