if ( $this->mParams['enablechunks'] ) {
$this->mUpload = new UploadFromChunks();
$this->mUpload->initialize(
- $request->getText( 'done' ),
- $request->getText( 'filename' ),
- $request->getText( 'chunksessionkey' ),
+ $request->getVal( 'done', null ),
+ $request->getVal( 'filename', null ),
+ $request->getVal( 'chunksessionkey', null ),
$request->getFileTempName( 'chunk' ),
$request->getFileSize( 'chunk' ),
$request->getSessionData( 'wsUploadData' )
if ( !isset( $this->mUpload ) )
$this->dieUsage( 'No upload module set', 'nomodule' );
-
- // Finish up the exec command:
- $this->doExecUpload();
- }
-
- protected function doExecUpload() {
- global $wgUser;
// Check whether the user has the appropriate permissions to upload anyway
$permission = $this->mUpload->isAllowed( $wgUser );
}
// Perform the upload
$result = $this->performUpload();
+
// Cleanup any temporary mess
- // FIXME: This should be in a try .. finally block with performUpload
$this->mUpload->cleanupTempFile();
$this->getResult()->addValue( null, $this->getModuleName(), $result );
}
$file = $this->mUpload->getLocalFile();
$result['result'] = 'Success';
$result['filename'] = $file->getName();
-
- // Append imageinfo to the result
- $imParam = ApiQueryImageInfo::getPropertyNames();
- $result['imageinfo'] = ApiQueryImageInfo::getInfo( $file,
- array_flip( $imParam ), $this->getResult() );
+ $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() );
return $result;
}
* @returns void
*/
protected function initFromSessionKey( $sessionKey, $sessionData ) {
- if ( !$sessionKey || empty( $sessionKey ) ) {
- $this->status = Status::newFromFatal( 'Missing session data.' );
+ // testing against null because we don't want to cause obscure
+ // bugs when $sessionKey is full of "0"
+ if ( !$sessionKey === null ) {
+ $this->status = Status::newFromFatal( 'import-token-mismatch' );
return;
}
$this->sessionKey = $sessionKey;
* @see UploadBase::performUpload
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
- wfDebug( "\n\n\performUpload(chunked): sum:" . $comment . ' c: ' . $pageText . ' w:' . $watch );
+ wfDebug( "\n\n\performUpload(chunked): comment:" . $comment . ' pageText: ' . $pageText . ' watch:' . $watch );
global $wgUser, $wgOut;
if ( $this->chunkMode == self::INIT ) {
);
$wgOut->disable();
} else if ( $this->chunkMode == self::DONE ) {
- if ( $comment == '' )
+ if ( !$comment )
$comment = $this->comment;
- if ( $pageText == '' )
+ if ( !$pageText )
$pageText = $this->pageText;
- if ( $watch == '' )
+ if ( !$watch )
$watch = $this->watch;
$status = parent::performUpload( $comment, $pageText, $watch, $user );
$_SESSION['wsUploadData'][$this->sessionKey]['repoPath'] = $this->repoPath;
}
return $status;
+ }
+ if ( $this->getRealPath( $this->repoPath ) ) {
+ $this->status = $this->appendToUploadFile( $this->repoPath, $this->mTempPath );
} else {
- if ( $this->getRealPath( $this->repoPath ) ) {
- $this->status = $this->appendToUploadFile( $this->repoPath, $this->mTempPath );
- } else {
- $this->status = Status::newFatal( 'filenotfound', $this->repoPath );
- }
+ $this->status = Status::newFatal( 'filenotfound', $this->repoPath );
+ }
+ if ( $this->fileSize > $wgMaxUploadSize )
+ $this->status = Status::newFatal( 'largefileserver' );
+ }
+
+ public function verifyUpload() {
+ if ( $this->chunkMode != self::DONE ) {
+ return Status::newGood();
+ }
+ return parent::verifyUpload();
+ }
+
+ public function checkWarnings() {
+ if ( $this->chunkMode != self::DONE ) {
+ return null;
+ }
+ return parent::checkWarnings();
+ }
- if ( $this->fileSize > $wgMaxUploadSize )
- $this->status = Status::newFatal( 'largefileserver' );
+ public function getImageInfo( $result ) {
+ if ( $this->chunkMode != self::DONE ) {
+ return null;
}
+ return parent::getImageInfo( $result );
}
}