48 $this->mParams[
'async'] = ( $this->mParams[
'async'] &&
49 $this->
getConfig()->get(
'EnableAsyncUploads' ) );
51 $this->mParams[
'file'] =
$request->getFileName(
'file' );
52 $this->mParams[
'chunk'] =
$request->getFileName(
'chunk' );
55 if ( !$this->mParams[
'filekey'] && $this->mParams[
'sessionkey'] ) {
56 $this->mParams[
'filekey'] = $this->mParams[
'sessionkey'];
63 } elseif ( !isset( $this->mUpload ) ) {
64 $this->
dieUsage(
'No upload module set',
'nomodule' );
76 $status = $this->mUpload->fetchFile();
78 $errors =
$status->getErrorsArray();
79 $error = array_shift( $errors[0] );
80 $this->
dieUsage(
'Error fetching file from remote source', $error, 0, $errors[0] );
84 if ( $this->mParams[
'chunk'] ) {
86 if ( $this->mParams[
'filesize'] > $maxSize ) {
87 $this->
dieUsage(
'The file you submitted was too large',
'file-too-large' );
89 if ( !$this->mUpload->getTitle() ) {
90 $this->
dieUsage(
'Invalid file title supplied',
'internal-error' );
92 } elseif ( $this->mParams[
'async'] && $this->mParams[
'filekey'] ) {
95 wfDebug( __METHOD__ .
" about to verify\n" );
102 if ( !$this->mParams[
'stash'] ) {
103 $permErrors = $this->mUpload->verifyTitlePermissions(
$user );
104 if ( $permErrors !==
true ) {
120 if (
$result[
'result'] ===
'Success' ) {
121 $imageinfo = $this->mUpload->getImageInfo( $this->
getResult() );
126 $this->mUpload->cleanupTempFile();
135 if ( $warnings && !$this->mParams[
'ignorewarnings'] ) {
138 } elseif ( $this->mParams[
'chunk'] ) {
141 } elseif ( $this->mParams[
'stash'] ) {
165 if ( $warnings && count( $warnings ) > 0 ) {
166 $result[
'warnings'] = $warnings;
183 $result[
'warnings'] = $warnings;
199 if ( $warnings && count( $warnings ) > 0 ) {
200 $result[
'warnings'] = $warnings;
204 $chunkPath =
$request->getFileTempname(
'chunk' );
205 $chunkSize =
$request->getUpload(
'chunk' )->getSize();
206 $totalSoFar = $this->mParams[
'offset'] + $chunkSize;
207 $minChunkSize = $this->
getConfig()->get(
'MinUploadChunkSize' );
210 if ( $totalSoFar > $this->mParams[
'filesize'] ) {
212 'Offset plus current chunk is greater than claimed file size',
'invalid-chunk'
217 if ( $totalSoFar != $this->mParams[
'filesize'] && $chunkSize < $minChunkSize ) {
219 "Minimum chunk size is $minChunkSize bytes for non-final chunks",
'chunk-too-small'
223 if ( $this->mParams[
'offset'] == 0 ) {
226 $filekey = $this->mParams[
'filekey'];
232 $this->
dieUsage(
'No chunked upload session with this key',
'stashfailed' );
233 } elseif ( $progress[
'result'] !==
'Continue' || $progress[
'stage'] !==
'uploading' ) {
235 'Chunked upload is already completed, check status for details',
'stashfailed'
239 $status = $this->mUpload->addChunk(
240 $chunkPath, $chunkSize, $this->mParams[
'offset'] );
243 'offset' => $this->mUpload->getOffset(),
251 if ( $totalSoFar == $this->mParams[
'filesize'] ) {
252 if ( $this->mParams[
'async'] ) {
256 [
'result' =>
'Poll',
262 'filename' => $this->mParams[
'filename'],
263 'filekey' => $filekey,
270 $status = $this->mUpload->concatenateChunks();
275 [
'result' =>
'Failure',
'stage' =>
'assembling',
'status' =>
$status ]
283 $result[
'warnings'] = $warnings;
289 $this->mUpload->stash->removeFile( $filekey );
290 $filekey = $this->mUpload->getStashFile()->getFileKey();
299 'result' =>
'Continue',
300 'stage' =>
'uploading',
301 'offset' => $totalSoFar,
305 $result[
'result'] =
'Continue';
306 $result[
'offset'] = $totalSoFar;
327 $isPartial = (bool)$this->mParams[
'chunk'];
329 $status = $this->mUpload->tryStashFile( $this->
getUser(), $isPartial );
336 $debugMessage =
'Stashing temporary file failed: ' . get_class( $e ) .
' ' . $e->getMessage();
337 wfDebug( __METHOD__ .
' ' . $debugMessage .
"\n" );
342 $stashFile =
$status->getValue();
343 $data[
'filekey'] = $stashFile->getFileKey();
345 $data[
'sessionkey'] = $data[
'filekey'];
346 return $data[
'filekey'];
349 if (
$status->getMessage()->getKey() ===
'uploadstash-exception' ) {
352 list( $exceptionType, $message ) =
$status->getMessage()->getParams();
353 $debugMessage =
'Stashing temporary file failed: ' . $exceptionType .
' ' . $message;
354 wfDebug( __METHOD__ .
' ' . $debugMessage .
"\n" );
360 if ( $failureMode !==
'optional' ) {
364 $data[
'stashfailed'] = $msg;
381 $data[
'invalidparameter'] = $parameter;
383 $parsed = $this->
parseMsg( $error );
384 if ( isset( $parsed[
'data'] ) ) {
385 $data = array_merge( $data, $parsed[
'data'] );
387 if ( $parsed[
'code'] ===
'unknownerror' ) {
388 $parsed[
'code'] =
$code;
391 $this->
dieUsage( $parsed[
'info'], $parsed[
'code'], 0, $data );
406 $errors =
$status->getErrorsByType(
'error' ) ?:
$status->getErrorsByType(
'warning' );
407 if ( !( $errors[0][
'message'] instanceof
IApiMessage ) ) {
408 $code = $overrideCode;
410 if ( $moreExtraData ) {
411 $extraData = $extraData ?: [];
412 $extraData += $moreExtraData;
428 if ( !$this->mParams[
'chunk'] ) {
430 'filekey',
'file',
'url' );
434 if ( $this->mParams[
'filekey'] && $this->mParams[
'checkstatus'] ) {
437 $this->
dieUsage(
'No result in status data',
'missingresult' );
438 } elseif ( !$progress[
'status']->isGood() ) {
441 if ( isset( $progress[
'status']->value[
'verification'] ) ) {
444 if ( isset( $progress[
'status']->value[
'warnings'] ) ) {
447 $progress[
'warnings'] = $warnings;
450 unset( $progress[
'status'] );
452 if ( isset( $progress[
'imageinfo'] ) ) {
453 $imageinfo = $progress[
'imageinfo'];
454 unset( $progress[
'imageinfo'] );
468 if ( is_null( $this->mParams[
'filename'] ) ) {
469 $this->
dieUsageMsg( [
'missingparam',
'filename' ] );
472 if ( $this->mParams[
'chunk'] ) {
475 if ( isset( $this->mParams[
'filekey'] ) ) {
476 if ( $this->mParams[
'offset'] === 0 ) {
477 $this->
dieUsage(
'Cannot supply a filekey when offset is 0',
'badparams' );
481 $this->mUpload->continueChunks(
482 $this->mParams[
'filename'],
483 $this->mParams[
'filekey'],
487 if ( $this->mParams[
'offset'] !== 0 ) {
488 $this->
dieUsage(
'Must supply a filekey when offset is non-zero',
'badparams' );
492 $this->mUpload->initialize(
493 $this->mParams[
'filename'],
497 } elseif ( isset( $this->mParams[
'filekey'] ) ) {
506 $this->mUpload->initialize(
507 $this->mParams[
'filekey'], $this->mParams[
'filename'], !$this->mParams[
'async']
509 } elseif ( isset( $this->mParams[
'file'] ) ) {
511 $this->mUpload->initialize(
512 $this->mParams[
'filename'],
515 } elseif ( isset( $this->mParams[
'url'] ) ) {
530 $this->mUpload->
initialize( $this->mParams[
'filename'],
531 $this->mParams[
'url'] );
544 $permission = $this->mUpload->isAllowed(
$user );
546 if ( $permission !==
true ) {
547 if ( !
$user->isLoggedIn() ) {
548 $this->
dieUsageMsg( [
'mustbeloggedin',
'upload' ] );
555 if (
$user->isBlocked() ) {
560 if (
$user->isBlockedGlobally() ) {
569 $verification = $this->mUpload->verifyUpload();
583 switch ( $verification[
'status'] ) {
590 [
'filename' => $verification[
'filtered'] ] );
604 $this->
dieUsage(
'The file you submitted was empty',
'empty-file' );
607 $this->
dieUsage(
'The file you submitted was too large',
'file-too-large' );
612 'filetype' => $verification[
'finalExt'],
613 'allowed' => array_values( array_unique( $this->
getConfig()->
get(
'FileExtensions' ) ) )
617 $msg =
'Filetype not permitted: ';
618 if ( isset( $verification[
'blacklistedExt'] ) ) {
619 $msg .= implode(
', ', $verification[
'blacklistedExt'] );
620 $extradata[
'blacklisted'] = array_values( $verification[
'blacklistedExt'] );
623 $msg .= $verification[
'finalExt'];
625 $this->
dieUsage( $msg,
'filetype-banned', 0, $extradata );
628 $parsed = $this->
parseMsg( $verification[
'details'] );
629 $info =
"This file did not pass file verification: {$parsed['info']}";
630 if ( $verification[
'details'][0] instanceof
IApiMessage ) {
631 $code = $parsed[
'code'];
635 $code =
'verification-error';
637 if ( $verification[
'details'][0] instanceof IApiMessage ) {
638 $msg = $verification[
'details'][0];
639 $details = array_merge( [ $msg->getKey() ], $msg->getParams() );
641 $details = $verification[
'details'];
644 $data = [
'details' => $details ];
645 if ( isset( $parsed[
'data'] ) ) {
646 $data = array_merge( $data, $parsed[
'data'] );
652 if ( is_array( $verification[
'error'] ) ) {
653 $params = $verification[
'error'];
654 } elseif ( $verification[
'error'] !==
'' ) {
655 $params = [ $verification[
'error'] ];
660 $msg = $this->
msg( $key,
$params )->inLanguage(
'en' )->useDatabase(
false )->text();
661 $this->
dieUsage( $msg,
'hookaborted', 0, [
'details' => $verification[
'error'] ] );
664 $this->
dieUsage(
'An unknown error occurred',
'unknown-error',
665 0, [
'details' => [
'code' => $verification[
'status'] ] ] );
678 $warnings = $this->mUpload->checkWarnings();
688 if ( isset( $warnings[
'duplicate'] ) ) {
691 foreach ( $warnings[
'duplicate']
as $dupe ) {
692 $dupes[] = $dupe->getName();
695 $warnings[
'duplicate'] = $dupes;
698 if ( isset( $warnings[
'exists'] ) ) {
699 $warning = $warnings[
'exists'];
700 unset( $warnings[
'exists'] );
702 $localFile = isset( $warning[
'normalizedFile'] )
703 ? $warning[
'normalizedFile']
705 $warnings[$warning[
'warning']] = $localFile->getName();
708 if ( isset( $warnings[
'no-change'] ) ) {
710 $file = $warnings[
'no-change'];
711 unset( $warnings[
'no-change'] );
713 $warnings[
'nochange'] = [
718 if ( isset( $warnings[
'duplicate-version'] ) ) {
721 foreach ( $warnings[
'duplicate-version']
as $dupe ) {
726 unset( $warnings[
'duplicate-version'] );
729 $warnings[
'duplicateversions'] = $dupes;
743 switch ( $exceptionType ) {
744 case 'UploadStashFileNotFoundException':
746 'Could not find the file in the stash: ' . $message,
747 'stashedfilenotfound'
749 case 'UploadStashBadPathException':
751 'File key of improper format or otherwise invalid: ' . $message,
754 case 'UploadStashFileException':
756 'Could not store upload in the stash: ' . $message,
759 case 'UploadStashZeroLengthFileException':
761 'File is of zero length, and could not be stored in the stash: ' .
765 case 'UploadStashNotLoggedInException':
766 return [
'Not logged in: ' . $message,
'stashnotloggedin' ];
767 case 'UploadStashWrongOwnerException':
768 return [
'Wrong owner: ' . $message,
'stashwrongowner' ];
769 case 'UploadStashNoSuchKeyException':
770 return [
'No such filekey: ' . $message,
'stashnosuchfilekey' ];
772 return [ $exceptionType .
': ' . $message,
'stasherror' ];
785 if ( is_null( $this->mParams[
'text'] ) ) {
786 $this->mParams[
'text'] = $this->mParams[
'comment'];
790 $file = $this->mUpload->getLocalFile();
798 $this->mParams[
'watchlist'], $file->getTitle(),
'watchdefault'
801 if ( !$watch && $this->mParams[
'watchlist'] ==
'preferences' && !$file->exists() ) {
809 if ( $this->mParams[
'watch'] ) {
813 if ( $this->mParams[
'tags'] ) {
821 if ( $this->mParams[
'async'] ) {
823 if ( $progress && $progress[
'result'] ===
'Poll' ) {
824 $this->
dieUsage(
'Upload from stash already in progress.',
'publishfailed' );
828 $this->mParams[
'filekey'],
829 [
'result' =>
'Poll',
'stage' =>
'queued',
'status' =>
Status::newGood() ]
834 'filename' => $this->mParams[
'filename'],
835 'filekey' => $this->mParams[
'filekey'],
836 'comment' => $this->mParams[
'comment'],
837 'tags' => $this->mParams[
'tags'],
838 'text' => $this->mParams[
'text'],
847 $status = $this->mUpload->performUpload( $this->mParams[
'comment'],
848 $this->mParams[
'text'], $watch, $this->
getUser(), $this->mParams[
'tags'] );
852 $errors =
$status->getErrorsByType(
'error' );
853 $msg = array_merge( [ $errors[0][
'message'] ], $errors[0][
'params'] );
854 $data =
$status->getErrorsArray();
863 $result[
'filename'] = $file->getName();
864 if ( $warnings && count( $warnings ) > 0 ) {
865 $result[
'warnings'] = $warnings;
906 'ignorewarnings' =>
false,
931 'checkstatus' =>
false,
943 'action=upload&filename=Wiki.png' .
944 '&url=http%3A//upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png&token=123ABC'
945 =>
'apihelp-upload-example-url',
946 'action=upload&filename=Wiki.png&filekey=filekey&ignorewarnings=1&token=123ABC'
947 =>
'apihelp-upload-example-filekey',
952 return 'https://www.mediawiki.org/wiki/API:Upload';
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below...
initialize($name, $url)
Entry point for API upload.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
getResult()
Get the result object.
Implements uploading from previously stored file.
checkPermissions($user)
Checks that the user has permissions to perform this upload.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
static newFatal($message)
Factory function for fatal errors.
performStash($failureMode, &$data=null)
Stash the file and add the file key, or error information if it fails, to the data.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getMain()
Get the main module.
static getSessionStatus(User $user, $statusKey)
Get the current status of a chunked upload (used for polling)
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
getContextResult()
Get an upload result based on upload context.
getWatchlistValue($watchlist, $titleObj, $userOption=null)
Return true if we're to watch the page, false if not, null if no change.
extractRequestParams($parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user...
requireOnlyOneParameter($params, $required)
Die if none or more than one of a certain set of parameters is set and not false. ...
Interface for messages with machine-readable data for use by the API.
verifyUpload()
Performs file verification, dies on error.
getChunkResult($warnings)
Get the result of a chunk upload.
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
performUpload($warnings)
Perform the actual upload.
dieStatusWithCode($status, $overrideCode, $moreExtraData=null)
Like dieStatus(), but always uses $overrideCode for the error code, unless the code comes from IApiMe...
Implements uploading from a HTTP resource.
static isAllowedHost($url)
Checks whether the URL is for an allowed host The domains in the whitelist can include wildcard chara...
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static getMaxUploadSize($forType=null)
Get the MediaWiki maximum uploaded file size for given type of upload, based on $wgMaxUploadSize.
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.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. '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 '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 '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 '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. '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 IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() '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 Sanitizer::validateEmail(), 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. '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) '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 '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. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED!Use HtmlPageLinkRendererBegin instead.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
getWarningsResult($warnings)
Get Warnings Result.
wfTimestamp($outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static isThrottled($user)
Returns true if the user has surpassed the upload rate limit, false otherwise.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
static isEnabled()
Checks if the upload from URL feature is enabled.
Implements regular file uploads.
Upload a file from the upload stash into the local file repo.
getErrorFromStatus($status, &$extraData=null)
Get error (as code, string) from a Status object.
getStashResult($warnings)
Get Stash Result, throws an exception if the file could not be stashed.
getConfig()
Get the Config object.
getApiWarnings()
Check warnings.
Assemble the segments of a chunked upload.
getContext()
Get the base IContextSource object.
Implements uploading from chunks.
getModuleName()
Get the name of the module being executed by this instance.
static newGood($value=null)
Factory function for good results.
const MIN_LENGTH_PARTNAME
dieRecoverableError($error, $parameter, $data=[], $code= 'unknownerror')
Throw an error that the user can recover from by providing a better value for $parameter.
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
static isEnabled()
Returns true if uploads are enabled.
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 local account $user
transformWarnings($warnings)
static singleton($wiki=false)
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
exportSession()
Export the resolved user IP, HTTP headers, user ID, and session ID.
error also a ContextSource you ll probably need to make sure the header is varied on $request
selectUploadModule()
Select an upload module and set it to mUpload.
static isAllowedUrl($url)
Checks whether the URL is not allowed.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
const WINDOWS_NONASCII_FILENAME
dieUsage($description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
dieBlocked(Block $block)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
Extension of RawMessage implementing IApiMessage.
This abstract class implements many basic API functions, and is the base of all API classes...
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
handleStashException($exceptionType, $message)
Handles a stash exception, giving a useful error to the user.
static setSessionStatus(User $user, $statusKey, $value)
Set the current status of a chunked upload (used for polling)
parseMsg($error)
Return the error message related to a certain array.
checkVerification(array $verification)
Performs file verification, dies on error.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
dieStatus($status)
Throw a UsageException based on the errors in the Status object.
UploadBase UploadFromChunks $mUpload
getUser()
Get the User object.
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
dieUsageMsg($error)
Output the error message related to a certain array.