MediaWiki  1.29.2
MWHttpRequest.php
Go to the documentation of this file.
1 <?php
22 use Psr\Log\LoggerInterface;
23 use Psr\Log\LoggerAwareInterface;
24 use Psr\Log\NullLogger;
25 
33 class MWHttpRequest implements LoggerAwareInterface {
34  const SUPPORTS_FILE_POSTS = false;
35 
36  protected $content;
37  protected $timeout = 'default';
38  protected $headersOnly = null;
39  protected $postData = null;
40  protected $proxy = null;
41  protected $noProxy = false;
42  protected $sslVerifyHost = true;
43  protected $sslVerifyCert = true;
44  protected $caInfo = null;
45  protected $method = "GET";
46  protected $reqHeaders = [];
47  protected $url;
48  protected $parsedUrl;
50  protected $callback;
51  protected $maxRedirects = 5;
52  protected $followRedirects = false;
53  protected $connectTimeout;
54 
58  protected $cookieJar;
59 
60  protected $headerList = [];
61  protected $respVersion = "0.9";
62  protected $respStatus = "200 Ok";
63  protected $respHeaders = [];
64 
66  protected $status;
67 
71  protected $profiler;
72 
76  protected $profileName;
77 
81  protected $logger;
82 
89  protected function __construct(
90  $url, $options = [], $caller = __METHOD__, $profiler = null
91  ) {
92  global $wgHTTPTimeout, $wgHTTPConnectTimeout;
93 
94  $this->url = wfExpandUrl( $url, PROTO_HTTP );
95  $this->parsedUrl = wfParseUrl( $this->url );
96 
97  if ( isset( $options['logger'] ) ) {
98  $this->logger = $options['logger'];
99  } else {
100  $this->logger = new NullLogger();
101  }
102 
103  if ( !$this->parsedUrl || !Http::isValidURI( $this->url ) ) {
104  $this->status = StatusValue::newFatal( 'http-invalid-url', $url );
105  } else {
106  $this->status = StatusValue::newGood( 100 ); // continue
107  }
108 
109  if ( isset( $options['timeout'] ) && $options['timeout'] != 'default' ) {
110  $this->timeout = $options['timeout'];
111  } else {
112  $this->timeout = $wgHTTPTimeout;
113  }
114  if ( isset( $options['connectTimeout'] ) && $options['connectTimeout'] != 'default' ) {
115  $this->connectTimeout = $options['connectTimeout'];
116  } else {
117  $this->connectTimeout = $wgHTTPConnectTimeout;
118  }
119  if ( isset( $options['userAgent'] ) ) {
120  $this->setUserAgent( $options['userAgent'] );
121  }
122  if ( isset( $options['username'] ) && isset( $options['password'] ) ) {
123  $this->setHeader(
124  'Authorization',
125  'Basic ' . base64_encode( $options['username'] . ':' . $options['password'] )
126  );
127  }
128  if ( isset( $options['originalRequest'] ) ) {
129  $this->setOriginalRequest( $options['originalRequest'] );
130  }
131 
132  $members = [ "postData", "proxy", "noProxy", "sslVerifyHost", "caInfo",
133  "method", "followRedirects", "maxRedirects", "sslVerifyCert", "callback" ];
134 
135  foreach ( $members as $o ) {
136  if ( isset( $options[$o] ) ) {
137  // ensure that MWHttpRequest::method is always
138  // uppercased. T38137
139  if ( $o == 'method' ) {
140  $options[$o] = strtoupper( $options[$o] );
141  }
142  $this->$o = $options[$o];
143  }
144  }
145 
146  if ( $this->noProxy ) {
147  $this->proxy = ''; // noProxy takes precedence
148  }
149 
150  // Profile based on what's calling us
151  $this->profiler = $profiler;
152  $this->profileName = $caller;
153  }
154 
158  public function setLogger( LoggerInterface $logger ) {
159  $this->logger = $logger;
160  }
161 
167  public static function canMakeRequests() {
168  return function_exists( 'curl_init' ) || wfIniGetBool( 'allow_url_fopen' );
169  }
170 
180  public static function factory( $url, $options = null, $caller = __METHOD__ ) {
181  if ( !Http::$httpEngine ) {
182  Http::$httpEngine = function_exists( 'curl_init' ) ? 'curl' : 'php';
183  } elseif ( Http::$httpEngine == 'curl' && !function_exists( 'curl_init' ) ) {
184  throw new DomainException( __METHOD__ . ': curl (http://php.net/curl) is not installed, but' .
185  ' Http::$httpEngine is set to "curl"' );
186  }
187 
188  if ( !is_array( $options ) ) {
189  $options = [];
190  }
191 
192  if ( !isset( $options['logger'] ) ) {
193  $options['logger'] = LoggerFactory::getInstance( 'http' );
194  }
195 
196  switch ( Http::$httpEngine ) {
197  case 'curl':
198  return new CurlHttpRequest( $url, $options, $caller, Profiler::instance() );
199  case 'php':
200  if ( !wfIniGetBool( 'allow_url_fopen' ) ) {
201  throw new DomainException( __METHOD__ . ': allow_url_fopen ' .
202  'needs to be enabled for pure PHP http requests to ' .
203  'work. If possible, curl should be used instead. See ' .
204  'http://php.net/curl.'
205  );
206  }
207  return new PhpHttpRequest( $url, $options, $caller, Profiler::instance() );
208  default:
209  throw new DomainException( __METHOD__ . ': The setting of Http::$httpEngine is not valid.' );
210  }
211  }
212 
218  public function getContent() {
219  return $this->content;
220  }
221 
228  public function setData( $args ) {
229  $this->postData = $args;
230  }
231 
237  protected function proxySetup() {
238  // If there is an explicit proxy set and proxies are not disabled, then use it
239  if ( $this->proxy && !$this->noProxy ) {
240  return;
241  }
242 
243  // Otherwise, fallback to $wgHTTPProxy if this is not a machine
244  // local URL and proxies are not disabled
245  if ( self::isLocalURL( $this->url ) || $this->noProxy ) {
246  $this->proxy = '';
247  } else {
248  $this->proxy = Http::getProxy();
249  }
250  }
251 
258  private static function isLocalURL( $url ) {
259  global $wgCommandLineMode, $wgLocalVirtualHosts;
260 
261  if ( $wgCommandLineMode ) {
262  return false;
263  }
264 
265  // Extract host part
266  $matches = [];
267  if ( preg_match( '!^https?://([\w.-]+)[/:].*$!', $url, $matches ) ) {
268  $host = $matches[1];
269  // Split up dotwise
270  $domainParts = explode( '.', $host );
271  // Check if this domain or any superdomain is listed as a local virtual host
272  $domainParts = array_reverse( $domainParts );
273 
274  $domain = '';
275  $countParts = count( $domainParts );
276  for ( $i = 0; $i < $countParts; $i++ ) {
277  $domainPart = $domainParts[$i];
278  if ( $i == 0 ) {
279  $domain = $domainPart;
280  } else {
281  $domain = $domainPart . '.' . $domain;
282  }
283 
284  if ( in_array( $domain, $wgLocalVirtualHosts ) ) {
285  return true;
286  }
287  }
288  }
289 
290  return false;
291  }
292 
297  public function setUserAgent( $UA ) {
298  $this->setHeader( 'User-Agent', $UA );
299  }
300 
306  public function setHeader( $name, $value ) {
307  // I feel like I should normalize the case here...
308  $this->reqHeaders[$name] = $value;
309  }
310 
315  protected function getHeaderList() {
316  $list = [];
317 
318  if ( $this->cookieJar ) {
319  $this->reqHeaders['Cookie'] =
320  $this->cookieJar->serializeToHttpRequest(
321  $this->parsedUrl['path'],
322  $this->parsedUrl['host']
323  );
324  }
325 
326  foreach ( $this->reqHeaders as $name => $value ) {
327  $list[] = "$name: $value";
328  }
329 
330  return $list;
331  }
332 
351  public function setCallback( $callback ) {
352  if ( is_null( $callback ) ) {
353  $callback = [ $this, 'read' ];
354  } elseif ( !is_callable( $callback ) ) {
355  throw new InvalidArgumentException( __METHOD__ . ': invalid callback' );
356  }
357  $this->callback = $callback;
358  }
359 
369  public function read( $fh, $content ) {
370  $this->content .= $content;
371  return strlen( $content );
372  }
373 
380  public function execute() {
381  throw new LogicException( 'children must override this' );
382  }
383 
384  protected function prepare() {
385  $this->content = "";
386 
387  if ( strtoupper( $this->method ) == "HEAD" ) {
388  $this->headersOnly = true;
389  }
390 
391  $this->proxySetup(); // set up any proxy as needed
392 
393  if ( !$this->callback ) {
394  $this->setCallback( null );
395  }
396 
397  if ( !isset( $this->reqHeaders['User-Agent'] ) ) {
398  $this->setUserAgent( Http::userAgent() );
399  }
400  }
401 
407  protected function parseHeader() {
408  $lastname = "";
409 
410  foreach ( $this->headerList as $header ) {
411  if ( preg_match( "#^HTTP/([0-9.]+) (.*)#", $header, $match ) ) {
412  $this->respVersion = $match[1];
413  $this->respStatus = $match[2];
414  } elseif ( preg_match( "#^[ \t]#", $header ) ) {
415  $last = count( $this->respHeaders[$lastname] ) - 1;
416  $this->respHeaders[$lastname][$last] .= "\r\n$header";
417  } elseif ( preg_match( "#^([^:]*):[\t ]*(.*)#", $header, $match ) ) {
418  $this->respHeaders[strtolower( $match[1] )][] = $match[2];
419  $lastname = strtolower( $match[1] );
420  }
421  }
422 
423  $this->parseCookies();
424  }
425 
434  protected function setStatus() {
435  if ( !$this->respHeaders ) {
436  $this->parseHeader();
437  }
438 
439  if ( (int)$this->respStatus > 399 ) {
440  list( $code, $message ) = explode( " ", $this->respStatus, 2 );
441  $this->status->fatal( "http-bad-status", $code, $message );
442  }
443  }
444 
452  public function getStatus() {
453  if ( !$this->respHeaders ) {
454  $this->parseHeader();
455  }
456 
457  return (int)$this->respStatus;
458  }
459 
465  public function isRedirect() {
466  if ( !$this->respHeaders ) {
467  $this->parseHeader();
468  }
469 
470  $status = (int)$this->respStatus;
471 
472  if ( $status >= 300 && $status <= 303 ) {
473  return true;
474  }
475 
476  return false;
477  }
478 
487  public function getResponseHeaders() {
488  if ( !$this->respHeaders ) {
489  $this->parseHeader();
490  }
491 
492  return $this->respHeaders;
493  }
494 
501  public function getResponseHeader( $header ) {
502  if ( !$this->respHeaders ) {
503  $this->parseHeader();
504  }
505 
506  if ( isset( $this->respHeaders[strtolower( $header )] ) ) {
507  $v = $this->respHeaders[strtolower( $header )];
508  return $v[count( $v ) - 1];
509  }
510 
511  return null;
512  }
513 
521  public function setCookieJar( $jar ) {
522  $this->cookieJar = $jar;
523  }
524 
530  public function getCookieJar() {
531  if ( !$this->respHeaders ) {
532  $this->parseHeader();
533  }
534 
535  return $this->cookieJar;
536  }
537 
547  public function setCookie( $name, $value, $attr = [] ) {
548  if ( !$this->cookieJar ) {
549  $this->cookieJar = new CookieJar;
550  }
551 
552  if ( $this->parsedUrl && !isset( $attr['domain'] ) ) {
553  $attr['domain'] = $this->parsedUrl['host'];
554  }
555 
556  $this->cookieJar->setCookie( $name, $value, $attr );
557  }
558 
562  protected function parseCookies() {
563  if ( !$this->cookieJar ) {
564  $this->cookieJar = new CookieJar;
565  }
566 
567  if ( isset( $this->respHeaders['set-cookie'] ) ) {
568  $url = parse_url( $this->getFinalUrl() );
569  foreach ( $this->respHeaders['set-cookie'] as $cookie ) {
570  $this->cookieJar->parseCookieResponseHeader( $cookie, $url['host'] );
571  }
572  }
573  }
574 
591  public function getFinalUrl() {
592  $headers = $this->getResponseHeaders();
593 
594  // return full url (fix for incorrect but handled relative location)
595  if ( isset( $headers['location'] ) ) {
596  $locations = $headers['location'];
597  $domain = '';
598  $foundRelativeURI = false;
599  $countLocations = count( $locations );
600 
601  for ( $i = $countLocations - 1; $i >= 0; $i-- ) {
602  $url = parse_url( $locations[$i] );
603 
604  if ( isset( $url['host'] ) ) {
605  $domain = $url['scheme'] . '://' . $url['host'];
606  break; // found correct URI (with host)
607  } else {
608  $foundRelativeURI = true;
609  }
610  }
611 
612  if ( !$foundRelativeURI ) {
613  return $locations[$countLocations - 1];
614  }
615  if ( $domain ) {
616  return $domain . $locations[$countLocations - 1];
617  }
618  $url = parse_url( $this->url );
619  if ( isset( $url['host'] ) ) {
620  return $url['scheme'] . '://' . $url['host'] .
621  $locations[$countLocations - 1];
622  }
623  }
624 
625  return $this->url;
626  }
627 
633  public function canFollowRedirects() {
634  return true;
635  }
636 
649  public function setOriginalRequest( $originalRequest ) {
650  if ( $originalRequest instanceof WebRequest ) {
651  $originalRequest = [
652  'ip' => $originalRequest->getIP(),
653  'userAgent' => $originalRequest->getHeader( 'User-Agent' ),
654  ];
655  } elseif (
656  !is_array( $originalRequest )
657  || array_diff( [ 'ip', 'userAgent' ], array_keys( $originalRequest ) )
658  ) {
659  throw new InvalidArgumentException( __METHOD__ . ': $originalRequest must be a '
660  . "WebRequest or an array with 'ip' and 'userAgent' keys" );
661  }
662 
663  $this->reqHeaders['X-Forwarded-For'] = $originalRequest['ip'];
664  $this->reqHeaders['X-Original-User-Agent'] = $originalRequest['userAgent'];
665  }
666 }
MWHttpRequest\$headerList
$headerList
Definition: MWHttpRequest.php:60
MWHttpRequest\factory
static factory( $url, $options=null, $caller=__METHOD__)
Generate a new request object.
Definition: MWHttpRequest.php:180
MWHttpRequest\$headersOnly
$headersOnly
Definition: MWHttpRequest.php:38
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: StatusValue.php:42
Http\$httpEngine
static $httpEngine
Definition: Http.php:28
MWHttpRequest\$callback
callable $callback
Definition: MWHttpRequest.php:50
content
per default it will return the text for text based content
Definition: contenthandler.txt:104
MWHttpRequest\setStatus
setStatus()
Sets HTTPRequest status member to a fatal value with the error message if the returned integer value ...
Definition: MWHttpRequest.php:434
MWHttpRequest\$respVersion
$respVersion
Definition: MWHttpRequest.php:61
Profiler\instance
static instance()
Singleton.
Definition: Profiler.php:62
MWHttpRequest\setCookie
setCookie( $name, $value, $attr=[])
Sets a cookie.
Definition: MWHttpRequest.php:547
captcha-old.count
count
Definition: captcha-old.py:225
MWHttpRequest\proxySetup
proxySetup()
Take care of setting up the proxy (do nothing if "noProxy" is set)
Definition: MWHttpRequest.php:237
$last
$last
Definition: profileinfo.php:415
MWHttpRequest\$maxRedirects
$maxRedirects
Definition: MWHttpRequest.php:51
MWHttpRequest\$sslVerifyCert
$sslVerifyCert
Definition: MWHttpRequest.php:43
Http\userAgent
static userAgent()
A standard user-agent we can use for external requests.
Definition: Http.php:129
MWHttpRequest\$followRedirects
$followRedirects
Definition: MWHttpRequest.php:52
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
StatusValue\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:63
MWHttpRequest\setData
setData( $args)
Set the parameters of the request.
Definition: MWHttpRequest.php:228
MWHttpRequest\$content
$content
Definition: MWHttpRequest.php:36
MWHttpRequest\$status
StatusValue $status
Definition: MWHttpRequest.php:66
CurlHttpRequest
MWHttpRequest implemented using internal curl compiled into PHP.
Definition: CurlHttpRequest.php:24
MWHttpRequest\$timeout
$timeout
Definition: MWHttpRequest.php:37
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
php
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
Definition: injection.txt:35
MWHttpRequest\$profiler
Profiler $profiler
Definition: MWHttpRequest.php:71
MWHttpRequest\getStatus
getStatus()
Get the integer value of the HTTP status code (e.g.
Definition: MWHttpRequest.php:452
MWHttpRequest\$noProxy
$noProxy
Definition: MWHttpRequest.php:41
MWHttpRequest\parseHeader
parseHeader()
Parses the headers, including the HTTP status code and any Set-Cookie headers.
Definition: MWHttpRequest.php:407
MWHttpRequest\$connectTimeout
$connectTimeout
Definition: MWHttpRequest.php:53
wfParseUrl
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
Definition: GlobalFunctions.php:818
MWHttpRequest\$postData
$postData
Definition: MWHttpRequest.php:39
MWHttpRequest\getContent
getContent()
Get the body, or content, of the response to the request.
Definition: MWHttpRequest.php:218
MWHttpRequest\SUPPORTS_FILE_POSTS
const SUPPORTS_FILE_POSTS
Definition: MWHttpRequest.php:34
MWHttpRequest\parseCookies
parseCookies()
Parse the cookies in the response headers and store them in the cookie jar.
Definition: MWHttpRequest.php:562
MWHttpRequest\$respStatus
$respStatus
Definition: MWHttpRequest.php:62
CookieJar\setCookie
setCookie( $name, $value, $attr)
Set a cookie in the cookie jar.
Definition: CookieJar.php:36
$wgCommandLineMode
global $wgCommandLineMode
Definition: Setup.php:503
$matches
$matches
Definition: NoLocalSettings.php:24
MWHttpRequest\isRedirect
isRedirect()
Returns true if the last status code was a redirect.
Definition: MWHttpRequest.php:465
Http\getProxy
static getProxy()
Gets the relevant proxy from $wgHTTPProxy.
Definition: Http.php:158
Profiler
Profiler base class that defines the interface and some trivial functionality.
Definition: Profiler.php:33
MWHttpRequest\getCookieJar
getCookieJar()
Returns the cookie jar in use.
Definition: MWHttpRequest.php:530
MWHttpRequest\isLocalURL
static isLocalURL( $url)
Check if the URL can be served by localhost.
Definition: MWHttpRequest.php:258
MWHttpRequest\$reqHeaders
$reqHeaders
Definition: MWHttpRequest.php:46
MWHttpRequest\setCookieJar
setCookieJar( $jar)
Tells the MWHttpRequest object to use this pre-loaded CookieJar.
Definition: MWHttpRequest.php:521
MWHttpRequest\$respHeaders
$respHeaders
Definition: MWHttpRequest.php:63
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
MWHttpRequest\$cookieJar
CookieJar $cookieJar
Definition: MWHttpRequest.php:58
MWHttpRequest\$logger
$logger
Definition: MWHttpRequest.php:81
list
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
Definition: deferred.txt:11
MWHttpRequest\read
read( $fh, $content)
A generic callback to read the body of the response from a remote server.
Definition: MWHttpRequest.php:369
MWHttpRequest\__construct
__construct( $url, $options=[], $caller=__METHOD__, $profiler=null)
Definition: MWHttpRequest.php:89
$value
$value
Definition: styleTest.css.php:45
$header
$header
Definition: updateCredits.php:35
MWHttpRequest\$method
$method
Definition: MWHttpRequest.php:45
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:76
MWHttpRequest
This wrapper class will call out to curl (if available) or fallback to regular PHP if necessary for h...
Definition: MWHttpRequest.php:33
MWHttpRequest\setCallback
setCallback( $callback)
Set a read callback to accept data read from the HTTP request.
Definition: MWHttpRequest.php:351
MWHttpRequest\setHeader
setHeader( $name, $value)
Set an arbitrary header.
Definition: MWHttpRequest.php:306
PROTO_HTTP
const PROTO_HTTP
Definition: Defines.php:217
MWHttpRequest\getHeaderList
getHeaderList()
Get an array of the headers.
Definition: MWHttpRequest.php:315
MWHttpRequest\$parsedUrl
$parsedUrl
Definition: MWHttpRequest.php:48
MWHttpRequest\$profileName
string $profileName
Definition: MWHttpRequest.php:76
MWHttpRequest\getResponseHeaders
getResponseHeaders()
Returns an associative array of response headers after the request has been executed.
Definition: MWHttpRequest.php:487
wfIniGetBool
wfIniGetBool( $setting)
Safety wrapper around ini_get() for boolean settings.
Definition: GlobalFunctions.php:2176
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Definition: WebRequest.php:38
MWHttpRequest\LoggerInterface
LoggerInterface
Definition: MWHttpRequest.php:81
MWHttpRequest\$sslVerifyHost
$sslVerifyHost
Definition: MWHttpRequest.php:42
$args
if( $line===false) $args
Definition: cdb.php:63
$code
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
Definition: hooks.txt:783
CookieJar
Cookie jar to use with MWHttpRequest.
Definition: CookieJar.php:25
MWHttpRequest\$caInfo
$caInfo
Definition: MWHttpRequest.php:44
MWHttpRequest\canMakeRequests
static canMakeRequests()
Simple function to test if we can make any sort of requests at all, using cURL or fopen()
Definition: MWHttpRequest.php:167
as
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
Definition: distributors.txt:9
MWHttpRequest\getResponseHeader
getResponseHeader( $header)
Returns the value of the given response header.
Definition: MWHttpRequest.php:501
MWHttpRequest\setUserAgent
setUserAgent( $UA)
Set the user agent.
Definition: MWHttpRequest.php:297
MWHttpRequest\execute
execute()
Take care of whatever is necessary to perform the URI request.
Definition: MWHttpRequest.php:380
Http\isValidURI
static isValidURI( $uri)
Checks that the given URI is a valid one.
Definition: Http.php:146
LoggerFactory
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
Definition: logger.txt:5
MWHttpRequest\canFollowRedirects
canFollowRedirects()
Returns true if the backend can follow redirects.
Definition: MWHttpRequest.php:633
PhpHttpRequest
Definition: PhpHttpRequest.php:21
MWHttpRequest\$proxy
$proxy
Definition: MWHttpRequest.php:40
MWHttpRequest\setLogger
setLogger(LoggerInterface $logger)
Definition: MWHttpRequest.php:158
MWHttpRequest\getFinalUrl
getFinalUrl()
Returns the final URL after all redirections.
Definition: MWHttpRequest.php:591
$options
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 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
Definition: hooks.txt:1049
MWHttpRequest\setOriginalRequest
setOriginalRequest( $originalRequest)
Set information about the original request.
Definition: MWHttpRequest.php:649
MWHttpRequest\$url
$url
Definition: MWHttpRequest.php:47
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:552
MWHttpRequest\prepare
prepare()
Definition: MWHttpRequest.php:384