Merge "Various fixes for EnhancedChangesList"
[lhc/web/wiklou.git] / includes / upload / UploadBase.php
index 17d8895..4c8148a 100644 (file)
@@ -31,8 +31,6 @@
  * UploadBase and subclasses are the backend of MediaWiki's file uploads.
  * The frontends are formed by ApiUpload and SpecialUpload.
  *
- * See also includes/docs/upload.txt
- *
  * @author Brion Vibber
  * @author Bryan Tong Minh
  * @author Michael Dale
@@ -322,8 +320,8 @@ abstract class UploadBase {
 
                $error = '';
                if ( !wfRunHooks( 'UploadVerification',
-                       array( $this->mDestName, $this->mTempPath, &$error ) ) )
-               {
+                       array( $this->mDestName, $this->mTempPath, &$error ) )
+               {
                        wfProfileOut( __METHOD__ );
                        return array( 'status' => self::HOOK_ABORTED, 'error' => $error );
                }
@@ -657,7 +655,11 @@ abstract class UploadBase {
                // Check dupes against archives
                $archivedImage = new ArchivedFile( null, 0, "{$hash}.{$this->mFinalExtension}" );
                if ( $archivedImage->getID() > 0 ) {
-                       $warnings['duplicate-archive'] = $archivedImage->getName();
+                       if ( $archivedImage->userCan( File::DELETED_FILE ) ) {
+                               $warnings['duplicate-archive'] = $archivedImage->getName();
+                       } else {
+                               $warnings['duplicate-archive'] = '';
+                       }
                }
 
                wfProfileOut( __METHOD__ );
@@ -723,7 +725,8 @@ abstract class UploadBase {
                # exclamation mark, so restrict file name to 240 bytes.
                if ( strlen( $this->mFilteredName ) > 240 ) {
                        $this->mTitleError = self::FILENAME_TOO_LONG;
-                       return $this->mTitle = null;
+                       $this->mTitle = null;
+                       return $this->mTitle;
                }
 
                /**
@@ -736,7 +739,8 @@ abstract class UploadBase {
                $nt = Title::makeTitleSafe( NS_FILE, $this->mFilteredName );
                if ( is_null( $nt ) ) {
                        $this->mTitleError = self::ILLEGAL_FILENAME;
-                       return $this->mTitle = null;
+                       $this->mTitle = null;
+                       return $this->mTitle;
                }
                $this->mFilteredName = $nt->getDBkey();
 
@@ -777,19 +781,22 @@ abstract class UploadBase {
 
                if ( $this->mFinalExtension == '' ) {
                        $this->mTitleError = self::FILETYPE_MISSING;
-                       return $this->mTitle = null;
+                       $this->mTitle = null;
+                       return $this->mTitle;
                } elseif ( $blackListedExtensions ||
                                ( $wgCheckFileExtensions && $wgStrictFileExtensions &&
                                        !$this->checkFileExtensionList( $ext, $wgFileExtensions ) ) ) {
                        $this->mBlackListedExtensions = $blackListedExtensions;
                        $this->mTitleError = self::FILETYPE_BADTYPE;
-                       return $this->mTitle = null;
+                       $this->mTitle = null;
+                       return $this->mTitle;
                }
 
                // Windows may be broken with special characters, see bug XXX
                if ( wfIsWindows() && !preg_match( '/^[\x0-\x7f]*$/', $nt->getText() ) ) {
                        $this->mTitleError = self::WINDOWS_NONASCII_FILENAME;
-                       return $this->mTitle = null;
+                       $this->mTitle = null;
+                       return $this->mTitle;
                }
 
                # If there was more than one "extension", reassemble the base
@@ -802,10 +809,12 @@ abstract class UploadBase {
 
                if ( strlen( $partname ) < 1 ) {
                        $this->mTitleError = self::MIN_LENGTH_PARTNAME;
-                       return $this->mTitle = null;
+                       $this->mTitle = null;
+                       return $this->mTitle;
                }
 
-               return $this->mTitle = $nt;
+               $this->mTitle = $nt;
+               return $this->mTitle;
        }
 
        /**