63 public static function request( $method, $url,
$options = [], $caller = __METHOD__ ) {
64 wfDebug(
"HTTP: $method: $url\n" );
66 $options[
'method'] = strtoupper( $method );
68 if ( !isset(
$options[
'timeout'] ) ) {
71 if ( !isset(
$options[
'connectTimeout'] ) ) {
72 $options[
'connectTimeout'] =
'default';
79 return $req->getContent();
81 $errors =
$status->getErrorsByType(
'error' );
82 $logger = LoggerFactory::getInstance(
'http' );
83 $logger->warning(
$status->getWikiText(
false,
false,
'en' ),
84 [
'error' => $errors,
'caller' => $caller,
'content' =>
$req->getContent() ] );
100 public static function get( $url,
$options = [], $caller = __METHOD__ ) {
101 $args = func_get_args();
102 if ( isset(
$args[1] ) && ( is_string(
$args[1] ) || is_numeric(
$args[1] ) ) ) {
105 wfWarn(
"Second parameter should not be a timeout.", 2 );
109 $caller = __METHOD__;
123 public static function post( $url,
$options = [], $caller = __METHOD__ ) {
133 return "MediaWiki/$wgVersion";
150 '/^https?:\/\/[^\/\s]\S*$/D',
163 if ( $wgHTTPProxy ) {
241 $this->timeout =
$options[
'timeout'];
245 if ( isset(
$options[
'connectTimeout'] ) &&
$options[
'connectTimeout'] !=
'default' ) {
246 $this->connectTimeout =
$options[
'connectTimeout'];
250 if ( isset(
$options[
'userAgent'] ) ) {
254 $members = [
"postData",
"proxy",
"noProxy",
"sslVerifyHost",
"caInfo",
255 "method",
"followRedirects",
"maxRedirects",
"sslVerifyCert",
"callback" ];
257 foreach ( $members
as $o ) {
261 if ( $o ==
'method' ) {
268 if ( $this->noProxy ) {
274 $this->profileName = $caller;
283 return function_exists(
'curl_init' ) ||
wfIniGetBool(
'allow_url_fopen' );
299 throw new MWException( __METHOD__ .
': curl (http://php.net/curl) is not installed, but' .
300 ' Http::$httpEngine is set to "curl"' );
308 throw new MWException( __METHOD__ .
': allow_url_fopen ' .
309 'needs to be enabled for pure PHP http requests to ' .
310 'work. If possible, curl should be used instead. See ' .
311 'http://php.net/curl.'
316 throw new MWException( __METHOD__ .
': The setting of Http::$httpEngine is not valid.' );
336 $this->postData =
$args;
346 if ( $this->proxy && !$this->noProxy ) {
352 if ( self::isLocalURL( $this->url ) || $this->noProxy ) {
368 if ( $wgCommandLineMode ) {
374 if ( preg_match(
'!^https?://([\w.-]+)[/:].*$!',
$url,
$matches ) ) {
377 $domainParts = explode(
'.', $host );
379 $domainParts = array_reverse( $domainParts );
382 $countParts = count( $domainParts );
383 for ( $i = 0; $i < $countParts; $i++ ) {
384 $domainPart = $domainParts[$i];
386 $domain = $domainPart;
388 $domain = $domainPart .
'.' . $domain;
391 if ( in_array( $domain, $wgLocalVirtualHosts ) ) {
425 if ( $this->cookieJar ) {
426 $this->reqHeaders[
'Cookie'] =
427 $this->cookieJar->serializeToHttpRequest(
428 $this->parsedUrl[
'path'],
429 $this->parsedUrl[
'host']
434 $list[] =
"$name: $value";
460 throw new MWException(
'Invalid MwHttpRequest callback' );
487 if ( strtoupper( $this->method ) ==
"HEAD" ) {
488 $this->headersOnly =
true;
493 if ( !$this->callback ) {
497 if ( !isset( $this->reqHeaders[
'User-Agent'] ) ) {
512 foreach ( $this->headerList
as $header ) {
513 if ( preg_match(
"#^HTTP/([0-9.]+) (.*)#", $header, $match ) ) {
514 $this->respVersion = $match[1];
515 $this->respStatus = $match[2];
516 } elseif ( preg_match(
"#^[ \t]#", $header ) ) {
517 $last = count( $this->respHeaders[$lastname] ) - 1;
518 $this->respHeaders[$lastname][
$last] .=
"\r\n$header";
519 } elseif ( preg_match(
"#^([^:]*):[\t ]*(.*)#", $header, $match ) ) {
520 $this->respHeaders[strtolower( $match[1] )][] = $match[2];
521 $lastname = strtolower( $match[1] );
538 if ( !$this->respHeaders ) {
542 if ( (
int)$this->respStatus > 399 ) {
543 list(
$code, $message ) = explode(
" ", $this->respStatus, 2 );
544 $this->status->fatal(
"http-bad-status",
$code, $message );
556 if ( !$this->respHeaders ) {
569 if ( !$this->respHeaders ) {
573 $status = (int)$this->respStatus;
591 if ( !$this->respHeaders ) {
605 if ( !$this->respHeaders ) {
609 if ( isset( $this->respHeaders[strtolower( $header )] ) ) {
610 $v = $this->respHeaders[strtolower( $header )];
611 return $v[count( $v ) - 1];
623 $this->cookieJar = $jar;
632 if ( !$this->respHeaders ) {
649 if ( !$this->cookieJar ) {
661 if ( !$this->cookieJar ) {
665 if ( isset( $this->respHeaders[
'set-cookie'] ) ) {
667 foreach ( $this->respHeaders[
'set-cookie']
as $cookie ) {
668 $this->cookieJar->parseCookieResponseHeader( $cookie,
$url[
'host'] );
694 if ( isset( $headers[
'location'] ) ) {
695 $locations = $headers[
'location'];
697 $foundRelativeURI =
false;
698 $countLocations = count( $locations );
700 for ( $i = $countLocations - 1; $i >= 0; $i-- ) {
701 $url = parse_url( $locations[$i] );
703 if ( isset(
$url[
'host'] ) ) {
704 $domain =
$url[
'scheme'] .
'://' .
$url[
'host'];
707 $foundRelativeURI =
true;
711 if ( $foundRelativeURI ) {
713 return $domain . $locations[$countLocations - 1];
715 $url = parse_url( $this->url );
716 if ( isset(
$url[
'host'] ) ) {
717 return $url[
'scheme'] .
'://' .
$url[
'host'] .
718 $locations[$countLocations - 1];
722 return $locations[$countLocations - 1];
762 if ( !$this->status->isOK() ) {
770 if ( defined(
'CURLOPT_CONNECTTIMEOUT_MS' ) ) {
771 $this->curlOptions[CURLOPT_CONNECTTIMEOUT_MS] = $this->connectTimeout * 1000;
774 $this->curlOptions[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0;
776 $this->curlOptions[CURLOPT_HEADERFUNCTION] = [ $this,
"readHeader" ];
778 $this->curlOptions[CURLOPT_ENCODING] =
""; # Enable compression
780 $this->curlOptions[CURLOPT_USERAGENT] = $this->reqHeaders[
'User-Agent'];
782 $this->curlOptions[CURLOPT_SSL_VERIFYHOST] = $this->sslVerifyHost ? 2 : 0;
785 if ( $this->caInfo ) {
789 if ( $this->headersOnly ) {
790 $this->curlOptions[CURLOPT_NOBODY] =
true;
791 $this->curlOptions[CURLOPT_HEADER] =
true;
792 } elseif ( $this->method ==
'POST' ) {
793 $this->curlOptions[CURLOPT_POST] =
true;
800 if ( defined(
'CURLOPT_SAFE_UPLOAD' ) ) {
801 $this->curlOptions[CURLOPT_SAFE_UPLOAD] =
true;
808 $this->curlOptions[CURLOPT_POSTFIELDS] =
$postData;
813 $this->reqHeaders[
'Expect'] =
'';
818 $this->curlOptions[CURLOPT_HTTPHEADER] = $this->
getHeaderList();
820 $curlHandle = curl_init( $this->url );
822 if ( !curl_setopt_array( $curlHandle, $this->curlOptions ) ) {
823 throw new MWException(
"Error setting curl options." );
827 MediaWiki\suppressWarnings();
828 if ( !curl_setopt( $curlHandle, CURLOPT_FOLLOWLOCATION,
true ) ) {
829 wfDebug( __METHOD__ .
": Couldn't set CURLOPT_FOLLOWLOCATION. " .
830 "Probably open_basedir is set.\n" );
834 MediaWiki\restoreWarnings();
837 if ( $this->profiler ) {
838 $profileSection = $this->profiler->scopedProfileIn(
839 __METHOD__ .
'-' . $this->profileName
843 $curlRes = curl_exec( $curlHandle );
844 if ( curl_errno( $curlHandle ) == CURLE_OPERATION_TIMEOUTED ) {
845 $this->status->fatal(
'http-timed-out', $this->url );
846 } elseif ( $curlRes ===
false ) {
847 $this->status->fatal(
'http-curl-error', curl_error( $curlHandle ) );
849 $this->headerList = explode(
"\r\n", $this->headerText );
852 curl_close( $curlHandle );
854 if ( $this->profiler ) {
855 $this->profiler->scopedProfileOut( $profileSection );
868 $curlVersionInfo = curl_version();
869 if ( $curlVersionInfo[
'version_number'] < 0x071304 ) {
870 wfDebug(
"Cannot follow redirects with libcurl < 7.19.4 due to CVE-2009-0037\n" );
874 if ( version_compare( PHP_VERSION,
'5.6.0',
'<' ) ) {
875 if ( strval( ini_get(
'open_basedir' ) ) !==
'' ) {
876 wfDebug(
"Cannot follow redirects when open_basedir is set\n" );
911 if ( $this->caInfo ) {
913 } elseif ( version_compare( PHP_VERSION,
'5.6.0',
'<' ) ) {
921 $certLocations = array_filter( [
922 getenv(
'SSL_CERT_DIR' ),
923 getenv(
'SSL_CERT_PATH' ),
924 '/etc/pki/tls/certs/ca-bundle.crt', # Fedora et al
925 '/etc/ssl/certs', #
Debian et al
926 '/etc/pki/tls/certs/ca-bundle.trust.crt',
927 '/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem',
928 '/System/Library/OpenSSL', # OSX
932 foreach ( $certLocations
as $key => $cert ) {
933 if ( is_dir( $cert ) ) {
934 $certOptions[
'capath'] = $cert;
936 } elseif ( is_file( $cert ) ) {
937 $certOptions[
'cafile'] = $cert;
939 } elseif ( $key ===
'manual' ) {
941 throw new DomainException(
"Invalid CA info passed: $cert" );
956 $n = count( $this->fopenErrors ) + 1;
957 $this->fopenErrors += [
"errno$n" => $errno,
"errstr$n" => $errstr ];
964 if ( is_array( $this->postData ) ) {
968 if ( $this->parsedUrl[
'scheme'] !=
'http'
969 && $this->parsedUrl[
'scheme'] !=
'https' ) {
970 $this->status->fatal(
'http-invalid-scheme', $this->parsedUrl[
'scheme'] );
973 $this->reqHeaders[
'Accept'] =
"*/*";
974 $this->reqHeaders[
'Connection'] =
'Close';
975 if ( $this->method ==
'POST' ) {
977 $this->reqHeaders[
'Content-Length'] = strlen( $this->postData );
978 if ( !isset( $this->reqHeaders[
'Content-Type'] ) ) {
979 $this->reqHeaders[
'Content-Type'] =
"application/x-www-form-urlencoded";
988 'protocol_version' =>
'1.1',
989 'max_redirects' => $this->followRedirects ? $this->maxRedirects : 0,
990 'ignore_errors' =>
true,
993 'curl_verify_ssl_host' => $this->sslVerifyHost ? 2 : 0,
998 'SNI_enabled' =>
true,
999 'ciphers' =>
'HIGH:!SSLv2:!SSLv3:-ADH:-kDH:-kECDH:-DSS',
1000 'disable_compression' =>
true,
1004 if ( $this->proxy ) {
1006 $options[
'http'][
'request_fulluri'] =
true;
1009 if ( $this->postData ) {
1013 if ( $this->sslVerifyHost ) {
1016 if ( version_compare( PHP_VERSION,
'5.6.0',
'>=' ) ) {
1017 $options[
'ssl'][
'peer_name'] = $this->parsedUrl[
'host'];
1019 $options[
'ssl'][
'CN_match'] = $this->parsedUrl[
'host'];
1027 $this->headerList = [];
1033 if ( $this->profiler ) {
1034 $profileSection = $this->profiler->scopedProfileIn(
1035 __METHOD__ .
'-' . $this->profileName
1040 $this->fopenErrors = [];
1041 set_error_handler( [ $this,
'errorHandler' ] );
1043 restore_error_handler();
1051 if ( isset(
$options[
'ssl'][
'CN_match'] )
1052 && (
$options[
'ssl'][
'CN_match'] ===
'commons.wikimedia.org'
1053 ||
$options[
'ssl'][
'CN_match'] ===
'upload.wikimedia.org' )
1055 $options[
'ssl'][
'CN_match'] =
'en.wikipedia.org';
1062 $result = stream_get_meta_data( $fh );
1063 $this->headerList =
$result[
'wrapper_data'];
1066 if ( !$this->followRedirects ) {
1070 # Handle manual redirection
1071 if ( !$this->
isRedirect() || $reqCount > $this->maxRedirects ) {
1074 # Check security of URL
1078 wfDebug( __METHOD__ .
": insecure redirection\n" );
1082 if ( $this->profiler ) {
1083 $this->profiler->scopedProfileOut( $profileSection );
1088 if ( $fh ===
false ) {
1089 if ( $this->fopenErrors ) {
1090 LoggerFactory::getInstance(
'http' )->warning( __CLASS__
1091 .
': error opening connection: {errstr1}', $this->fopenErrors );
1093 $this->status->fatal(
'http-request-error' );
1098 $this->status->fatal(
'http-timed-out', $this->url );
1104 if ( $this->status->isOK() || (int)$this->respStatus >= 300 ) {
1105 while ( !feof( $fh ) ) {
1106 $buf = fread( $fh, 8192 );
1108 if ( $buf ===
false ) {
1109 $this->status->fatal(
'http-read-error' );
1113 if ( strlen( $buf ) ) {
1114 call_user_func( $this->callback, $fh, $buf );
readHeader($fh, $content)
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
proxySetup()
Take care of setting up the proxy (do nothing if "noProxy" is set)
$wgVersion
MediaWiki version number.
setCookie($name, $value=null, $attr=null)
Sets a cookie.
static getProxy()
Gets the relevant proxy from $wgHTTPProxy.
execute()
Take care of whatever is necessary to perform the URI request.
per default it will return the text for text based content
canFollowRedirects()
Returns true if the backend can follow redirects.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for h...
setHeader($name, $value)
Set an arbitrary header.
static instance()
Singleton.
setCookieJar($jar)
Tells the MWHttpRequest object to use this pre-loaded CookieJar.
isRedirect()
Returns true if the last status code was a redirect.
$wgHTTPTimeout
Timeout for HTTP requests done internally, in seconds.
static isLocalURL($url)
Check if the URL can be served by localhost.
when a variable name is used in a it is silently declared as a new local masking the global
wfExpandUrl($url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
static newFatal($message)
Factory function for fatal errors.
static canMakeRequests()
Simple function to test if we can make any sort of requests at all, using cURL or fopen() ...
$wgHTTPProxy
Proxy to use for CURL requests.
MWHttpRequest implemented using internal curl compiled into PHP.
static request($method, $url, $options=[], $caller=__METHOD__)
Perform an HTTP request.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
static userAgent()
A standard user-agent we can use for external requests.
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
parseCookies()
Parse the cookies in the response headers and store them in the cookie jar.
const SUPPORTS_FILE_POSTS
global $wgCommandLineMode
getCookieJar()
Returns the cookie jar in use.
getHeaderList()
Get an array of the headers.
getFinalUrl()
Returns the final URL after all redirections.
wfWarn($msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfIniGetBool($setting)
Safety wrapper around ini_get() for boolean settings.
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 and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
__construct($url, $options=[], $caller=__METHOD__, $profiler=null)
errorHandler($errno, $errstr)
Custom error handler for dealing with fopen() errors.
const SUPPORTS_FILE_POSTS
read($fh, $content)
A generic callback to read the body of the response from a remote server.
Various HTTP related functions.
getCertOptions()
Returns an array with a 'capath' or 'cafile' key that is suitable to be merged into the 'ssl' sub-arr...
setStatus()
Sets HTTPRequest status member to a fatal value with the error message if the returned integer value ...
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy like it should help lighten the load on the database servers by caching data and objects in Debian
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
setCallback($callback)
Set a read callback to accept data read from the HTTP request.
getResponseHeaders()
Returns an associative array of response headers after the request has been executed.
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
getStatus()
Get the integer value of the HTTP status code (e.g.
$wgLocalVirtualHosts
Local virtual hosts.
parseHeader()
Parses the headers, including the HTTP status code and any Set-Cookie headers.
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 hook is for auditing only $req
$wgHTTPConnectTimeout
Timeout for connections done internally (in seconds) Only works for curl.
setUserAgent($UA)
Set the user agent.
wfArrayToCgi($array1, $array2=null, $prefix= '')
This function takes one or two arrays as input, and returns a CGI-style string, e.g.
static post($url, $options=[], $caller=__METHOD__)
Simple wrapper for Http::request( 'POST' )
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
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method.MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances.The"Spi"in MediaWiki\Logger\Spi stands for"service provider interface".An SPI is an API intended to be implemented or extended by a third party.This software design pattern is intended to enable framework extension and replaceable components.It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki.The service provider interface allows the backend logging library to be implemented in multiple ways.The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime.This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance.Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
static factory($url, $options=null, $caller=__METHOD__)
Generate a new request object.
getContent()
Get the body, or content, of the response to the request.
wfParseUrl($url)
parse_url() work-alike, but non-broken.
setData($args)
Set the parameters of the request.
setCookie($name, $value, $attr)
Set a cookie in the cookie jar.
static isValidURI($uri)
Checks that the given URI is a valid one.
getResponseHeader($header)
Returns the value of the given response header.
static newGood($value=null)
Factory function for good results.
Allows to change the fields on the form that will be generated $name