21use Wikimedia\WrappedString;
22use Wikimedia\WrappedStringList;
78 foreach ( $vars
as $key =>
$value ) {
79 $this->config[$key] =
$value;
109 $this->exemptStates = $states;
135 'styleDeprecations' => [],
138 foreach ( $this->modules
as $name ) {
144 $group = $module->getGroup();
146 if ( $module->isKnownEmpty(
$context ) ) {
152 if ( $group ===
'user' || $module->shouldEmbedModule( $this->context ) ) {
169 foreach ( $this->moduleStyles
as $name ) {
170 $module = $rl->getModule(
$name );
176 $logger = $rl->getLogger();
177 $logger->error(
'Unexpected general module "{module}" in styles queue.', [
188 $group = $module->getGroup();
191 if ( !$module->isKnownEmpty(
$context ) ) {
192 if ( $module->shouldEmbedModule( $this->context ) ) {
200 $deprecation = $module->getDeprecationInformation();
201 if ( $deprecation ) {
202 $data[
'styleDeprecations'][] = $deprecation;
213 return [
'class' =>
'client-nojs' ];
231 $nonce = $this->
options[
'nonce'];
238 $chunks[] = Html::inlineScript(
239 'document.documentElement.className = document.documentElement.className'
240 .
'.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );',
245 if ( $this->config ) {
246 $chunks[] = ResourceLoader::makeInlineScript(
247 ResourceLoader::makeConfigSetScript( $this->config ),
253 $states = array_merge( $this->exemptStates,
$data[
'states'] );
255 $chunks[] = ResourceLoader::makeInlineScript(
256 ResourceLoader::makeLoaderStateScript( $states ),
262 if (
$data[
'embed'][
'general'] ) {
264 $data[
'embed'][
'general'],
271 if (
$data[
'general'] ) {
272 $chunks[] = ResourceLoader::makeInlineScript(
274 . ResourceLoader::encodeJsonForScript(
$data[
'general'] )
276 .
'mw.loader.load(RLPAGEMODULES);',
282 if (
$data[
'styles'] ) {
291 if (
$data[
'embed'][
'styles'] ) {
293 $data[
'embed'][
'styles'],
302 foreach ( [
'target',
'safemode' ]
as $param ) {
303 if ( $this->
options[$param] !==
null ) {
314 return WrappedString::join(
"\n", $chunks );
325 if (
$data[
'styleDeprecations'] ) {
326 $chunks[] = ResourceLoader::makeInlineScript(
327 implode(
'',
$data[
'styleDeprecations'] ),
332 return WrappedString::join(
"\n", $chunks );
344 array $extraQuery = []
351 if ( $group !==
'user' && $group !==
'private' ) {
352 $req->setVal(
'user',
null );
373 array $extraQuery = [], $nonce =
null
387 return new WrappedStringList(
"\n", $chunks );
393 $module = $rl->getModule(
$name );
395 $rl->getLogger()->warning(
'Unknown module "{module}"', [
'module' =>
$name ] );
398 $sortedModules[$module->getSource()][$module->getGroup()][
$name] = $module;
401 foreach ( $sortedModules
as $source => $groups ) {
402 foreach ( $groups
as $group => $grpModules ) {
408 foreach ( $grpModules
as $name => $module ) {
409 $shouldEmbed = $module->shouldEmbedModule(
$context );
410 if ( !$moduleSets || $moduleSets[$idx][0] !== $shouldEmbed ) {
411 $moduleSets[++$idx] = [ $shouldEmbed, [] ];
413 $moduleSets[$idx][1][
$name] = $module;
417 foreach ( $moduleSets
as list( $embed, $moduleSet ) ) {
418 $context->setModules( array_keys( $moduleSet ) );
422 $chunks[] = Html::inlineStyle(
423 $rl->makeModuleResponse(
$context, $moduleSet )
426 $chunks[] = ResourceLoader::makeInlineScript(
427 $rl->makeModuleResponse(
$context, $moduleSet ),
434 foreach ( $moduleSet
as $key => $module ) {
435 $isRaw |= $module->isRaw();
443 if ( $group ===
'user' ) {
452 $chunk = Html::linkedStyle( $url );
454 $chunk = Html::element(
'script', [
456 'async' => !isset( $extraQuery[
'sync'] ),
460 $chunk = ResourceLoader::makeInlineScript(
461 Xml::encodeJsCall(
'mw.loader.load', [ $url ] ),
466 if ( $group ==
'noscript' ) {
467 $chunks[] = Html::rawElement(
'noscript', [], $chunk );
476 return new WrappedStringList(
"\n", $chunks );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Allows changing specific properties of a context object, without changing the main one.
WebRequest clone which takes values from a provided array.
Load and configure a ResourceLoader client on an HTML page.
getLoad( $modules, $only, $nonce, array $extraQuery=[])
setModules(array $modules)
Ensure one or more modules are loaded.
ResourceLoader $resourceLoader
static makeLoad(ResourceLoaderContext $mainContext, array $modules, $only, array $extraQuery=[], $nonce=null)
Explicily load or embed modules on a page.
__construct(ResourceLoaderContext $context, array $options=[])
getHeadHtml()
The order of elements in the head is as follows:
getContext( $group, $type)
setConfig(array $vars)
Set mw.config variables.
ResourceLoaderContext $context
setExemptStates(array $states)
Set state of special modules that are handled by the caller manually.
static makeContext(ResourceLoaderContext $mainContext, $group, $type, array $extraQuery=[])
setModuleStyles(array $modules)
Ensure the styles of one or more modules are loaded.
Object passed around to modules which contains information about the state of a specific loader reque...
getContentOverrideCallback()
Return the replaced-content mapping callback.
Dynamic JavaScript and CSS resource loading system.
getModule( $name)
Get the ResourceLoaderModule object for a given module name.
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
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
this hook is for auditing only $req
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
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 & $ret
Allows to change the fields on the form that will be generated $name
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a and VARBINARY columns should simply be TEXT The only exception is when VARBINARY is used to store true binary data