MediaWiki  REL1_31
ServiceWiring.php
Go to the documentation of this file.
1 <?php
51 use Wikimedia\ObjectFactory;
52 
53 return [
54  'DBLoadBalancerFactory' => function ( MediaWikiServices $services ) {
55  $mainConfig = $services->getMainConfig();
56 
58  $mainConfig->get( 'LBFactoryConf' ),
59  $mainConfig,
60  $services->getConfiguredReadOnlyMode()
61  );
62  $class = MWLBFactory::getLBFactoryClass( $lbConf );
63 
64  $instance = new $class( $lbConf );
65  MWLBFactory::setSchemaAliases( $instance, $mainConfig );
66 
67  return $instance;
68  },
69 
70  'DBLoadBalancer' => function ( MediaWikiServices $services ) {
71  // just return the default LB from the DBLoadBalancerFactory service
72  return $services->getDBLoadBalancerFactory()->getMainLB();
73  },
74 
75  'SiteStore' => function ( MediaWikiServices $services ) {
76  $rawSiteStore = new DBSiteStore( $services->getDBLoadBalancer() );
77 
78  // TODO: replace wfGetCache with a CacheFactory service.
79  // TODO: replace wfIsHHVM with a capabilities service.
81 
82  return new CachingSiteStore( $rawSiteStore, $cache );
83  },
84 
85  'SiteLookup' => function ( MediaWikiServices $services ) {
86  $cacheFile = $services->getMainConfig()->get( 'SitesCacheFile' );
87 
88  if ( $cacheFile !== false ) {
89  return new FileBasedSiteLookup( $cacheFile );
90  } else {
91  // Use the default SiteStore as the SiteLookup implementation for now
92  return $services->getSiteStore();
93  }
94  },
95 
96  'ConfigFactory' => function ( MediaWikiServices $services ) {
97  // Use the bootstrap config to initialize the ConfigFactory.
98  $registry = $services->getBootstrapConfig()->get( 'ConfigRegistry' );
99  $factory = new ConfigFactory();
100 
101  foreach ( $registry as $name => $callback ) {
102  $factory->register( $name, $callback );
103  }
104  return $factory;
105  },
106 
107  'MainConfig' => function ( MediaWikiServices $services ) {
108  // Use the 'main' config from the ConfigFactory service.
109  return $services->getConfigFactory()->makeConfig( 'main' );
110  },
111 
112  'InterwikiLookup' => function ( MediaWikiServices $services ) {
113  global $wgContLang; // TODO: manage $wgContLang as a service
114  $config = $services->getMainConfig();
115  return new ClassicInterwikiLookup(
116  $wgContLang,
117  $services->getMainWANObjectCache(),
118  $config->get( 'InterwikiExpiry' ),
119  $config->get( 'InterwikiCache' ),
120  $config->get( 'InterwikiScopes' ),
121  $config->get( 'InterwikiFallbackSite' )
122  );
123  },
124 
125  'StatsdDataFactory' => function ( MediaWikiServices $services ) {
126  return new BufferingStatsdDataFactory(
127  rtrim( $services->getMainConfig()->get( 'StatsdMetricPrefix' ), '.' )
128  );
129  },
130 
131  'EventRelayerGroup' => function ( MediaWikiServices $services ) {
132  return new EventRelayerGroup( $services->getMainConfig()->get( 'EventRelayerConfig' ) );
133  },
134 
135  'SearchEngineFactory' => function ( MediaWikiServices $services ) {
136  return new SearchEngineFactory( $services->getSearchEngineConfig() );
137  },
138 
139  'SearchEngineConfig' => function ( MediaWikiServices $services ) {
141  return new SearchEngineConfig( $services->getMainConfig(), $wgContLang );
142  },
143 
144  'SkinFactory' => function ( MediaWikiServices $services ) {
145  $factory = new SkinFactory();
146 
147  $names = $services->getMainConfig()->get( 'ValidSkinNames' );
148 
149  foreach ( $names as $name => $skin ) {
150  $factory->register( $name, $skin, function () use ( $name, $skin ) {
151  $class = "Skin$skin";
152  return new $class( $name );
153  } );
154  }
155  // Register a hidden "fallback" skin
156  $factory->register( 'fallback', 'Fallback', function () {
157  return new SkinFallback;
158  } );
159  // Register a hidden skin for api output
160  $factory->register( 'apioutput', 'ApiOutput', function () {
161  return new SkinApi;
162  } );
163 
164  return $factory;
165  },
166 
167  'WatchedItemStore' => function ( MediaWikiServices $services ) {
168  $store = new WatchedItemStore(
169  $services->getDBLoadBalancer(),
170  new HashBagOStuff( [ 'maxKeys' => 100 ] ),
171  $services->getReadOnlyMode(),
172  $services->getMainConfig()->get( 'UpdateRowsPerQuery' )
173  );
174  $store->setStatsdDataFactory( $services->getStatsdDataFactory() );
175 
176  if ( $services->getMainConfig()->get( 'ReadOnlyWatchedItemStore' ) ) {
177  $store = new NoWriteWatchedItemStore( $store );
178  }
179 
180  return $store;
181  },
182 
183  'WatchedItemQueryService' => function ( MediaWikiServices $services ) {
184  return new WatchedItemQueryService(
185  $services->getDBLoadBalancer(),
186  $services->getCommentStore(),
187  $services->getActorMigration()
188  );
189  },
190 
191  'CryptRand' => function ( MediaWikiServices $services ) {
192  $secretKey = $services->getMainConfig()->get( 'SecretKey' );
193  return new CryptRand(
194  [
195  // To try vary the system information of the state a bit more
196  // by including the system's hostname into the state
197  'wfHostname',
198  // It's mostly worthless but throw the wiki's id into the data
199  // for a little more variance
200  'wfWikiID',
201  // If we have a secret key set then throw it into the state as well
202  function () use ( $secretKey ) {
203  return $secretKey ?: '';
204  }
205  ],
206  // The config file is likely the most often edited file we know should
207  // be around so include its stat info into the state.
208  // The constant with its location will almost always be defined, as
209  // WebStart.php defines MW_CONFIG_FILE to $IP/LocalSettings.php unless
210  // being configured with MW_CONFIG_CALLBACK (e.g. the installer).
211  defined( 'MW_CONFIG_FILE' ) ? [ MW_CONFIG_FILE ] : [],
212  LoggerFactory::getInstance( 'CryptRand' )
213  );
214  },
215 
216  'CryptHKDF' => function ( MediaWikiServices $services ) {
217  $config = $services->getMainConfig();
218 
219  $secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
220  if ( !$secret ) {
221  throw new RuntimeException( "Cannot use MWCryptHKDF without a secret." );
222  }
223 
224  // In HKDF, the context can be known to the attacker, but this will
225  // keep simultaneous runs from producing the same output.
226  $context = [ microtime(), getmypid(), gethostname() ];
227 
228  // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
229  $cache = $services->getLocalServerObjectCache();
230  if ( $cache instanceof EmptyBagOStuff ) {
232  }
233 
234  return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ),
235  $cache, $context, $services->getCryptRand()
236  );
237  },
238 
239  'MediaHandlerFactory' => function ( MediaWikiServices $services ) {
240  return new MediaHandlerFactory(
241  $services->getMainConfig()->get( 'MediaHandlers' )
242  );
243  },
244 
245  'MimeAnalyzer' => function ( MediaWikiServices $services ) {
246  $logger = LoggerFactory::getInstance( 'Mime' );
247  $mainConfig = $services->getMainConfig();
248  $params = [
249  'typeFile' => $mainConfig->get( 'MimeTypeFile' ),
250  'infoFile' => $mainConfig->get( 'MimeInfoFile' ),
251  'xmlTypes' => $mainConfig->get( 'XMLMimeTypes' ),
252  'guessCallback' =>
253  function ( $mimeAnalyzer, &$head, &$tail, $file, &$mime ) use ( $logger ) {
254  // Also test DjVu
255  $deja = new DjVuImage( $file );
256  if ( $deja->isValid() ) {
257  $logger->info( __METHOD__ . ": detected $file as image/vnd.djvu\n" );
258  $mime = 'image/vnd.djvu';
259 
260  return;
261  }
262  // Some strings by reference for performance - assuming well-behaved hooks
263  Hooks::run(
264  'MimeMagicGuessFromContent',
265  [ $mimeAnalyzer, &$head, &$tail, $file, &$mime ]
266  );
267  },
268  'extCallback' => function ( $mimeAnalyzer, $ext, &$mime ) {
269  // Media handling extensions can improve the MIME detected
270  Hooks::run( 'MimeMagicImproveFromExtension', [ $mimeAnalyzer, $ext, &$mime ] );
271  },
272  'initCallback' => function ( $mimeAnalyzer ) {
273  // Allow media handling extensions adding MIME-types and MIME-info
274  Hooks::run( 'MimeMagicInit', [ $mimeAnalyzer ] );
275  },
276  'logger' => $logger
277  ];
278 
279  if ( $params['infoFile'] === 'includes/mime.info' ) {
280  $params['infoFile'] = __DIR__ . "/libs/mime/mime.info";
281  }
282 
283  if ( $params['typeFile'] === 'includes/mime.types' ) {
284  $params['typeFile'] = __DIR__ . "/libs/mime/mime.types";
285  }
286 
287  $detectorCmd = $mainConfig->get( 'MimeDetectorCommand' );
288  if ( $detectorCmd ) {
289  $factory = $services->getShellCommandFactory();
290  $params['detectCallback'] = function ( $file ) use ( $detectorCmd, $factory ) {
291  $result = $factory->create()
292  // $wgMimeDetectorCommand can contain commands with parameters
293  ->unsafeParams( $detectorCmd )
294  ->params( $file )
295  ->execute();
296  return $result->getStdout();
297  };
298  }
299 
300  // XXX: MimeMagic::singleton currently requires this service to return an instance of MimeMagic
301  return new MimeMagic( $params );
302  },
303 
304  'ProxyLookup' => function ( MediaWikiServices $services ) {
305  $mainConfig = $services->getMainConfig();
306  return new ProxyLookup(
307  $mainConfig->get( 'SquidServers' ),
308  $mainConfig->get( 'SquidServersNoPurge' )
309  );
310  },
311 
312  'Parser' => function ( MediaWikiServices $services ) {
313  $conf = $services->getMainConfig()->get( 'ParserConf' );
314  return ObjectFactory::constructClassInstance( $conf['class'], [ $conf ] );
315  },
316 
317  'ParserCache' => function ( MediaWikiServices $services ) {
318  $config = $services->getMainConfig();
319  $cache = ObjectCache::getInstance( $config->get( 'ParserCacheType' ) );
320  wfDebugLog( 'caches', 'parser: ' . get_class( $cache ) );
321 
322  return new ParserCache(
323  $cache,
324  $config->get( 'CacheEpoch' )
325  );
326  },
327 
328  'LinkCache' => function ( MediaWikiServices $services ) {
329  return new LinkCache(
330  $services->getTitleFormatter(),
331  $services->getMainWANObjectCache()
332  );
333  },
334 
335  'LinkRendererFactory' => function ( MediaWikiServices $services ) {
336  return new LinkRendererFactory(
337  $services->getTitleFormatter(),
338  $services->getLinkCache()
339  );
340  },
341 
342  'LinkRenderer' => function ( MediaWikiServices $services ) {
343  global $wgUser;
344 
345  if ( defined( 'MW_NO_SESSION' ) ) {
346  return $services->getLinkRendererFactory()->create();
347  } else {
348  return $services->getLinkRendererFactory()->createForUser( $wgUser );
349  }
350  },
351 
352  'GenderCache' => function ( MediaWikiServices $services ) {
353  return new GenderCache();
354  },
355 
356  '_MediaWikiTitleCodec' => function ( MediaWikiServices $services ) {
358 
359  return new MediaWikiTitleCodec(
360  $wgContLang,
361  $services->getGenderCache(),
362  $services->getMainConfig()->get( 'LocalInterwikis' )
363  );
364  },
365 
366  'TitleFormatter' => function ( MediaWikiServices $services ) {
367  return $services->getService( '_MediaWikiTitleCodec' );
368  },
369 
370  'TitleParser' => function ( MediaWikiServices $services ) {
371  return $services->getService( '_MediaWikiTitleCodec' );
372  },
373 
374  'MainObjectStash' => function ( MediaWikiServices $services ) {
375  $mainConfig = $services->getMainConfig();
376 
377  $id = $mainConfig->get( 'MainStash' );
378  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
379  throw new UnexpectedValueException(
380  "Cache type \"$id\" is not present in \$wgObjectCaches." );
381  }
382 
383  return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
384  },
385 
386  'MainWANObjectCache' => function ( MediaWikiServices $services ) {
387  $mainConfig = $services->getMainConfig();
388 
389  $id = $mainConfig->get( 'MainWANCache' );
390  if ( !isset( $mainConfig->get( 'WANObjectCaches' )[$id] ) ) {
391  throw new UnexpectedValueException(
392  "WAN cache type \"$id\" is not present in \$wgWANObjectCaches." );
393  }
394 
395  $params = $mainConfig->get( 'WANObjectCaches' )[$id];
396  $objectCacheId = $params['cacheId'];
397  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$objectCacheId] ) ) {
398  throw new UnexpectedValueException(
399  "Cache type \"$objectCacheId\" is not present in \$wgObjectCaches." );
400  }
401  $params['store'] = $mainConfig->get( 'ObjectCaches' )[$objectCacheId];
402 
403  return \ObjectCache::newWANCacheFromParams( $params );
404  },
405 
406  'LocalServerObjectCache' => function ( MediaWikiServices $services ) {
407  $mainConfig = $services->getMainConfig();
408 
409  if ( function_exists( 'apc_fetch' ) ) {
410  $id = 'apc';
411  } elseif ( function_exists( 'apcu_fetch' ) ) {
412  $id = 'apcu';
413  } elseif ( function_exists( 'wincache_ucache_get' ) ) {
414  $id = 'wincache';
415  } else {
416  $id = CACHE_NONE;
417  }
418 
419  if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
420  throw new UnexpectedValueException(
421  "Cache type \"$id\" is not present in \$wgObjectCaches." );
422  }
423 
424  return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
425  },
426 
427  'VirtualRESTServiceClient' => function ( MediaWikiServices $services ) {
428  $config = $services->getMainConfig()->get( 'VirtualRestConfig' );
429 
430  $vrsClient = new VirtualRESTServiceClient( new MultiHttpClient( [] ) );
431  foreach ( $config['paths'] as $prefix => $serviceConfig ) {
432  $class = $serviceConfig['class'];
433  // Merge in the global defaults
434  $constructArg = isset( $serviceConfig['options'] )
435  ? $serviceConfig['options']
436  : [];
437  $constructArg += $config['global'];
438  // Make the VRS service available at the mount point
439  $vrsClient->mount( $prefix, [ 'class' => $class, 'config' => $constructArg ] );
440  }
441 
442  return $vrsClient;
443  },
444 
445  'ConfiguredReadOnlyMode' => function ( MediaWikiServices $services ) {
446  return new ConfiguredReadOnlyMode( $services->getMainConfig() );
447  },
448 
449  'ReadOnlyMode' => function ( MediaWikiServices $services ) {
450  return new ReadOnlyMode(
451  $services->getConfiguredReadOnlyMode(),
452  $services->getDBLoadBalancer()
453  );
454  },
455 
456  'UploadRevisionImporter' => function ( MediaWikiServices $services ) {
458  $services->getMainConfig()->get( 'EnableUploads' ),
459  LoggerFactory::getInstance( 'UploadRevisionImporter' )
460  );
461  },
462 
463  'OldRevisionImporter' => function ( MediaWikiServices $services ) {
465  true,
466  LoggerFactory::getInstance( 'OldRevisionImporter' ),
467  $services->getDBLoadBalancer()
468  );
469  },
470 
471  'WikiRevisionOldRevisionImporterNoUpdates' => function ( MediaWikiServices $services ) {
473  false,
474  LoggerFactory::getInstance( 'OldRevisionImporter' ),
475  $services->getDBLoadBalancer()
476  );
477  },
478 
479  'ShellCommandFactory' => function ( MediaWikiServices $services ) {
480  $config = $services->getMainConfig();
481 
482  $limits = [
483  'time' => $config->get( 'MaxShellTime' ),
484  'walltime' => $config->get( 'MaxShellWallClockTime' ),
485  'memory' => $config->get( 'MaxShellMemory' ),
486  'filesize' => $config->get( 'MaxShellFileSize' ),
487  ];
488  $cgroup = $config->get( 'ShellCgroup' );
489  $restrictionMethod = $config->get( 'ShellRestrictionMethod' );
490 
491  $factory = new CommandFactory( $limits, $cgroup, $restrictionMethod );
492  $factory->setLogger( LoggerFactory::getInstance( 'exec' ) );
493  $factory->logStderr();
494 
495  return $factory;
496  },
497 
498  'ExternalStoreFactory' => function ( MediaWikiServices $services ) {
499  $config = $services->getMainConfig();
500 
501  return new ExternalStoreFactory(
502  $config->get( 'ExternalStores' )
503  );
504  },
505 
506  'RevisionStore' => function ( MediaWikiServices $services ) {
508  $blobStore = $services->getService( '_SqlBlobStore' );
509 
510  $store = new RevisionStore(
511  $services->getDBLoadBalancer(),
512  $blobStore,
513  $services->getMainWANObjectCache(),
514  $services->getCommentStore(),
515  $services->getActorMigration()
516  );
517 
518  $store->setLogger( LoggerFactory::getInstance( 'RevisionStore' ) );
519 
520  $config = $services->getMainConfig();
521  $store->setContentHandlerUseDB( $config->get( 'ContentHandlerUseDB' ) );
522 
523  return $store;
524  },
525 
526  'RevisionLookup' => function ( MediaWikiServices $services ) {
527  return $services->getRevisionStore();
528  },
529 
530  'RevisionFactory' => function ( MediaWikiServices $services ) {
531  return $services->getRevisionStore();
532  },
533 
534  'BlobStoreFactory' => function ( MediaWikiServices $services ) {
536  return new BlobStoreFactory(
537  $services->getDBLoadBalancer(),
538  $services->getMainWANObjectCache(),
539  $services->getMainConfig(),
541  );
542  },
543 
544  'BlobStore' => function ( MediaWikiServices $services ) {
545  return $services->getService( '_SqlBlobStore' );
546  },
547 
548  '_SqlBlobStore' => function ( MediaWikiServices $services ) {
549  return $services->getBlobStoreFactory()->newSqlBlobStore();
550  },
551 
552  'ContentModelStore' => function ( MediaWikiServices $services ) {
553  return new NameTableStore(
554  $services->getDBLoadBalancer(),
555  $services->getMainWANObjectCache(),
556  LoggerFactory::getInstance( 'NameTableSqlStore' ),
557  'content_models',
558  'model_id',
559  'model_name'
566  );
567  },
568 
569  'SlotRoleStore' => function ( MediaWikiServices $services ) {
570  return new NameTableStore(
571  $services->getDBLoadBalancer(),
572  $services->getMainWANObjectCache(),
573  LoggerFactory::getInstance( 'NameTableSqlStore' ),
574  'slot_roles',
575  'role_id',
576  'role_name',
577  'strtolower'
578  );
579  },
580 
581  'PreferencesFactory' => function ( MediaWikiServices $services ) {
583  $authManager = AuthManager::singleton();
584  $linkRenderer = $services->getLinkRendererFactory()->create();
585  $config = $services->getMainConfig();
586  $factory = new DefaultPreferencesFactory( $config, $wgContLang, $authManager, $linkRenderer );
587  $factory->setLogger( LoggerFactory::getInstance( 'preferences' ) );
588 
589  return $factory;
590  },
591 
592  'HttpRequestFactory' => function ( MediaWikiServices $services ) {
593  return new \MediaWiki\Http\HttpRequestFactory();
594  },
595 
596  'CommentStore' => function ( MediaWikiServices $services ) {
598  return new CommentStore(
599  $wgContLang,
600  $services->getMainConfig()->get( 'CommentTableSchemaMigrationStage' )
601  );
602  },
603 
604  'ActorMigration' => function ( MediaWikiServices $services ) {
605  return new ActorMigration(
606  $services->getMainConfig()->get( 'ActorTableSchemaMigrationStage' )
607  );
608  },
609 
611  // NOTE: When adding a service here, don't forget to add a getter function
612  // in the MediaWikiServices class. The convenience getter should just call
613  // $this->getService( 'FooBarService' ).
615 
616 ];
EventRelayerGroup
Factory class for spawning EventRelayer objects using configuration.
Definition: EventRelayerGroup.php:28
LinkCache
Cache for article titles (prefixed DB keys) and ids linked from one source.
Definition: LinkCache.php:34
$wgUser
$wgUser
Definition: Setup.php:902
MediaWiki\Storage\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:69
MultiHttpClient
Class to handle concurrent HTTP requests.
Definition: MultiHttpClient.php:48
MediaWikiTitleCodec
A codec for MediaWiki page titles.
Definition: MediaWikiTitleCodec.php:38
FileBasedSiteLookup
Provides a file-based cache of a SiteStore.
Definition: FileBasedSiteLookup.php:33
ObjectCache\getLocalClusterInstance
static getLocalClusterInstance()
Get the main cluster-local cache object.
Definition: ObjectCache.php:367
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
SkinApi
SkinTemplate class for API output.
Definition: SkinApi.php:31
HashBagOStuff
Simple store for keeping values in an associative array for the current process.
Definition: HashBagOStuff.php:31
ImportableOldRevisionImporter
Definition: ImportableOldRevisionImporter.php:9
MediaWiki\Interwiki\ClassicInterwikiLookup
InterwikiLookup implementing the "classic" interwiki storage (hardcoded up to MW 1....
Definition: ClassicInterwikiLookup.php:46
EmptyBagOStuff
A BagOStuff object with no objects in it.
Definition: EmptyBagOStuff.php:29
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:88
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:50
CACHE_NONE
const CACHE_NONE
Definition: Defines.php:112
ReadOnlyMode
A service class for fetching the wiki's current read-only mode.
Definition: ReadOnlyMode.php:11
CachingSiteStore
Definition: CachingSiteStore.php:31
CACHE_ACCEL
const CACHE_ACCEL
Definition: Defines.php:115
GenderCache
Caches user genders when needed to use correct namespace aliases.
Definition: GenderCache.php:31
DjVuImage
Support for detecting/validating DjVu image files and getting some basic file metadata (resolution et...
Definition: DjVuImage.php:36
ConfiguredReadOnlyMode
A read-only mode service which does not depend on LoadBalancer.
Definition: ConfiguredReadOnlyMode.php:9
CommentStore
CommentStore handles storage of comments (edit summaries, log reasons, etc) in the database.
Definition: CommentStore.php:31
$params
$params
Definition: styleTest.css.php:40
MediaWiki\Linker\LinkRendererFactory
Factory to create LinkRender objects.
Definition: LinkRendererFactory.php:31
SearchEngineFactory
Factory class for SearchEngine.
Definition: SearchEngineFactory.php:9
ActorMigration
This class handles the logic for the actor table migration.
Definition: ActorMigration.php:35
$linkRenderer
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition: hooks.txt:2056
$result
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. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. '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 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name '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:Array with elements of the form "language:title" in the order that they will be output. & $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
Definition: hooks.txt:1993
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1087
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:37
MediaHandlerFactory
Class to construct MediaHandler objects.
Definition: MediaHandlerFactory.php:29
CryptHKDF
Definition: CryptHKDF.php:33
WatchedItemQueryService
Definition: WatchedItemQueryService.php:18
ProxyLookup
Definition: ProxyLookup.php:27
VirtualRESTServiceClient
Virtual HTTP service client loosely styled after a Virtual File System.
Definition: VirtualRESTServiceClient.php:45
SkinFallback
SkinTemplate class for the fallback skin.
Definition: SkinFallback.php:14
ObjectCache\getInstance
static getInstance( $id)
Get a cached instance of the specified type of cache object.
Definition: ObjectCache.php:92
BufferingStatsdDataFactory
A factory for application metric data.
Definition: BufferingStatsdDataFactory.php:35
MWLBFactory\getLBFactoryClass
static getLBFactoryClass(array $config)
Returns the LBFactory class to use and the load balancer configuration.
Definition: MWLBFactory.php:178
MWLBFactory\applyDefaultConfig
static applyDefaultConfig(array $lbConf, Config $mainConfig, ConfiguredReadOnlyMode $readOnlyMode)
Definition: MWLBFactory.php:44
DBSiteStore
Definition: DBSiteStore.php:33
MimeMagic
Definition: MimeMagic.php:27
MediaWiki\Storage\BlobStoreFactory
Service for instantiating BlobStores.
Definition: BlobStoreFactory.php:35
wfGetCache
wfGetCache( $cacheType)
Get a specific cache object.
Definition: GlobalFunctions.php:3138
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
$services
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition: hooks.txt:2273
$mime
if( $ext=='php'|| $ext=='php5') $mime
Definition: router.php:59
ExternalStoreFactory
Definition: ExternalStoreFactory.php:9
MWLBFactory\setSchemaAliases
static setSchemaAliases(LBFactory $lbFactory, Config $config)
Definition: MWLBFactory.php:211
SkinFactory
Factory class to create Skin objects.
Definition: SkinFactory.php:31
MediaWiki\Shell\CommandFactory
Factory facilitating dependency injection for Command.
Definition: CommandFactory.php:32
CACHE_ANYTHING
const CACHE_ANYTHING
Definition: Defines.php:111
MediaWiki\Storage\NameTableStore
Definition: NameTableStore.php:35
MediaWiki\Auth\AuthManager
This serves as the entry point to the authentication system.
Definition: AuthManager.php:83
WatchedItemStore
Storage layer class for WatchedItems.
Definition: WatchedItemStore.php:19
$skin
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
Definition: hooks.txt:2011
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
ImportableUploadRevisionImporter
Definition: ImportableUploadRevisionImporter.php:8
$cache
$cache
Definition: mcc.php:33
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:22
ParserCache
Definition: ParserCache.php:30
ConfigFactory
Factory class to create Config objects.
Definition: ConfigFactory.php:31
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
MediaWiki\Preferences\DefaultPreferencesFactory
This is the default implementation of PreferencesFactory.
Definition: DefaultPreferencesFactory.php:61
SearchEngineConfig
Configuration handling class for SearchEngine.
Definition: SearchEngineConfig.php:9
MediaWikiServices
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 MediaWikiServices
Definition: injection.txt:25
wfIsHHVM
wfIsHHVM()
Check if we are running under HHVM.
Definition: GlobalFunctions.php:2032
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
$ext
$ext
Definition: router.php:55
CryptRand
Definition: CryptRand.php:28
$context
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2811
NoWriteWatchedItemStore
Definition: NoWriteWatchedItemStore.php:28
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:57