r23546 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23545‎ | r23546 | r23547 >
Date:08:56, 29 June 2007
Author:tstarling
Status:old
Tags:
Comment:
Restore MW 1.4 behaviour for Special:Upload -- redirect to description page on new upload, show success on reupload.
Modified paths:
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/filerepo/LocalFile.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/LocalFile.php
@@ -607,7 +607,8 @@
608608 * is already known
609609 * @param string $timestamp Timestamp for img_timestamp, or false to use the current time
610610 *
611 - * @return Wikitext-formatted WikiError or true on success
 611+ * @return Returns the archive name on success or an empty string if it was a new upload.
 612+ * Returns a wikitext-formatted WikiError on failure.
612613 */
613614 function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false, $timestamp = false ) {
614615 $archive = $this->publish( $srcPath, $flags );
@@ -617,7 +618,7 @@
618619 if ( !$this->recordUpload2( $archive, $comment, $pageText, $props, $timestamp ) ) {
619620 return new WikiErrorMsg( 'filenotfound', wfEscapeWikiText( $srcPath ) );
620621 }
621 - return true;
 622+ return $archive;
622623 }
623624
624625 /**
Index: trunk/phase3/includes/SpecialUpload.php
@@ -510,16 +510,22 @@
511511 $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
512512 $this->mCopyrightStatus, $this->mCopyrightSource );
513513
514 - $error = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText,
 514+ $status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText,
515515 File::DELETE_SOURCE, $this->mFileProps );
516 - if ( WikiError::isError( $error ) ) {
517 - $this->showError( $error );
 516+ if ( WikiError::isError( $status ) ) {
 517+ $this->showError( $status );
518518 } else {
519519 if ( $this->mWatchthis ) {
520520 global $wgUser;
521521 $wgUser->addWatch( $this->mLocalFile->getTitle() );
522522 }
523 - $this->showSuccess();
 523+ if ( $status === '' ) {
 524+ // New upload, redirect to description page
 525+ $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
 526+ } else {
 527+ // Reupload, show success page
 528+ $this->showSuccess();
 529+ }
524530 wfRunHooks( 'UploadComplete', array( &$img ) );
525531 }
526532 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r23581Merged revisions 23406-23580 via svnmerge from...david04:50, 30 June 2007

Status & tagging log