Go to the documentation of this file.
54 $this->stash = $stash;
57 wfDebug( __METHOD__ .
" creating new UploadFromChunks instance for " .
$user->getId() .
"\n" );
59 wfDebug( __METHOD__ .
" creating new UploadFromChunks instance with no user\n" );
74 $this->mChunkIndex = 0;
79 $this->mLocalFile = parent::stashFile();
81 $this->mOffset = $this->mLocalFile->getSize();
82 $this->mFileKey = $this->mLocalFile->getFileKey();
96 $this->mFileKey = $key;
97 $this->mUpload = $webRequestUpload;
101 $metadata = $this->stash->getMetadata( $key );
104 $metadata[
'us_size'],
115 wfDebug( __METHOD__ .
" concatenate {$this->mChunkIndex} chunks:" .
116 $this->
getOffset() .
' inx:' . $chunkIndex .
"\n" );
121 for ( $i = 0; $i <= $chunkIndex; $i++ ) {
132 $tmpPath = $tmpFile->bind( $this )->getPath();
136 $tStart = microtime(
true );
138 $tAmount = microtime(
true ) - $tStart;
139 if ( !$status->isOk() ) {
142 wfDebugLog(
'fileconcatenate',
"Combined $i chunks in $tAmount seconds." );
145 $this->mTempPath = $tmpPath;
147 $this->mFileSize = filesize( $this->mTempPath );
150 wfDebugLog(
'fileconcatenate',
"Verification failed for chunked upload" );
157 $tStart = microtime(
true );
158 $this->mLocalFile = parent::stashFile( $this->
user );
159 $tAmount = microtime(
true ) - $tStart;
160 $this->mLocalFile->setLocalReference( $tmpFile );
161 wfDebugLog(
'fileconcatenate',
"Stashed combined file ($i chunks) in $tAmount seconds." );
175 $rv = parent::performUpload(
$comment, $pageText, $watch,
$user );
185 return $this->repo->getVirtualUrl(
'temp' ) .
187 $this->repo->getHashPath(
201 public function addChunk( $chunkPath, $chunkSize, $offset ) {
209 if ( $preAppendOffset == $offset ) {
211 $this->mChunkIndex++;
213 # For some reason mTempPath is set to first part
215 $this->mTempPath = $chunkPath;
217 $this->mTempPath = $oldTemp;
222 if ( $status->isGood() ) {
224 $this->mOffset = $preAppendOffset + $chunkSize;
239 wfDebug( __METHOD__ .
" update chunk status for {$this->mFileKey} offset:" .
242 $dbw = $this->repo->getMasterDb();
245 $dbw->begin( __METHOD__ );
249 'us_status' =>
'chunks',
253 array(
'us_key' => $this->mFileKey ),
256 $dbw->commit( __METHOD__ );
265 $dbw = $this->repo->getMasterDb();
266 $row = $dbw->selectRow(
273 array(
'us_key' => $this->mFileKey ),
278 $this->mChunkIndex = $row->us_chunk_inx;
279 $this->mOffset = $row->us_size;
280 $this->mVirtualTempPath = $row->us_path;
289 if ( $this->mChunkIndex !==
null ) {
300 if ( $this->mOffset !==
null ) {
318 $hashPath = $this->repo->getHashPath( $fileKey );
319 $storeStatus = $this->repo->quickImport( $chunkPath,
320 $this->repo->getZonePath(
'temp' ) .
"/{$hashPath}{$fileKey}" );
323 if ( ! $storeStatus->isOK() ) {
324 $error = $storeStatus->getErrorsArray();
326 if ( ! count(
$error ) ) {
327 $error = $storeStatus->getWarningsArray();
329 if ( ! count(
$error ) ) {
334 implode(
'; ',
$error ) );
340 if ( $index ===
null ) {
343 return $this->mFileKey .
'.' . $index;
355 $this->mTitle =
false;
357 $this->mDesiredDestName = $oldDesiredDestName;
358 $this->mTitle =
false;
359 if ( is_array(
$res ) ) {
updateChunkStatus()
Update the chunk db table with the current status:
static singleton()
Get a RepoGroup instance.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
getOffset()
Gets the current offset in fromt the stashedupload table.
getChunkIndex()
Get the current Chunk index.
outputChunk( $chunkPath)
Output the chunk to disk.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
__construct( $user=null, $stash=false, $repo=false)
Setup local pointers to stash, repo and user (similar to UploadFromStash)
UploadStash is intended to accomplish a few things:
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
performUpload( $comment, $pageText, $watch, $user)
Perform the upload, then remove the temp copy afterward.
getVerificationErrorCode( $error)
addChunk( $chunkPath, $chunkSize, $offset)
Add a chunk to the temporary directory.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Allows to change the fields on the form that will be generated $name
static factory( $prefix, $extension='')
Make a new temporary file on the file system.
concatenateChunks()
Append the final chunk and ready file for parent::performUpload()
stashFile(User $user=null)
Calls the parent stashFile and updates the uploadsession table to handle "chunks".
getChunkStatus()
Get the chunk db state and populate update relevant local values.
getChunkFileKey( $index=null)
verifyPartialFile()
A verification routine suitable for partial files.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
static getMaxUploadSize( $forType=null)
initializePathInfo( $name, $tempPath, $fileSize, $removeTempFile=false)
Initialize the path information.
getVirtualChunkLocation( $index)
Returns the virtual chunk location:
static extensionFromPath( $path)
Get the final extension from a storage or FS path.
continueChunks( $name, $key, $webRequestUpload)
Continue chunk uploading.
Implements uploading from chunks.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Implements regular file uploads.
static newFatal( $message)
Factory function for fatal errors.
verifyChunk()
Verify that the chunk isn't really an evil html file.