MediaWiki REL1_37
|
ResourceLoader is a loading system for JavaScript and CSS resources. More...
Public Member Functions | |
__construct (Config $config, LoggerInterface $logger=null, DependencyStore $tracker=null) | |
Register core modules and runs registration hooks. | |
addSource ( $sources, $loadUrl=null) | |
Add a foreign source of modules. | |
createLoaderURL ( $source, ResourceLoaderContext $context, array $extraQuery=[]) | |
Build a load.php URL. | |
getCombinedVersion (ResourceLoaderContext $context, array $moduleNames) | |
Helper method to get and combine versions of multiple modules. | |
getConfig () | |
getLessCompiler (array $vars=[], array $importDirs=[]) | |
Return a LESS compiler that is set up for use with MediaWiki. | |
getLoadScript ( $source) | |
Get the URL to the load.php endpoint for the given ResourceLoader source. | |
getLogger () | |
getMessageBlobStore () | |
getModule ( $name) | |
Get the ResourceLoaderModule object for a given module name. | |
getModuleNames () | |
getModulesByMessage ( $messageKey) | |
Get names of modules that use a certain message. | |
getSources () | |
Get the list of sources. | |
getTestSuiteModuleNames () | |
Get a list of module names with QUnit test suites. | |
isModuleRegistered ( $name) | |
Check whether a ResourceLoader module is registered. | |
loadModuleDependenciesInternal ( $moduleName, $variant) | |
makeModuleResponse (ResourceLoaderContext $context, array $modules, array $missing=[]) | |
Generate code for a response. | |
makeVersionQuery (ResourceLoaderContext $context, array $modules) | |
Get the expected value of the 'version' query parameter. | |
outputErrorAndLog (Exception $e, $msg, array $context=[]) | |
Add an error to the 'errors' array and log it. | |
preloadModuleInfo (array $moduleNames, ResourceLoaderContext $context) | |
Load information stored in the database and dependency tracking store about modules. | |
register ( $name, array $info=null) | |
Register a module with the ResourceLoader system. | |
registerTestModules () | |
respond (ResourceLoaderContext $context) | |
Output a response to a load request, including the content-type header. | |
saveModuleDependenciesInternal ( $moduleName, $variant, $paths, $priorPaths) | |
setDependencyStore (DependencyStore $tracker) | |
setLogger (LoggerInterface $logger) | |
setMessageBlobStore (MessageBlobStore $blobStore) | |
setModuleSkinStyles (array $moduleSkinStyles) | |
Static Public Member Functions | |
static | clearCache () |
Reset static members used for caching. | |
static | encodeJsonForScript ( $data) |
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode. | |
static | ensureNewline ( $str) |
Ensure the string is either empty or ends in a line break. | |
static | expandModuleNames ( $modules) |
Expand a string of the form jquery.foo,bar|jquery.ui.baz,quux to an array of module names like ‘[ 'jquery.foo’, 'jquery.bar', 'jquery.ui.baz', 'jquery.ui.quux' ]`. | |
static | filter ( $filter, $data, array $options=[]) |
Run JavaScript or CSS data through a filter, caching the filtered result for future calls. | |
static | formatException (Throwable $e) |
Handle exception display. | |
static | getSiteConfigSettings (ResourceLoaderContext $context, Config $conf) |
Get site configuration settings to expose to JavaScript on all pages via mw.config . | |
static | inDebugMode () |
Determine whether debug mode is on. | |
static | isValidModuleName ( $moduleName) |
Check a module name for validity. | |
static | makeCombinedStyles (array $stylePairs) |
Combines an associative array mapping media type to CSS into a single stylesheet with "@media" blocks. | |
static | makeComment ( $text) |
Generate a CSS or JS comment block. | |
static | makeConfigSetScript (array $configuration) |
Return JS code which will set the MediaWiki configuration array to the given value. | |
static | makeHash ( $value) |
Create a hash for module versioning purposes. | |
static | makeInlineCodeWithModule ( $modules, $script) |
Wrap JavaScript code to run after a required module. | |
static | makeInlineScript ( $script, $nonce=null) |
Make an HTML script that runs given JS code after startup and base modules. | |
static | makeLoaderConditionalScript ( $script) |
Wrap JavaScript code to run after the startup module. | |
static | makeLoaderQuery (array $modules, $lang, $skin, $user=null, $version=null, $debug=ResourceLoaderContext::DEBUG_OFF, $only=null, $printable=false, $handheld=false, array $extraQuery=[]) |
Build a query array (array representation of query string) for load.php. | |
static | makeLoaderRegisterScript (ResourceLoaderContext $context, array $modules) |
Format JS code which calls mw.loader.register() with the given parameters. | |
static | makeLoaderSourcesScript (ResourceLoaderContext $context, array $sources) |
Format JS code which calls mw.loader.addSource() with the given parameters. | |
static | makeLoaderStateScript (ResourceLoaderContext $context, array $states) |
Returns a JS call to mw.loader.state, which sets the state of modules to a given value: | |
static | makeMessageSetScript ( $messages) |
Returns JS code which, when called, will register a given list of messages. | |
static | makePackedModulesString (array $modules) |
Convert an array of module names to a packed query string. | |
Public Attributes | |
const | HASH_LENGTH = 5 |
Protected Member Functions | |
measureResponseTime (Timing $timing) | |
sendResponseHeaders (ResourceLoaderContext $context, $etag, $errors, array $extra=[]) | |
Send main response headers to the client. | |
tryRespondFromFileCache (ResourceFileCache $fileCache, ResourceLoaderContext $context, $etag) | |
Send out code for a response from file cache if possible. | |
tryRespondNotModified (ResourceLoaderContext $context, $etag) | |
Respond with HTTP 304 Not Modified if appropiate. | |
Static Protected Member Functions | |
static | createLoaderQuery (ResourceLoaderContext $context, array $extraQuery=[]) |
Helper for createLoaderURL() | |
static | formatExceptionNoComment (Throwable $e) |
Handle exception display. | |
Protected Attributes | |
MessageBlobStore | $blobStore |
Config | $config |
DependencyStore | $depStore |
array | $errors = [] |
Errors accumulated during current respond() call. | |
string[] | $extraHeaders = [] |
Extra HTTP response headers from modules loaded in makeModuleResponse() | |
array[] | $moduleInfos = [] |
Map of (module name => associative info array) | |
ResourceLoaderModule[] | $modules = [] |
Map of (module name => ResourceLoaderModule) | |
array | $sources = [] |
Map of (source => path); E.g. | |
array | $testModuleNames = [] |
Associative array mapping framework ids to a list of names of test suite modules like [ 'qunit' => [ 'mediawiki.tests.qunit.suites', 'ext.foo.tests', ... ], ... ]. | |
string[] | $testSuiteModuleNames = [] |
List of module names that contain QUnit test suites. | |
Static Protected Attributes | |
static int null | $debugMode = null |
Static Private Member Functions | |
static | applyFilter ( $filter, $data) |
static | isEmptyObject (stdClass $obj) |
static | makeLoaderImplementScript (ResourceLoaderContext $context, $name, $scripts, $styles, $messages, $templates) |
Return JS code that calls mw.loader.implement with given module properties. | |
static | trimArray (array &$array) |
Remove empty values from the end of an array. | |
Private Attributes | |
array | $depStoreUpdateBuffer = [] |
Map of (module-variant => buffered DependencyStore updates) | |
HookContainer | $hookContainer |
HookRunner | $hookRunner |
LoggerInterface | $logger |
array | $moduleSkinStyles = [] |
Styles that are skin-specific and supplement or replace the default skinStyles of a FileModule. | |
ResourceLoader is a loading system for JavaScript and CSS resources.
For higher level documentation, see https://www.mediawiki.org/wiki/ResourceLoader/Architecture.
Definition at line 58 of file ResourceLoader.php.
ResourceLoader::__construct | ( | Config | $config, |
LoggerInterface | $logger = null , |
||
DependencyStore | $tracker = null |
||
) |
Register core modules and runs registration hooks.
Config | $config | |
LoggerInterface | null | $logger | [optional] |
DependencyStore | null | $tracker | [optional] |
Definition at line 243 of file ResourceLoader.php.
References $config, $logger, $tracker, addSource(), Config\get(), setDependencyStore(), and setMessageBlobStore().
ResourceLoader::addSource | ( | $sources, | |
$loadUrl = null |
|||
) |
Add a foreign source of modules.
Source IDs are typically the same as the Wiki ID or database name (e.g. lowercase a-z).
array | string | $sources | Source ID (string), or [ id1 => loadUrl, id2 => loadUrl, ... ] |
string | array | null | $loadUrl | load.php url (string), or array with loadUrl key for backwards-compatibility. |
InvalidArgumentException | If array-form $loadUrl lacks a 'loadUrl' key. |
Definition at line 419 of file ResourceLoader.php.
References $source.
Referenced by __construct().
|
staticprivate |
string | $filter | |
string | $data |
Definition at line 222 of file ResourceLoader.php.
Referenced by filter().
|
static |
Reset static members used for caching.
Global state and $wgRequest are evil, but we're using it right now and sometimes we need to be able to force ResourceLoader to re-evaluate the context because it has changed (e.g. in the test suite).
Definition at line 1729 of file ResourceLoader.php.
|
staticprotected |
Helper for createLoaderURL()
ResourceLoaderContext | $context | |
array | $extraQuery |
Definition at line 1760 of file ResourceLoader.php.
ResourceLoader::createLoaderURL | ( | $source, | |
ResourceLoaderContext | $context, | ||
array | $extraQuery = [] |
||
) |
Build a load.php URL.
string | $source | Name of the ResourceLoader source |
ResourceLoaderContext | $context | |
array | $extraQuery |
Definition at line 1742 of file ResourceLoader.php.
|
static |
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
mixed | $data |
Definition at line 1401 of file ResourceLoader.php.
|
static |
Ensure the string is either empty or ends in a line break.
string | $str |
Definition at line 1247 of file ResourceLoader.php.
Referenced by ResourceLoaderModule\buildContent(), and ResourceLoaderFileModule\readScriptFiles().
|
static |
Expand a string of the form jquery.foo,bar|jquery.ui.baz,quux
to an array of module names like ‘[ 'jquery.foo’, 'jquery.bar', 'jquery.ui.baz', 'jquery.ui.quux' ]`.
This process is reversed by ResourceLoader::makePackedModulesString().
string | $modules | Packed module name list |
Definition at line 1671 of file ResourceLoader.php.
Referenced by ResourceLoaderContext\__construct().
|
static |
Run JavaScript or CSS data through a filter, caching the filtered result for future calls.
Available filters are:
If $data is empty, only contains whitespace or the filter was unknown, $data is returned unmodified.
string | $filter | Name of filter to run |
string | $data | Text to filter, such as JavaScript or CSS text |
array<string,bool> | $options Keys:
|
Definition at line 182 of file ResourceLoader.php.
References $cache, applyFilter(), and CACHE_ANYTHING.
Referenced by ResourceLoaderModule\buildContent(), and ResourceLoaderClientHtml\getHeadHtml().
|
static |
Handle exception display.
Throwable | $e | Exception to be shown to the user |
Definition at line 1065 of file ResourceLoader.php.
|
staticprotected |
Handle exception display.
Throwable | $e | Exception to be shown to the user |
Definition at line 1076 of file ResourceLoader.php.
References $wgShowExceptionDetails.
ResourceLoader::getCombinedVersion | ( | ResourceLoaderContext | $context, |
array | $moduleNames | ||
) |
Helper method to get and combine versions of multiple modules.
ResourceLoaderContext | $context | |
string[] | $moduleNames | List of known module names |
Definition at line 712 of file ResourceLoader.php.
References $hashes.
ResourceLoader::getConfig | ( | ) |
ResourceLoader::getLessCompiler | ( | array | $vars = [] , |
array | $importDirs = [] |
||
) |
Return a LESS compiler that is set up for use with MediaWiki.
array | $vars | Associative array of variables that should be used for compilation. Since 1.32, this method no longer automatically includes global LESS vars from ResourceLoader::getLessVars (T191937). |
array | $importDirs | Additional directories to look in for @import (since 1.36) |
MWException |
Definition at line 1860 of file ResourceLoader.php.
ResourceLoader::getLoadScript | ( | $source | ) |
Get the URL to the load.php endpoint for the given ResourceLoader source.
string | $source | Source ID |
UnexpectedValueException | If the source ID was not registered |
Definition at line 601 of file ResourceLoader.php.
References $source.
ResourceLoader::getLogger | ( | ) |
Definition at line 289 of file ResourceLoader.php.
References $logger.
Referenced by ResourceLoaderContext\__construct().
ResourceLoader::getMessageBlobStore | ( | ) |
Definition at line 297 of file ResourceLoader.php.
References $blobStore.
Referenced by preloadModuleInfo().
ResourceLoader::getModule | ( | $name | ) |
Get the ResourceLoaderModule object for a given module name.
If an array of module parameters exists but a ResourceLoaderModule object has not yet been instantiated, this method will instantiate and cache that object such that subsequent calls simply return the same object.
string | $name | Module name |
Definition at line 481 of file ResourceLoader.php.
Referenced by preloadModuleInfo().
ResourceLoader::getModuleNames | ( | ) |
Definition at line 444 of file ResourceLoader.php.
ResourceLoader::getModulesByMessage | ( | $messageKey | ) |
Get names of modules that use a certain message.
string | $messageKey |
Definition at line 1261 of file ResourceLoader.php.
|
static |
Get site configuration settings to expose to JavaScript on all pages via mw.config
.
ResourceLoaderContext | $context | |
Config | $conf |
Definition at line 1888 of file ResourceLoader.php.
ResourceLoader::getSources | ( | ) |
Get the list of sources.
Definition at line 589 of file ResourceLoader.php.
ResourceLoader::getTestSuiteModuleNames | ( | ) |
Get a list of module names with QUnit test suites.
Definition at line 455 of file ResourceLoader.php.
|
static |
Determine whether debug mode is on.
Order of priority is:
Definition at line 1708 of file ResourceLoader.php.
Referenced by SpecialJavaScriptTest\exportJS(), OutputPage\getRlClientContext(), and SpecialJavaScriptTest\renderPage().
|
staticprivate |
Definition at line 1441 of file ResourceLoader.php.
ResourceLoader::isModuleRegistered | ( | $name | ) |
Check whether a ResourceLoader module is registered.
string | $name |
Definition at line 466 of file ResourceLoader.php.
|
static |
Check a module name for validity.
Module names may not contain pipes (|), commas (,) or exclamation marks (!) and can be at most 255 bytes.
string | $moduleName | Module name to check |
Definition at line 1844 of file ResourceLoader.php.
ResourceLoader::loadModuleDependenciesInternal | ( | $moduleName, | |
$variant | |||
) |
string | $moduleName | Module name |
string | $variant | Language/skin variant |
Definition at line 518 of file ResourceLoader.php.
References ResourceLoaderModule\expandRelativePaths().
|
static |
Combines an associative array mapping media type to CSS into a single stylesheet with "@media" blocks.
array<string,string|string[]> | $stylePairs Map from media type to CSS string(s) |
Definition at line 1365 of file ResourceLoader.php.
Referenced by ResourceLoaderModule\buildContent(), and WebInstallerOutput\getCSS().
|
static |
Generate a CSS or JS comment block.
Only use this for public data, not error message details.
string | $text |
Definition at line 1054 of file ResourceLoader.php.
Referenced by ResourceLoaderWikiModule\getScript(), and ResourceLoaderWikiModule\getStyles().
|
static |
Return JS code which will set the MediaWiki configuration array to the given value.
array | $configuration | List of configuration values keyed by variable name |
Exception |
Definition at line 1617 of file ResourceLoader.php.
Referenced by SpecialJavaScriptTest\exportJS(), OutputPage\getBottomScripts(), MWDebug\getDebugHTML(), Skin\makeVariablesScript(), and wfReportTime().
|
static |
Create a hash for module versioning purposes.
This hash is used in three ways:
To differentiate between the current version and a past version of a module by the same name.
In the cache key of localStorage in the browser (mw.loader.store). This store keeps only one version of any given module. As long as the next version the client encounters has a different hash from the last version it saw, it will correctly discard it in favour of a network fetch.
A browser may evict a site's storage container for any reason (e.g. when the user hasn't visited a site for some time, and/or when the device is low on storage space). Anecdotally it seems devices rarely keep unused storage beyond 2 weeks on mobile devices and 4 weeks on desktop. But, there is no hard limit or expiration on localStorage. ResourceLoader's Client also clears localStorage when the user changes their language preference or when they (temporarily) use Debug Mode.
The only hard factors that reduce the range of possible versions are 1) the name and existence of a given module, and 2) the TTL for mw.loader.store, and 3) the $wgResourceLoaderStorageVersion
configuration variable.
To identify a batch response of modules from load.php in an HTTP cache.
When fetching modules in a batch from load.php, a combined hash is created by the JS code, and appended as query parameter.
In cache proxies (e.g. Varnish, Nginx) and in the browser's HTTP cache, these urls are used to identify other previously cached responses. The range of possible versions a given version has to be unique amongst is determined by the maximum duration each response is stored for, which is controlled by ‘$wgResourceLoaderMaxage['versioned’]`.
To detect race conditions between multiple web servers in a MediaWiki deployment of which some have the newer version and some still the older version.
An HTTP request from a browser for the Startup manifest may be responded to by a server with the newer version. The browser may then use that to request a given module, which may then be responded to by a server with the older version. To avoid caching this for too long (which would pollute all other users without repairing itself), the combined hash that the JS client adds to the url is verified by the server (in sendResponseHeaders). If they don't match, we instruct cache proxies and clients to not cache this response as long as they normally would. This is also the reason that the algorithm used here in PHP must match the one used in JS.
The fnv132 digest creates a 32-bit integer, which goes upto 4 Giga and needs up to 7 chars in base 36. Within 7 characters, base 36 can count up to 78,364,164,096 (78 Giga), (but with fnv132 we'd use very little of this range, mostly padding). Within 6 characters, base 36 can count up to 2,176,782,336 (2 Giga). Within 5 characters, base 36 can count up to 60,466,176 (60 Mega).
string | $value |
Definition at line 675 of file ResourceLoader.php.
Referenced by ResourceLoaderModule\getVersionHash().
|
static |
Wrap JavaScript code to run after a required module.
string | string[] | $modules | Module name(s) |
string | $script | JavaScript code |
Definition at line 1571 of file ResourceLoader.php.
Referenced by SpecialJavaScriptTest\exportJS().
|
static |
Make an HTML script that runs given JS code after startup and base modules.
The code will be wrapped in a closure, and it will be executed by ResourceLoader's startup module if the client has adequate support for MediaWiki JavaScript code.
string | $script | JavaScript code |
string | null | $nonce | Content-Security-Policy nonce (from OutputPage->getCSP()->getNonce() ) |
Definition at line 1590 of file ResourceLoader.php.
Referenced by ResourceLoaderClientHtml\getBodyHtml(), OutputPage\getBottomScripts(), MWDebug\getDebugHTML(), ResourceLoaderClientHtml\makeLoad(), Skin\makeVariablesScript(), and wfReportTime().
|
static |
Wrap JavaScript code to run after the startup module.
string | $script | JavaScript code |
Definition at line 1557 of file ResourceLoader.php.
Referenced by SpecialJavaScriptTest\exportJS().
|
staticprivate |
Return JS code that calls mw.loader.implement with given module properties.
ResourceLoaderContext | $context | |
string | $name | Module name or implement key (format "`[name]@[version]`") |
XmlJsCode | array | string | $scripts | Code as XmlJsCode (to be wrapped in a closure), list of URLs to JavaScript files, string of JavaScript for $.globalEval , or array with 'files' and 'main' properties (see ResourceLoaderModule::getScript()) |
mixed | $styles | Array of CSS strings keyed by media type, or an array of lists of URLs to CSS files keyed by media type |
mixed | $messages | List of messages associated with this module. May either be an associative array mapping message key to value, or a JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object. |
array | $templates | Keys are name of templates and values are the source of the template. |
Definition at line 1289 of file ResourceLoader.php.
|
static |
Build a query array (array representation of query string) for load.php.
Helper function for createLoaderURL().
string[] | $modules | |
string | $lang | |
string | $skin | |
string | null | $user | |
string | null | $version | |
int | $debug | |
string | null | $only | |
bool | $printable | |
bool | $handheld | |
array | $extraQuery |
Definition at line 1793 of file ResourceLoader.php.
Referenced by OutputPage\getRlClientContext().
|
static |
Format JS code which calls mw.loader.register()
with the given parameters.
ResourceLoaderContext | $context | |
array[] | $modules | Array of module registration arrays, each containing
|
Definition at line 1501 of file ResourceLoader.php.
|
static |
Format JS code which calls mw.loader.addSource()
with the given parameters.
ResourceLoaderContext | $context | |
array<string,string> | $sources |
Definition at line 1543 of file ResourceLoader.php.
|
static |
Returns a JS call to mw.loader.state, which sets the state of modules to a given value:
ResourceLoaderContext | $context | |
array<string,string> | $states |
Definition at line 1433 of file ResourceLoader.php.
|
static |
Returns JS code which, when called, will register a given list of messages.
mixed | $messages | Associative array mapping message key to value. |
Definition at line 1352 of file ResourceLoader.php.
ResourceLoader::makeModuleResponse | ( | ResourceLoaderContext | $context, |
array | $modules, | ||
array | $missing = [] |
||
) |
Generate code for a response.
Calling this method also populates the errors
and headers
members, later used by respond().
ResourceLoaderContext | $context | Context in which to generate a response |
ResourceLoaderModule[] | $modules | List of module objects keyed by module name |
string[] | $missing | List of requested module names that are unregistered (optional) |
Definition at line 1099 of file ResourceLoader.php.
References $content, $modules, ResourceLoaderContext\encodeJson(), ResourceLoaderContext\getDebug(), ResourceLoaderContext\getImageObj(), ResourceLoaderContext\getOnly(), ResourceLoaderContext\getRaw(), and ResourceLoaderContext\shouldIncludeScripts().
|
static |
Convert an array of module names to a packed query string.
For example, ‘[ 'foo.bar’, 'foo.baz', 'bar.baz', 'bar.quux' ] becomes
'foo.bar,baz|bar.baz,quux'`.
This process is reversed by ResourceLoader::expandModuleNames(). See also mw.loader::buildModulesString() which is a port of this, used on the client-side.
string[] | $modules | List of module names (strings) |
Definition at line 1643 of file ResourceLoader.php.
ResourceLoader::makeVersionQuery | ( | ResourceLoaderContext | $context, |
array | $modules | ||
) |
Get the expected value of the 'version' query parameter.
This is used by respond() to set a short Cache-Control header for requests with information newer than the current server has. This avoids pollution of edge caches. Typically during deployment. (T117587)
This MUST match return value of mw.loader#getCombinedVersion()
client-side.
ResourceLoaderContext | $context | |
string[] | $modules |
Definition at line 748 of file ResourceLoader.php.
References $modules.
|
protected |
Definition at line 889 of file ResourceLoader.php.
References Timing\measure().
ResourceLoader::outputErrorAndLog | ( | Exception | $e, |
$msg, | |||
array | $context = [] |
||
) |
Add an error to the 'errors' array and log it.
Exception | $e | |
string | $msg | |
array | $context |
Definition at line 695 of file ResourceLoader.php.
ResourceLoader::preloadModuleInfo | ( | array | $moduleNames, |
ResourceLoaderContext | $context | ||
) |
Load information stored in the database and dependency tracking store about modules.
string[] | $moduleNames | Module names |
ResourceLoaderContext | $context | ResourceLoader-specific context of the request |
Definition at line 122 of file ResourceLoader.php.
References $blob, $dbr, $lang, DB_REPLICA, ResourceLoaderModule\expandRelativePaths(), ResourceLoaderContext\getLanguage(), getMessageBlobStore(), getModule(), ResourceLoaderModule\getVary(), and wfGetDB().
ResourceLoader::register | ( | $name, | |
array | $info = null |
||
) |
Register a module with the ResourceLoader system.
string | array[] | $name | Module name as a string or, array of module info arrays keyed by name. |
array | null | $info | Module info array. When using the first parameter to register multiple modules at once, this parameter is optional. |
InvalidArgumentException | If a module name contains illegal characters (pipes or commas) |
InvalidArgumentException | If the module info is not an array |
Definition at line 336 of file ResourceLoader.php.
ResourceLoader::registerTestModules | ( | ) |
Definition at line 369 of file ResourceLoader.php.
ResourceLoader::respond | ( | ResourceLoaderContext | $context | ) |
Output a response to a load request, including the content-type header.
ResourceLoaderContext | $context | Context in which a response should be formed |
Definition at line 771 of file ResourceLoader.php.
References $modules, ResourceLoaderContext\encodeJson(), ResourceLoaderContext\getDebug(), ResourceLoaderContext\getImageObj(), ResourceLoaderContext\getModules(), ResourceLoaderContext\getRequest(), ResourceFileCache\newFromContext(), ResourceLoaderContext\shouldIncludeScripts(), and ResourceFileCache\useFileCache().
ResourceLoader::saveModuleDependenciesInternal | ( | $moduleName, | |
$variant, | |||
$paths, | |||
$priorPaths | |||
) |
string | $moduleName | Module name |
string | $variant | Language/skin variant |
string[] | $paths | List of relative paths referenced during computation |
string[] | $priorPaths | List of relative paths tracked in the dependency store |
Definition at line 531 of file ResourceLoader.php.
References $cache.
|
protected |
Send main response headers to the client.
Deals with Content-Type, CORS (for stylesheets), and caching.
ResourceLoaderContext | $context | |
string | $etag | ETag header value |
bool | $errors | Whether there are errors in the response |
string[] | $extra | Array of extra HTTP response headers |
Definition at line 909 of file ResourceLoader.php.
ResourceLoader::setDependencyStore | ( | DependencyStore | $tracker | ) |
DependencyStore | $tracker |
Definition at line 313 of file ResourceLoader.php.
References $tracker.
Referenced by __construct().
ResourceLoader::setLogger | ( | LoggerInterface | $logger | ) |
LoggerInterface | $logger |
Definition at line 281 of file ResourceLoader.php.
References $logger.
ResourceLoader::setMessageBlobStore | ( | MessageBlobStore | $blobStore | ) |
MessageBlobStore | $blobStore |
Definition at line 305 of file ResourceLoader.php.
References $blobStore.
Referenced by __construct().
ResourceLoader::setModuleSkinStyles | ( | array | $moduleSkinStyles | ) |
array | $moduleSkinStyles |
Definition at line 321 of file ResourceLoader.php.
References $moduleSkinStyles.
|
staticprivate |
Remove empty values from the end of an array.
Values considered empty:
array | &$array |
Definition at line 1461 of file ResourceLoader.php.
|
protected |
Send out code for a response from file cache if possible.
ResourceFileCache | $fileCache | Cache object for this request URL |
ResourceLoaderContext | $context | Context in which to generate a response |
string | $etag | ETag header value |
Definition at line 1000 of file ResourceLoader.php.
References FileCacheBase\cacheTimestamp(), DB_REPLICA, FileCacheBase\fetchText(), ResourceLoaderContext\getDebug(), ResourceLoaderContext\getVersion(), FileCacheBase\isCacheGood(), and wfGetDB().
|
protected |
Respond with HTTP 304 Not Modified if appropiate.
If there's an If-None-Match header, respond with a 304 appropriately and clear out the output buffer. If the client cache is too old then do nothing.
ResourceLoaderContext | $context | |
string | $etag | ETag header value |
Definition at line 967 of file ResourceLoader.php.
References ResourceLoaderContext\getDebug(), ResourceLoaderContext\getRequest(), and wfResetOutputBuffers().
|
protected |
Definition at line 62 of file ResourceLoader.php.
Referenced by getMessageBlobStore(), and setMessageBlobStore().
|
protected |
Definition at line 60 of file ResourceLoader.php.
Referenced by __construct(), and getConfig().
|
staticprotected |
Definition at line 103 of file ResourceLoader.php.
|
protected |
Definition at line 64 of file ResourceLoader.php.
|
private |
Map of (module-variant => buffered DependencyStore updates)
Definition at line 95 of file ResourceLoader.php.
|
protected |
Errors accumulated during current respond() call.
Definition at line 90 of file ResourceLoader.php.
|
protected |
Extra HTTP response headers from modules loaded in makeModuleResponse()
Definition at line 92 of file ResourceLoader.php.
|
private |
Definition at line 70 of file ResourceLoader.php.
|
private |
Definition at line 73 of file ResourceLoader.php.
|
private |
Definition at line 67 of file ResourceLoader.php.
Referenced by __construct(), getLogger(), and setLogger().
|
protected |
Map of (module name => associative info array)
Definition at line 78 of file ResourceLoader.php.
|
protected |
Map of (module name => ResourceLoaderModule)
Definition at line 76 of file ResourceLoader.php.
|
private |
Styles that are skin-specific and supplement or replace the default skinStyles of a FileModule.
See $wgResourceModuleSkinStyles.
Definition at line 100 of file ResourceLoader.php.
Referenced by setModuleSkinStyles().
|
protected |
Map of (source => path); E.g.
[ 'source-id' => 'http://.../load.php' ]
Definition at line 88 of file ResourceLoader.php.
|
protected |
Associative array mapping framework ids to a list of names of test suite modules like [ 'qunit' => [ 'mediawiki.tests.qunit.suites', 'ext.foo.tests', ... ], ... ].
Definition at line 84 of file ResourceLoader.php.
|
protected |
List of module names that contain QUnit test suites.
Definition at line 86 of file ResourceLoader.php.
const ResourceLoader::HASH_LENGTH = 5 |
Definition at line 611 of file ResourceLoader.php.