Merge "(bug 43661) Added test for special link trail case"
[lhc/web/wiklou.git] / includes / upload / UploadBase.php
index fdd5f65..48ea584 100644 (file)
@@ -235,6 +235,14 @@ abstract class UploadBase {
                return $this->mFileSize;
        }
 
+       /**
+        * Get the base 36 SHA1 of the file
+        * @return string
+        */
+       protected function getTempFileSha1Base36() {
+               return FSFile::getSha1Base36FromPath( $this->mTempPath );
+       }
+
        /**
         * @param $srcPath String: the source path
         * @return string the real path if it was a virtual URL
@@ -546,7 +554,9 @@ abstract class UploadBase {
        }
 
        /**
-        * Check for non fatal problems with the file
+        * Check for non fatal problems with the file.
+        *
+        * This should not assume that mTempPath is set.
         *
         * @return Array of warnings
         */
@@ -581,7 +591,7 @@ abstract class UploadBase {
 
                global $wgUploadSizeWarning;
                if ( $wgUploadSizeWarning && ( $this->mFileSize > $wgUploadSizeWarning ) ) {
-                       $warnings['large-file'] = $wgUploadSizeWarning;
+                       $warnings['large-file'] = array( $wgUploadSizeWarning, $this->mFileSize );
                }
 
                if ( $this->mFileSize == 0 ) {
@@ -594,7 +604,7 @@ abstract class UploadBase {
                }
 
                // Check dupes against existing files
-               $hash = FSFile::getSha1Base36FromPath( $this->mTempPath );
+               $hash = $this->getTempFileSha1Base36();
                $dupes = RepoGroup::singleton()->findBySha1( $hash );
                $title = $this->getTitle();
                // Remove all matches against self