Go to the documentation of this file.
82 foreach ( $required
as $name ) {
89 foreach ( $optional
as $name ) {
95 if ( isset( $this->params[
$name] ) ) {
134 return isset( $this->params[
$name] ) ? $this->params[
$name] :
null;
142 final public function failed() {
185 if ( isset( $deps[
'read'][
$path] ) || isset( $deps[
'write'][
$path] ) ) {
190 if ( isset( $deps[
'write'][
$path] ) ) {
206 if ( !$this->doOperation ) {
209 $nullEntries =
array();
210 $updateEntries =
array();
211 $deleteEntries =
array();
213 foreach ( array_unique( $pathsUsed )
as $path ) {
214 $nullEntries[] =
array(
217 'newSha1' => $this->
fileSha1( $path, $oPredicates )
221 if ( $nPredicates[
'sha1'][
$path] ===
false ) {
222 $deleteEntries[] =
array(
228 $updateEntries[] =
array(
229 'op' => $this->
fileExists( $path, $oPredicates ) ?
'update' :
'create',
231 'newSha1' => $nPredicates[
'sha1'][
$path]
236 return array_merge( $nullEntries, $updateEntries, $deleteEntries );
248 if ( $this->state !== self::STATE_NEW ) {
249 return Status::newFatal(
'fileop-fail-state', self::STATE_NEW, $this->state );
253 if ( !$status->isOK() ) {
273 final public function attempt() {
274 if ( $this->state !== self::STATE_CHECKED ) {
275 return Status::newFatal(
'fileop-fail-state', self::STATE_CHECKED, $this->state );
276 } elseif ( $this->
failed ) {
280 if ( $this->doOperation ) {
282 if ( !$status->isOK() ) {
308 $this->async =
false;
362 if ( $this->sourceSha1 ===
null ) {
363 $this->sourceSha1 = $this->
fileSha1( $this->params[
'src'], $predicates );
365 $this->overwriteSameCase =
false;
366 $this->destExists = $this->
fileExists( $this->params[
'dst'], $predicates );
367 if ( $this->destExists ) {
368 if ( $this->
getParam(
'overwrite' ) ) {
370 } elseif ( $this->
getParam(
'overwriteSame' ) ) {
371 $dhash = $this->
fileSha1( $this->params[
'dst'], $predicates );
373 if ( !strlen( $this->sourceSha1 ) || !strlen( $dhash ) ) {
374 $status->fatal(
'backend-fail-hashes' );
375 } elseif ( $this->sourceSha1 !== $dhash ) {
377 $status->fatal(
'backend-fail-notsame', $this->params[
'dst'] );
379 $this->overwriteSameCase =
true;
384 $status->fatal(
'backend-fail-alreadyexists', $this->params[
'dst'] );
411 if ( isset( $predicates[
'exists'][
$source] ) ) {
412 return $predicates[
'exists'][
$source];
416 return $this->backend->fileExists(
$params );
428 if ( isset( $predicates[
'sha1'][
$source] ) ) {
429 return $predicates[
'sha1'][
$source];
430 } elseif ( isset( $predicates[
'exists'][
$source] ) && !$predicates[
'exists'][
$source] ) {
435 return $this->backend->getFileSha1Base36(
$params );
455 $params[
'failedAction'] = $action;
457 wfDebugLog(
'FileOperation', get_class( $this ) .
459 }
catch ( Exception
$e ) {
472 array(
'content',
'dst' ),
473 array(
'overwrite',
'overwriteSame',
'headers' ),
481 if ( strlen( $this->
getParam(
'content' ) ) > $this->backend->maxFileSizeInternal() ) {
482 $status->fatal(
'backend-fail-maxsize',
483 $this->params[
'dst'], $this->backend->maxFileSizeInternal() );
484 $status->fatal(
'backend-fail-create', $this->params[
'dst'] );
488 } elseif ( !$this->backend->isPathUsableInternal( $this->params[
'dst'] ) ) {
489 $status->fatal(
'backend-fail-usable', $this->params[
'dst'] );
490 $status->fatal(
'backend-fail-create', $this->params[
'dst'] );
497 if ( $status->isOK() ) {
499 $predicates[
'exists'][$this->params[
'dst']] =
true;
507 if ( !$this->overwriteSameCase ) {
509 return $this->backend->createInternal( $this->
setFlags( $this->params ) );
516 return wfBaseConvert( sha1( $this->params[
'content'] ), 16, 36, 31 );
520 return array( $this->params[
'dst'] );
531 array(
'src',
'dst' ),
532 array(
'overwrite',
'overwriteSame',
'headers' ),
533 array(
'src',
'dst' )
540 if ( !is_file( $this->params[
'src'] ) ) {
541 $status->fatal(
'backend-fail-notexists', $this->params[
'src'] );
545 } elseif ( filesize( $this->params[
'src'] ) > $this->backend->maxFileSizeInternal() ) {
546 $status->fatal(
'backend-fail-maxsize',
547 $this->params[
'dst'], $this->backend->maxFileSizeInternal() );
548 $status->fatal(
'backend-fail-store', $this->params[
'src'], $this->params[
'dst'] );
552 } elseif ( !$this->backend->isPathUsableInternal( $this->params[
'dst'] ) ) {
553 $status->fatal(
'backend-fail-usable', $this->params[
'dst'] );
554 $status->fatal(
'backend-fail-store', $this->params[
'src'], $this->params[
'dst'] );
561 if ( $status->isOK() ) {
563 $predicates[
'exists'][$this->params[
'dst']] =
true;
571 if ( !$this->overwriteSameCase ) {
573 return $this->backend->storeInternal( $this->
setFlags( $this->params ) );
581 $hash = sha1_file( $this->params[
'src'] );
583 if (
$hash !==
false ) {
591 return array( $this->params[
'dst'] );
602 array(
'src',
'dst' ),
603 array(
'overwrite',
'overwriteSame',
'ignoreMissingSource',
'headers' ),
604 array(
'src',
'dst' )
611 if ( !$this->
fileExists( $this->params[
'src'], $predicates ) ) {
612 if ( $this->
getParam(
'ignoreMissingSource' ) ) {
613 $this->doOperation =
false;
615 $predicates[
'exists'][$this->params[
'src']] =
false;
616 $predicates[
'sha1'][$this->params[
'src']] =
false;
620 $status->fatal(
'backend-fail-notexists', $this->params[
'src'] );
625 } elseif ( !$this->backend->isPathUsableInternal( $this->params[
'dst'] ) ) {
626 $status->fatal(
'backend-fail-usable', $this->params[
'dst'] );
627 $status->fatal(
'backend-fail-copy', $this->params[
'src'], $this->params[
'dst'] );
634 if ( $status->isOK() ) {
636 $predicates[
'exists'][$this->params[
'dst']] =
true;
644 if ( $this->overwriteSameCase ) {
646 } elseif ( $this->params[
'src'] === $this->params[
'dst'] ) {
649 $status = $this->backend->describeInternal( $this->
setFlags(
array(
650 'src' => $this->params[
'dst'],
'headers' => $headers
654 $status = $this->backend->copyInternal( $this->
setFlags( $this->params ) );
661 return array( $this->params[
'src'] );
665 return array( $this->params[
'dst'] );
676 array(
'src',
'dst' ),
677 array(
'overwrite',
'overwriteSame',
'ignoreMissingSource',
'headers' ),
678 array(
'src',
'dst' )
685 if ( !$this->
fileExists( $this->params[
'src'], $predicates ) ) {
686 if ( $this->
getParam(
'ignoreMissingSource' ) ) {
687 $this->doOperation =
false;
689 $predicates[
'exists'][$this->params[
'src']] =
false;
690 $predicates[
'sha1'][$this->params[
'src']] =
false;
694 $status->fatal(
'backend-fail-notexists', $this->params[
'src'] );
699 } elseif ( !$this->backend->isPathUsableInternal( $this->params[
'dst'] ) ) {
700 $status->fatal(
'backend-fail-usable', $this->params[
'dst'] );
701 $status->fatal(
'backend-fail-move', $this->params[
'src'], $this->params[
'dst'] );
708 if ( $status->isOK() ) {
710 $predicates[
'exists'][$this->params[
'src']] =
false;
711 $predicates[
'sha1'][$this->params[
'src']] =
false;
712 $predicates[
'exists'][$this->params[
'dst']] =
true;
720 if ( $this->overwriteSameCase ) {
721 if ( $this->params[
'src'] === $this->params[
'dst'] ) {
726 $status = $this->backend->deleteInternal( $this->
setFlags(
727 array(
'src' => $this->params[
'src'] )
730 } elseif ( $this->params[
'src'] === $this->params[
'dst'] ) {
733 $status = $this->backend->describeInternal( $this->
setFlags(
734 array(
'src' => $this->params[
'dst'],
'headers' => $headers )
738 $status = $this->backend->moveInternal( $this->
setFlags( $this->params ) );
745 return array( $this->params[
'src'] );
749 return array( $this->params[
'src'], $this->params[
'dst'] );
765 if ( !$this->
fileExists( $this->params[
'src'], $predicates ) ) {
766 if ( $this->
getParam(
'ignoreMissingSource' ) ) {
767 $this->doOperation =
false;
769 $predicates[
'exists'][$this->params[
'src']] =
false;
770 $predicates[
'sha1'][$this->params[
'src']] =
false;
774 $status->fatal(
'backend-fail-notexists', $this->params[
'src'] );
779 } elseif ( !$this->backend->isPathUsableInternal( $this->params[
'src'] ) ) {
780 $status->fatal(
'backend-fail-usable', $this->params[
'src'] );
781 $status->fatal(
'backend-fail-delete', $this->params[
'src'] );
786 $predicates[
'exists'][$this->params[
'src']] =
false;
787 $predicates[
'sha1'][$this->params[
'src']] =
false;
794 return $this->backend->deleteInternal( $this->
setFlags( $this->params ) );
798 return array( $this->params[
'src'] );
814 if ( !$this->
fileExists( $this->params[
'src'], $predicates ) ) {
815 $status->fatal(
'backend-fail-notexists', $this->params[
'src'] );
819 } elseif ( !$this->backend->isPathUsableInternal( $this->params[
'src'] ) ) {
820 $status->fatal(
'backend-fail-usable', $this->params[
'src'] );
821 $status->fatal(
'backend-fail-describe', $this->params[
'src'] );
826 $predicates[
'exists'][$this->params[
'src']] =
827 $this->
fileExists( $this->params[
'src'], $predicates );
828 $predicates[
'sha1'][$this->params[
'src']] =
829 $this->
fileSha1( $this->params[
'src'], $predicates );
836 return $this->backend->describeInternal( $this->
setFlags( $this->params ) );
840 return array( $this->params[
'src'] );
logFailure( $action)
Log a file operation failure and preserve any temp files.
setBatchId( $batchId)
Set the batch UUID this operation belongs to.
bool $doOperation
Operation is not a no-op *.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
doPrecheck(array &$predicates)
fileSha1( $source, array $predicates)
Get the SHA-1 of a file in storage when this operation is attempted.
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
allowedParams()
Get the file operation parameters.
Change metadata for a file at the given storage path in the backend.
Delete a file at the given storage path from the backend.
storagePathsRead()
Get a list of storage paths read from for this operation.
FileBackend helper class for representing operations.
File backend exception for checked exceptions (e.g.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Placeholder operation that has no params and does nothing.
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
precheck(array &$predicates)
Check preconditions of the operation without writing anything.
static newGood( $value=null)
Factory function for good results.
static normalizeStoragePath( $storagePath)
Normalize a storage path by cleaning up directory separators.
getJournalEntries(array $oPredicates, array $nPredicates)
Get the file journal entries for this file operation.
doPrecheck(array &$predicates)
storagePathsChanged()
Get a list of storage paths written to for this operation.
allowedParams()
Get the file operation parameters.
allowedParams()
Get the file operation parameters.
Copy a file from one storage path to another in the backend.
applyDependencies(array $deps)
Update a dependency tracking array to account for this operation.
attemptAsync()
Attempt the operation in the background.
getBackend()
Get the backend this operation is for.
allowedParams()
Get the file operation parameters.
wfRestoreWarnings()
Restore error level to previous value.
getSourceSha1Base36()
precheckDestExistence() helper function to get the source file SHA-1.
failed()
Check if this operation failed precheck() or attempt()
static isStoragePath( $path)
Check if a given path is a "mwstore://" path.
setFlags(array $params)
Adjust params to FileBackendStore internal file calls.
doPrecheck(array &$predicates)
storagePathsChanged()
Get a list of storage paths written to for this operation.
getSourceSha1Base36()
precheckDestExistence() helper function to get the source file SHA-1.
storagePathsChanged()
Get a list of storage paths written to for this operation.
FileBackendStore $backend
doPrecheck(array &$predicates)
attempt()
Attempt the operation.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
getParam( $name)
Get the value of the parameter with the given name.
doPrecheck(array &$predicates)
doPrecheck(array &$predicates)
allowedParams()
Get the file operation parameters.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
allowedParams()
Get the file operation parameters.
dependsOn(array $deps)
Check if this operation changes files listed in $paths.
Allows to change the fields on the form that will be generated $name
storagePathsRead()
Get a list of storage paths read from for this operation.
Base class for all backends using particular storage medium.
getSourceSha1Base36()
precheckDestExistence() helper function to get the source file SHA-1.
storagePathsChanged()
Get a list of storage paths written to for this operation.
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
Move a file from one storage path to another in the backend.
__construct(FileBackendStore $backend, array $params)
Build a new batch file operation transaction.
wfBaseConvert( $input, $sourceBase, $destBase, $pad=1, $lowercase=true, $engine='auto')
Convert an arbitrarily-long digit string from one numeric base to another, optionally zero-padding to...
Store a file into the backend from a file on the file system.
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 as
if(PHP_SAPI !='cli') $source
storagePathsChanged()
Get a list of storage paths written to for this operation.
storagePathsChanged()
Get a list of storage paths written to for this operation.
fileExists( $source, array $predicates)
Check if a file will exist in storage when this operation is attempted.
doPrecheck(array &$predicates)
allowedParams()
Get the file operation parameters.
precheckDestExistence(array $predicates)
Check for errors with regards to the destination file already existing.
static newDependencies()
Get a new empty dependency tracking array for paths read/written to.
static normalizeIfValidStoragePath( $path)
Normalize a string if it is a valid storage path.
static newPredicates()
Get a new empty predicates array for precheck()
Create a file in the backend with the given content.
storagePathsChanged()
Get a list of storage paths written to for this operation.
storagePathsRead()
Get a list of storage paths read from for this operation.
static newFatal( $message)
Factory function for fatal errors.