$this->checkPermissions( $user );
// Fetch the file (usually a no-op)
+ /** @var $status Status */
$status = $this->mUpload->fetchFile();
if ( !$status->isGood() ) {
$errors = $status->getErrorsArray();
// Check if the uploaded file is sane
if ( $this->mParams['chunk'] ) {
- $maxSize = $this->mUpload->getMaxUploadSize( );
+ $maxSize = $this->mUpload->getMaxUploadSize();
if( $this->mParams['filesize'] > $maxSize ) {
$this->dieUsage( 'The file you submitted was too large', 'file-too-large' );
}
}
/**
- * Get an uplaod result based on upload context
+ * Get an upload result based on upload context
* @return array
*/
private function getContextResult() {
$warnings = $this->getApiWarnings();
if ( $warnings && !$this->mParams['ignorewarnings'] ) {
- // Get warnings formated in result array format
+ // Get warnings formatted in result array format
return $this->getWarningsResult( $warnings );
} elseif ( $this->mParams['chunk'] ) {
// Add chunk, and get result
}
/**
- * Get Stash Result, throws an expetion if the file could not be stashed.
- * @param $warnings array Array of Api upload warnings
+ * Get Stash Result, throws an exception if the file could not be stashed.
+ * @param array $warnings Array of Api upload warnings
* @return array
*/
private function getStashResult( $warnings ) {
/**
* Get Warnings Result
- * @param $warnings array Array of Api upload warnings
+ * @param array $warnings Array of Api upload warnings
* @return array
*/
private function getWarningsResult( $warnings ) {
/**
* Get the result of a chunk upload.
- * @param $warnings array Array of Api upload warnings
+ * @param array $warnings Array of Api upload warnings
* @return array
*/
private function getChunkResult( $warnings ) {
$filekey = $this->performStash();
} else {
$filekey = $this->mParams['filekey'];
+ /** @var $status Status */
$status = $this->mUpload->addChunk(
$chunkPath, $chunkSize, $this->mParams['offset'] );
if ( !$status->isGood() ) {
array(
'filename' => $this->mParams['filename'],
'filekey' => $this->mParams['filekey'],
- 'session' => $this->getRequest()->exportUserSession(),
- 'userid' => $this->getUser()->getId()
+ 'session' => $this->getContext()->exportSession()
)
) );
if ( $ok ) {
* Throw an error that the user can recover from by providing a better
* value for $parameter
*
- * @param $error array Error array suitable for passing to dieUsageMsg()
- * @param $parameter string Parameter that needs revising
- * @param $data array Optional extra data to pass to the user
+ * @param array $error Error array suitable for passing to dieUsageMsg()
+ * @param string $parameter Parameter that needs revising
+ * @param array $data Optional extra data to pass to the user
* @throws UsageException
*/
private function dieRecoverableError( $error, $parameter, $data = array() ) {
/**
* Performs file verification, dies on error.
*/
- protected function verifyUpload( ) {
- $verification = $this->mUpload->verifyUpload( );
+ protected function verifyUpload() {
+ $verification = $this->mUpload->verifyUpload();
if ( $verification['status'] === UploadBase::OK ) {
return;
- } else {
- return $this->checkVerification( $verification );
}
+
+ $this->checkVerification( $verification );
}
/**
protected function checkVerification( array $verification ) {
global $wgFileExtensions;
- // TODO: Move them to ApiBase's message map
+ // @todo Move them to ApiBase's message map
switch( $verification['status'] ) {
// Recoverable errors
case UploadBase::MIN_LENGTH_PARTNAME:
}
}
-
/**
* Check warnings.
* Returns a suitable array for inclusion into API results if there were warnings
return $warnings;
}
-
/**
* Perform the actual upload. Returns a suitable result array on success;
* dies on failure.
*
- * @param $warnings array Array of Api upload warnings
+ * @param array $warnings Array of Api upload warnings
* @return array
*/
protected function performUpload( $warnings ) {
$this->mParams['text'] = $this->mParams['comment'];
}
+ /** @var $file File */
$file = $this->mUpload->getLocalFile();
$watch = $this->getWatchlistValue( $this->mParams['watchlist'], $file->getTitle() );
'comment' => $this->mParams['comment'],
'text' => $this->mParams['text'],
'watch' => $watch,
- 'session' => $this->getRequest()->exportUserSession(),
- 'userid' => $this->getUser()->getId()
+ 'session' => $this->getContext()->exportSession()
)
) );
if ( $ok ) {
"Failed to start PublishStashedFile.php", 'publishfailed' );
}
} else {
+ /** @var $status Status */
$status = $this->mUpload->performUpload( $this->mParams['comment'],
$this->mParams['text'], $watch, $this->getUser() );
),
),
'ignorewarnings' => false,
- 'file' => null,
+ 'file' => array(
+ ApiBase::PARAM_TYPE => 'upload',
+ ),
'url' => null,
'filekey' => null,
'sessionkey' => array(
'filesize' => null,
'offset' => null,
- 'chunk' => null,
+ 'chunk' => array(
+ ApiBase::PARAM_TYPE => 'upload',
+ ),
'async' => false,
'asyncdownload' => false,