$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 ) );
}
}
* 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 );
if ( !$this->recordUpload2( $archive, $comment, $pageText, $props, $timestamp ) ) {
return new WikiErrorMsg( 'filenotfound', wfEscapeWikiText( $srcPath ) );
}
- return true;
+ return $archive;
}
/**