Go to the documentation of this file.
55 $this->stash = $stash;
58 wfDebug( __METHOD__ .
" creating new UploadFromChunks instance for " .
$user->getId() .
"\n" );
60 wfDebug( __METHOD__ .
" creating new UploadFromChunks instance with no user\n" );
76 return parent::tryStashFile(
$user, $isPartial );
87 return parent::stashFile(
$user );
98 return parent::stashFileGetKey();
109 return parent::stashSession();
120 $this->mChunkIndex = 0;
124 $this->mStashFile = parent::doStashFile(
$user );
126 $this->mOffset = $this->mStashFile->getSize();
127 $this->mFileKey = $this->mStashFile->getFileKey();
130 $this->
outputChunk( $this->mStashFile->getPath() );
135 return $this->mStashFile;
146 $this->mFileKey = $key;
147 $this->mUpload = $webRequestUpload;
151 $metadata = $this->stash->getMetadata( $key );
152 $this->initializePathInfo(
$name,
153 $this->getRealPath( $metadata[
'us_path'] ),
154 $metadata[
'us_size'],
165 wfDebug( __METHOD__ .
" concatenate {$this->mChunkIndex} chunks:" .
166 $this->
getOffset() .
' inx:' . $chunkIndex .
"\n" );
171 for ( $i = 0; $i <= $chunkIndex; $i++ ) {
182 $tmpPath = $tmpFile->bind( $this )->getPath();
186 $tStart = microtime(
true );
188 $tAmount = microtime(
true ) - $tStart;
193 wfDebugLog(
'fileconcatenate',
"Combined $i chunks in $tAmount seconds." );
196 $this->setTempFile( $tmpPath );
199 if (
$ret[
'status'] !== UploadBase::OK ) {
200 wfDebugLog(
'fileconcatenate',
"Verification failed for chunked upload" );
201 $status->fatal( $this->getVerificationErrorCode(
$ret[
'status'] ) );
208 $tStart = microtime(
true );
211 $error = $this->runUploadStashFileHook( $this->
user );
213 call_user_func_array( [
$status,
'fatal' ], $error );
217 $this->mStashFile = parent::doStashFile( $this->
user );
219 $status->fatal(
'uploadstash-exception', get_class(
$e ),
$e->getMessage() );
223 $tAmount = microtime(
true ) - $tStart;
224 $this->mStashFile->setLocalReference( $tmpFile );
225 wfDebugLog(
'fileconcatenate',
"Stashed combined file ($i chunks) in $tAmount seconds." );
236 return $this->repo->getVirtualUrl(
'temp' ) .
238 $this->repo->getHashPath(
252 public function addChunk( $chunkPath, $chunkSize, $offset ) {
256 if ( $preAppendOffset + $chunkSize > $this->getMaxUploadSize() ) {
260 if ( $preAppendOffset == $offset ) {
262 $this->mChunkIndex++;
264 # For some reason mTempPath is set to first part
265 $oldTemp = $this->mTempPath;
266 $this->mTempPath = $chunkPath;
268 $this->mTempPath = $oldTemp;
275 $this->mOffset = $preAppendOffset + $chunkSize;
291 wfDebug( __METHOD__ .
" update chunk status for {$this->mFileKey} offset:" .
294 $dbw = $this->repo->getMasterDB();
298 'us_status' =>
'chunks',
302 [
'us_key' => $this->mFileKey ],
313 $dbw = $this->repo->getMasterDB();
314 $row = $dbw->selectRow(
321 [
'us_key' => $this->mFileKey ],
326 $this->mChunkIndex = $row->us_chunk_inx;
327 $this->mOffset = $row->us_size;
328 $this->mVirtualTempPath = $row->us_path;
337 if ( $this->mChunkIndex !==
null ) {
349 if ( $this->mOffset !==
null ) {
368 $hashPath = $this->repo->getHashPath( $fileKey );
369 $storeStatus = $this->repo->quickImport( $chunkPath,
370 $this->repo->getZonePath(
'temp' ) .
"/{$hashPath}{$fileKey}" );
373 if ( !$storeStatus->isOK() ) {
374 $error = $storeStatus->getErrorsArray();
375 $error = reset( $error );
376 if ( !
count( $error ) ) {
377 $error = $storeStatus->getWarningsArray();
378 $error = reset( $error );
379 if ( !
count( $error ) ) {
380 $error = [
'unknown',
'no error recorded' ];
384 implode(
'; ', $error ) );
391 if ( $index ===
null ) {
395 return $this->mFileKey .
'.' . $index;
405 $oldDesiredDestName = $this->mDesiredDestName;
407 $this->mTitle =
false;
408 $res = $this->verifyPartialFile();
409 $this->mDesiredDestName = $oldDesiredDestName;
410 $this->mTitle =
false;
411 if ( is_array(
$res ) ) {
426 $this->
msg = call_user_func_array(
'wfMessage',
$res );
427 parent::__construct( call_user_func_array(
'wfMessage',
$res )
428 ->inLanguage(
'en' )->useDatabase(
false )->
text() );
updateChunkStatus()
Update the chunk db table with the current status:
static singleton()
Get a RepoGroup instance.
getOffset()
Get the offset at which the next uploaded chunk will be appended to.
getChunkIndex()
Get the current Chunk index.
outputChunk( $chunkPath)
Output the chunk to disk.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
UploadStash is intended to accomplish a few things:
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
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 extensionFromPath( $path, $case='lowercase')
Get the final extension from a storage or FS path.
static newFatal( $message)
Factory function for fatal errors.
Allows to change the fields on the form that will be generated $name
__construct(User $user, $stash=false, $repo=false)
Setup local pointers to stash, repo and user (similar to UploadFromStash)
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
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
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
addChunk( $chunkPath, $chunkSize, $offset)
Add a chunk to the temporary directory.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static factory( $prefix, $extension='', $tmpDirectory=null)
Make a new temporary file on the file system.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
concatenateChunks()
Append the final chunk and ready file for parent::performUpload()
stashFile(User $user=null)
{}
getChunkStatus()
Get the chunk db state and populate update relevant local values.
msg( $key, $fallback)
Get a message from i18n.
tryStashFile(User $user, $isPartial=false)
{}
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
getChunkFileKey( $index=null)
wfTempDir()
Tries to get the system directory for temporary files.
getVirtualChunkLocation( $index)
Returns the virtual chunk location:
doStashFile(User $user=null)
Calls the parent doStashFile and updates the uploadsession table to handle "chunks".
continueChunks( $name, $key, $webRequestUpload)
Continue chunk uploading.
Implements uploading from chunks.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Implements regular file uploads.
A repository that stores files in the local filesystem and registers them in the wiki's own database.
verifyChunk()
Verify that the chunk isn't really an evil html file.