From d0ccdd920308671de59fd0d1e0c4691259c07489 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 29 Jun 2007 08:56:30 +0000 Subject: [PATCH] Restore MW 1.4 behaviour for Special:Upload -- redirect to description page on new upload, show success on reupload. --- includes/SpecialUpload.php | 14 ++++++++++---- includes/filerepo/LocalFile.php | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 703b80d26c..a8495f5fa2 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -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 ) ); } } diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 28567f511b..1f796e5d5c 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -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; } /** -- 2.20.1