- protected $mOffset, $mChunkIndex, $mFileKey, $mVirtualTempPath;
+ protected $mOffset;
+ protected $mChunkIndex;
+ protected $mFileKey;
+ protected $mVirtualTempPath;
- * @param $user User
- * @param $stash UploadStash
- * @param $repo FileRepo
+ * @param $user User|null Default: null
+ * @param $stash UploadStash|bool Default: false
+ * @param $repo FileRepo|bool Default: false
*/
public function __construct( $user = null, $stash = false, $repo = false ) {
// user object. sometimes this won't exist, as when running from cron.
*/
public function __construct( $user = null, $stash = false, $repo = false ) {
// user object. sometimes this won't exist, as when running from cron.
$ext = FileBackend::extensionFromPath( $this->mVirtualTempPath );
// Get a 0-byte temp file to perform the concatenation at
$tmpFile = TempFSFile::factory( 'chunkedupload_', $ext );
$ext = FileBackend::extensionFromPath( $this->mVirtualTempPath );
// Get a 0-byte temp file to perform the concatenation at
$tmpFile = TempFSFile::factory( 'chunkedupload_', $ext );
- $tmpPath = $tmpFile
- ? $tmpFile->bind( $this )->getPath() // keep alive with $this
- : false; // fail in concatenate()
+ $tmpPath = false; // fail in concatenate()
+ if ( $tmpFile ) {
+ // keep alive with $this
+ $tmpPath = $tmpFile->bind( $this )->getPath();
+ }
+
// Concatenate the chunks at the temp file
$tStart = microtime( true );
$status = $this->repo->concatenate( $fileList, $tmpPath, FileRepo::DELETE_SOURCE );
// Concatenate the chunks at the temp file
$tStart = microtime( true );
$status = $this->repo->concatenate( $fileList, $tmpPath, FileRepo::DELETE_SOURCE );
- $this->mTempPath = $tmpPath; // file system path
- $this->mFileSize = filesize( $this->mTempPath ); //Since this was set for the last chunk previously
+ // File system path
+ $this->mTempPath = $tmpPath;
+ // Since this was set for the last chunk previously
+ $this->mFileSize = filesize( $this->mTempPath );
$ret = $this->verifyUpload();
if ( $ret['status'] !== UploadBase::OK ) {
wfDebugLog( 'fileconcatenate', "Verification failed for chunked upload" );
$ret = $this->verifyUpload();
if ( $ret['status'] !== UploadBase::OK ) {
wfDebugLog( 'fileconcatenate', "Verification failed for chunked upload" );
$this->mLocalFile = parent::stashFile( $this->user );
$tAmount = microtime( true ) - $tStart;
$this->mLocalFile->setLocalReference( $tmpFile ); // reuse (e.g. for getImageInfo())
$this->mLocalFile = parent::stashFile( $this->user );
$tAmount = microtime( true ) - $tStart;
$this->mLocalFile->setLocalReference( $tmpFile ); // reuse (e.g. for getImageInfo())
- throw new UploadChunkFileException( "error storing file in '$chunkPath': " . implode( '; ', $error ) );
+ throw new UploadChunkFileException( "Error storing file in '$chunkPath': " .
+ implode( '; ', $error ) );
-class UploadChunkZeroLengthFileException extends MWException {};
-class UploadChunkFileException extends MWException {};
-class UploadChunkVerificationException extends MWException {};
+class UploadChunkZeroLengthFileException extends MWException {
+}
+
+class UploadChunkFileException extends MWException {
+}
+
+class UploadChunkVerificationException extends MWException {
+}