$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 ) {
- $result = array ();
+ $result = array();
// Some uploads can request they be stashed, so as not to publish them immediately.
// In this case, a failure to stash ought to be fatal
try {
/**
* 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() ) {
$ok = JobQueueGroup::singleton()->push( new AssembleUploadChunksJob(
Title::makeTitle( NS_FILE, $this->mParams['filekey'] ),
array(
- 'filename' => $this->mParams['filename'],
- 'filekey' => $this->mParams['filekey'],
- 'session' => $this->getRequest()->exportUserSession(),
- 'userid' => $this->getUser()->getId()
+ 'filename' => $this->mParams['filename'],
+ 'filekey' => $this->mParams['filekey'],
+ '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:
* 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() );
$ok = JobQueueGroup::singleton()->push( new PublishStashedFileJob(
Title::makeTitle( NS_FILE, $this->mParams['filename'] ),
array(
- 'filename' => $this->mParams['filename'],
- 'filekey' => $this->mParams['filekey'],
- 'comment' => $this->mParams['comment'],
- 'text' => $this->mParams['text'],
- 'watch' => $watch,
- 'session' => $this->getRequest()->exportUserSession(),
- 'userid' => $this->getUser()->getId()
+ 'filename' => $this->mParams['filename'],
+ 'filekey' => $this->mParams['filekey'],
+ 'comment' => $this->mParams['comment'],
+ 'text' => $this->mParams['text'],
+ 'watch' => $watch,
+ '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() );