// the old filekey and fetch the new one.
UploadBase::setSessionStatus( $this->getUser(), $filekey, false );
$this->mUpload->stash->removeFile( $filekey );
- $filekey = $this->mUpload->getLocalFile()->getFileKey();
+ $filekey = $this->mUpload->getStashFile()->getFileKey();
$result['result'] = 'Success';
}
$this->mParams['text'] = $this->mParams['comment'];
}
- /** @var $file File */
+ /** @var $file LocalFile */
$file = $this->mUpload->getLocalFile();
// For preferences mode, we want to watch if 'watchdefault' is set,
protected $mDesiredDestName, $mDestName, $mRemoveTempFile, $mSourceType;
protected $mTitle = false, $mTitleError = 0;
protected $mFilteredName, $mFinalExtension;
- protected $mLocalFile, $mFileSize, $mFileProps;
+ protected $mLocalFile, $mStashFile, $mFileSize, $mFileProps;
protected $mBlackListedExtensions;
protected $mJavaDetected, $mSVGNSError;
/**
* Return the local file and initializes if necessary.
*
- * @return LocalFile|UploadStashFile|null
+ * @return LocalFile|null
*/
public function getLocalFile() {
if ( is_null( $this->mLocalFile ) ) {
return $this->mLocalFile;
}
+ /**
+ * @return UploadStashFile|null
+ */
+ public function getStashFile() {
+ return $this->mStashFile;
+ }
+
/**
* Like stashFile(), but respects extensions' wishes to prevent the stashing. verifyUpload() must
* be called before calling this method (unless $isPartial is true).
protected function doStashFile( User $user = null ) {
$stash = RepoGroup::singleton()->getLocalRepo()->getUploadStash( $user );
$file = $stash->stashFile( $this->mTempPath, $this->getSourceType() );
- $this->mLocalFile = $file;
+ $this->mStashFile = $file;
return $file;
}
* @return array Image info
*/
public function getImageInfo( $result ) {
- $file = $this->getLocalFile();
- /** @todo This cries out for refactoring.
- * We really want to say $file->getAllInfo(); here.
- * Perhaps "info" methods should be moved into files, and the API should
- * just wrap them in queries.
- */
- if ( $file instanceof UploadStashFile ) {
+ $localFile = $this->getLocalFile();
+ $stashFile = $this->getStashFile();
+ // Calling a different API module depending on whether the file was stashed is less than optimal.
+ // In fact, calling API modules here at all is less than optimal. Maybe it should be refactored.
+ if ( $stashFile ) {
$imParam = ApiQueryStashImageInfo::getPropertyNames();
- $info = ApiQueryStashImageInfo::getInfo( $file, array_flip( $imParam ), $result );
+ $info = ApiQueryStashImageInfo::getInfo( $stashFile, array_flip( $imParam ), $result );
} else {
$imParam = ApiQueryImageInfo::getPropertyNames();
- $info = ApiQueryImageInfo::getInfo( $file, array_flip( $imParam ), $result );
+ $info = ApiQueryImageInfo::getInfo( $localFile, array_flip( $imParam ), $result );
}
return $info;
$this->verifyChunk();
// Create a local stash target
- $this->mLocalFile = parent::doStashFile( $user );
+ $this->mStashFile = parent::doStashFile( $user );
// Update the initial file offset (based on file size)
- $this->mOffset = $this->mLocalFile->getSize();
- $this->mFileKey = $this->mLocalFile->getFileKey();
+ $this->mOffset = $this->mStashFile->getSize();
+ $this->mFileKey = $this->mStashFile->getFileKey();
// Output a copy of this first to chunk 0 location:
- $this->outputChunk( $this->mLocalFile->getPath() );
+ $this->outputChunk( $this->mStashFile->getPath() );
// Update db table to reflect initial "chunk" state
$this->updateChunkStatus();
- return $this->mLocalFile;
+ return $this->mStashFile;
}
/**
return $status;
}
- // Update the mTempPath and mLocalFile
+ // Update the mTempPath and mStashFile
// (for FileUpload or normal Stash to take over)
$tStart = microtime( true );
// This is a re-implementation of UploadBase::tryStashFile(), we can't call it because we
return $status;
}
try {
- $this->mLocalFile = parent::doStashFile( $this->user );
+ $this->mStashFile = parent::doStashFile( $this->user );
} catch ( UploadStashException $e ) {
$status->fatal( 'uploadstash-exception', get_class( $e ), $e->getMessage() );
return $status;
}
$tAmount = microtime( true ) - $tStart;
- $this->mLocalFile->setLocalReference( $tmpFile ); // reuse (e.g. for getImageInfo())
+ $this->mStashFile->setLocalReference( $tmpFile ); // reuse (e.g. for getImageInfo())
wfDebugLog( 'fileconcatenate', "Stashed combined file ($i chunks) in $tAmount seconds." );
return $status;