Restore MW 1.4 behaviour for Special:Upload -- redirect to description page on new...
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 29 Jun 2007 08:56:30 +0000 (08:56 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 29 Jun 2007 08:56:30 +0000 (08:56 +0000)
includes/SpecialUpload.php
includes/filerepo/LocalFile.php

index 703b80d..a8495f5 100644 (file)
@@ -510,16 +510,22 @@ class UploadForm {
                $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
                        $this->mCopyrightStatus, $this->mCopyrightSource );
 
-               $error = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText, 
+               $status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText, 
                        File::DELETE_SOURCE, $this->mFileProps );
-               if ( WikiError::isError( $error ) ) {
-                       $this->showError( $error );
+               if ( WikiError::isError( $status ) ) {
+                       $this->showError( $status );
                } else {
                        if ( $this->mWatchthis ) {
                                global $wgUser;
                                $wgUser->addWatch( $this->mLocalFile->getTitle() );
                        }
-                       $this->showSuccess();
+                       if ( $status === '' ) {
+                               // New upload, redirect to description page
+                               $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
+                       } else {
+                               // Reupload, show success page
+                               $this->showSuccess();
+                       }
                        wfRunHooks( 'UploadComplete', array( &$img ) );
                }
        }
index 28567f5..1f796e5 100644 (file)
@@ -607,7 +607,8 @@ class LocalFile extends File
         *                         is already known
         * @param string $timestamp Timestamp for img_timestamp, or false to use the current time
         *
-        * @return Wikitext-formatted WikiError or true on success
+        * @return Returns the archive name on success or an empty string if it was a new upload. 
+        *      Returns a wikitext-formatted WikiError on failure. 
         */
        function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false, $timestamp = false ) {
                $archive = $this->publish( $srcPath, $flags );
@@ -617,7 +618,7 @@ class LocalFile extends File
                if ( !$this->recordUpload2( $archive, $comment, $pageText, $props, $timestamp ) ) {
                        return new WikiErrorMsg( 'filenotfound', wfEscapeWikiText( $srcPath ) );
                }
-               return true;
+               return $archive;
        }
 
        /**