/**
* Setup local pointers to stash, repo and user (similar to UploadFromStash)
*
- * @param $user User|null Default: null
- * @param $stash UploadStash|bool Default: false
- * @param $repo FileRepo|bool Default: false
+ * @param User|null $user Default: null
+ * @param UploadStash|bool $stash Default: false
+ * @param FileRepo|bool $repo Default: false
*/
public function __construct( $user = null, $stash = false, $repo = false ) {
// user object. sometimes this won't exist, as when running from cron.
/**
* Calls the parent stashFile and updates the uploadsession table to handle "chunks"
*
+ * @param User|null $user
* @return UploadStashFile stashed file
*/
public function stashFile( User $user = null ) {
// Update db table to reflect initial "chunk" state
$this->updateChunkStatus();
+
return $this->mLocalFile;
}
/**
* Continue chunk uploading
+ *
+ * @param string $name
+ * @param string $key
+ * @param WebRequestUpload $webRequestUpload
*/
public function continueChunks( $name, $key, $webRequestUpload ) {
$this->mFileKey = $key;
if ( $ret['status'] !== UploadBase::OK ) {
wfDebugLog( 'fileconcatenate', "Verification failed for chunked upload" );
$status->fatal( $this->getVerificationErrorCode( $ret['status'] ) );
+
return $status;
}
/**
* Perform the upload, then remove the temp copy afterward
- * @param $comment string
- * @param $pageText string
- * @param $watch bool
- * @param $user User
+ * @param string $comment
+ * @param string $pageText
+ * @param bool $watch
+ * @param User $user
* @return Status
*/
public function performUpload( $comment, $pageText, $watch, $user ) {
$rv = parent::performUpload( $comment, $pageText, $watch, $user );
+
return $rv;
}
/**
* Returns the virtual chunk location:
- * @param $index
+ * @param int $index
* @return string
*/
function getVirtualChunkLocation( $index ) {
return $this->repo->getVirtualUrl( 'temp' ) .
- '/' .
- $this->repo->getHashPath(
- $this->getChunkFileKey( $index )
- ) .
- $this->getChunkFileKey( $index );
+ '/' .
+ $this->repo->getHashPath(
+ $this->getChunkFileKey( $index )
+ ) .
+ $this->getChunkFileKey( $index );
}
/**
$status = Status::newFatal( 'invalid-chunk-offset' );
}
}
+
return $status;
}
*/
private function updateChunkStatus() {
wfDebug( __METHOD__ . " update chunk status for {$this->mFileKey} offset:" .
- $this->getOffset() . ' inx:' . $this->getChunkIndex() . "\n" );
+ $this->getOffset() . ' inx:' . $this->getChunkIndex() . "\n" );
$dbw = $this->repo->getMasterDb();
// Use a quick transaction since we will upload the full temp file into shared
/**
* Get the current Chunk index
- * @return Integer index of the current chunk
+ * @return int Index of the current chunk
*/
private function getChunkIndex() {
if ( $this->mChunkIndex !== null ) {
return $this->mChunkIndex;
}
+
return 0;
}
/**
* Gets the current offset in fromt the stashedupload table
- * @return Integer current byte offset of the chunk file set
+ * @return int Current byte offset of the chunk file set
*/
private function getOffset() {
if ( $this->mOffset !== null ) {
return $this->mOffset;
}
+
return 0;
}
/**
* Output the chunk to disk
*
- * @param $chunkPath string
+ * @param string $chunkPath
* @throws UploadChunkFileException
* @return FileRepoStatus
*/
$this->repo->getZonePath( 'temp' ) . "/{$hashPath}{$fileKey}" );
// Check for error in stashing the chunk:
- if ( ! $storeStatus->isOK() ) {
+ if ( !$storeStatus->isOK() ) {
$error = $storeStatus->getErrorsArray();
$error = reset( $error );
- if ( ! count( $error ) ) {
+ if ( !count( $error ) ) {
$error = $storeStatus->getWarningsArray();
$error = reset( $error );
- if ( ! count( $error ) ) {
+ if ( !count( $error ) ) {
$error = array( 'unknown', 'no error recorded' );
}
}
throw new UploadChunkFileException( "Error storing file in '$chunkPath': " .
implode( '; ', $error ) );
}
+
return $storeStatus;
}
if ( $index === null ) {
$index = $this->getChunkIndex();
}
+
return $this->mFileKey . '.' . $index;
}