Re-establishing validation feature (the beginnings)
[lhc/web/wiklou.git] / includes / SpecialUpload.php
index 9aa57b8..3045f79 100644 (file)
@@ -270,6 +270,10 @@ class UploadForm {
                                        $this->mUploadDescription,
                                        $this->mUploadCopyStatus,
                                        $this->mUploadSource );
+
+                       /* refresh image metadata cache */
+                       new Image( $this->mUploadSaveName, true );
+
                        $this->showSuccess();
                }
        }
@@ -295,8 +299,11 @@ class UploadForm {
 
                if( is_file( $this->mSavedFile ) ) {
                        $this->mUploadOldVersion = gmdate( 'YmdHis' ) . "!{$saveName}";
+                       wfSuppressWarnings();
+                       $success = rename( $this->mSavedFile, "${archive}/{$this->mUploadOldVersion}" );
+                       wfRestoreWarnings();
 
-                       if( !rename( $this->mSavedFile, "${archive}/{$this->mUploadOldVersion}" ) ) { 
+                       if( ! $success ) { 
                                $wgOut->fileRenameError( $this->mSavedFile,
                                  "${archive}/{$this->mUploadOldVersion}" );
                                return false;
@@ -306,12 +313,20 @@ class UploadForm {
                }
                
                if( $useRename ) {
-                       if( !rename( $tempName, $this->mSavedFile ) ) {
+                       wfSuppressWarnings();
+                       $success = rename( $tempName, $this->mSavedFile );
+                       wfRestoreWarnings();
+
+                       if( ! $success ) ) {
                                $wgOut->fileCopyError( $tempName, $this->mSavedFile );
                                return false;
                        }
                } else {
-                       if( !move_uploaded_file( $tempName, $this->mSavedFile ) ) {
+                       wfSuppressWarnings();
+                       $success = move_uploaded_file( $tempName, $this->mSavedFile );
+                       wfRestoreWarnings();
+
+                       if( ! $success ) {
                                $wgOut->fileCopyError( $tempName, $this->mSavedFile );
                                return false;
                        }
@@ -333,8 +348,7 @@ class UploadForm {
         * @access private
         */
        function saveTempUploadedFile( $saveName, $tempName ) {
-               global $wgOut;
-
+               global $wgOut;          
                $archive = wfImageArchiveDir( $saveName, 'temp' );
                $stash = $archive . '/' . gmdate( "YmdHis" ) . '!' . $saveName;
 
@@ -355,7 +369,7 @@ class UploadForm {
         * @return int
         * @access private
         */
-       function stashSession() {
+       function stashSession() {               
                $stash = $this->saveTempUploadedFile(
                        $this->mUploadSaveName, $this->mUploadTempName );
 
@@ -377,7 +391,10 @@ class UploadForm {
         * @access private
         */
        function unsaveUploadedFile() {
-               if ( ! @unlink( $this->mUploadTempName ) ) {
+               wfSuppressWarnings();
+               $success = unlink( $this->mUploadTempName );
+               wfRestoreWarnings();
+               if ( ! $success ) {
                        $wgOut->fileDeleteError( $this->mUploadTempName );
                }
        }
@@ -637,7 +654,9 @@ class UploadForm {
                        return true;
                }
                
-               $data = @getimagesize( $tmpfile );
+               wfSuppressWarnings();
+               $data = getimagesize( $tmpfile );
+               wfRestoreWarnings();
                if( false === $data ) {
                        # Didn't recognize the image type.
                        # Either the image is corrupt or someone's slipping us some