MediaWiki  1.28.0
ResourceLoader Class Reference

Dynamic JavaScript and CSS resource loading system. More...

Inheritance diagram for ResourceLoader:
Collaboration diagram for ResourceLoader:

Public Member Functions

 __construct (Config $config=null, LoggerInterface $logger=null)
 Register core modules and runs registration hooks. More...
 
 addSource ($id, $loadUrl=null)
 Add a foreign source of modules. More...
 
 createLoaderURL ($source, ResourceLoaderContext $context, $extraQuery=[])
 Build a load.php URL. More...
 
 getCombinedVersion (ResourceLoaderContext $context, array $moduleNames)
 Helper method to get and combine versions of multiple modules. More...
 
 getConfig ()
 
 getLessCompiler ($extraVars=[])
 Returns LESS compiler set up for use with MediaWiki. More...
 
 getLessVars ()
 Get global LESS variables. More...
 
 getLoadScript ($source)
 Get the URL to the load.php endpoint for the given ResourceLoader source. More...
 
 getLogger ()
 
 getMessageBlobStore ()
 
 getModule ($name)
 Get the ResourceLoaderModule object for a given module name. More...
 
 getModuleNames ()
 Get a list of module names. More...
 
 getModulesByMessage ($messageKey)
 Get names of modules that use a certain message. More...
 
 getSources ()
 Get the list of sources. More...
 
 getTestModuleNames ($framework= 'all')
 Get a list of test module names for one (or all) frameworks. More...
 
 isModuleRegistered ($name)
 Check whether a ResourceLoader module is registered. More...
 
 makeModuleResponse (ResourceLoaderContext $context, array $modules, array $missing=[])
 Generate code for a response. More...
 
 makeVersionQuery (ResourceLoaderContext $context)
 Get the expected value of the 'version' query parameter. More...
 
 preloadModuleInfo (array $moduleNames, ResourceLoaderContext $context)
 Load information stored in the database about modules. More...
 
 register ($name, $info=null)
 Register a module with the ResourceLoader system. More...
 
 registerTestModules ()
 
 respond (ResourceLoaderContext $context)
 Output a response to a load request, including the content-type header. More...
 
 setLogger (LoggerInterface $logger)
 
 setMessageBlobStore (MessageBlobStore $blobStore)
 

Static Public Member Functions

static clearCache ()
 Reset static members used for caching. More...
 
static filter ($filter, $data, array $options=[])
 Run JavaScript or CSS data through a filter, caching the filtered result for future calls. More...
 
static formatException ($e)
 Handle exception display. More...
 
static inDebugMode ()
 Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie, 3) $wg setting. More...
 
static isValidModuleName ($moduleName)
 Check a module name for validity. More...
 
static makeCombinedStyles (array $stylePairs)
 Combines an associative array mapping media type to CSS into a single stylesheet with "@media" blocks. More...
 
static makeComment ($text)
 Generate a CSS or JS comment block. More...
 
static makeConfigSetScript (array $configuration)
 Returns JS code which will set the MediaWiki configuration array to the given value. More...
 
static makeCustomLoaderScript ($name, $version, $dependencies, $group, $source, $script)
 Returns JS code which calls the script given by $script. More...
 
static makeHash ($value)
 
static makeInlineScript ($script)
 Construct an inline script tag with given JS code. More...
 
static makeLoaderConditionalScript ($script)
 Returns JS code which runs given JS code if the client-side framework is present. More...
 
static makeLoaderQuery ($modules, $lang, $skin, $user=null, $version=null, $debug=false, $only=null, $printable=false, $handheld=false, $extraQuery=[])
 Build a query array (array representation of query string) for load.php. More...
 
static makeLoaderRegisterScript ($name, $version=null, $dependencies=null, $group=null, $source=null, $skip=null)
 Returns JS code which calls mw.loader.register with the given parameters. More...
 
static makeLoaderSourcesScript ($id, $loadUrl=null)
 Returns JS code which calls mw.loader.addSource() with the given parameters. More...
 
static makeLoaderStateScript ($name, $state=null)
 Returns a JS call to mw.loader.state, which sets the state of a module or modules to a given value. More...
 
static makeMessageSetScript ($messages)
 Returns JS code which, when called, will register a given list of messages. More...
 
static makePackedModulesString ($modules)
 Convert an array of module names to a packed query string. More...
 

Protected Member Functions

 isFileModule ($name)
 Return whether the definition of a module corresponds to a simple ResourceLoaderFileModule. More...
 
 sendResponseHeaders (ResourceLoaderContext $context, $etag, $errors)
 Send main response headers to the client. More...
 
 tryRespondFromFileCache (ResourceFileCache $fileCache, ResourceLoaderContext $context, $etag)
 Send out code for a response from file cache if possible. More...
 
 tryRespondNotModified (ResourceLoaderContext $context, $etag)
 Respond with HTTP 304 Not Modified if appropiate. More...
 

Static Protected Member Functions

static createLoaderQuery (ResourceLoaderContext $context, $extraQuery=[])
 Helper for createLoaderURL() More...
 
static formatExceptionNoComment ($e)
 Handle exception display. More...
 
static makeLoaderImplementScript ($name, $scripts, $styles, $messages, $templates)
 Return JS code that calls mw.loader.implement with given module properties. More...
 

Protected Attributes

MessageBlobStore $blobStore
 
 $config
 
array $errors = []
 Errors accumulated during current respond() call. More...
 
array $moduleInfos = []
 Associative array mapping module name to info associative array. More...
 
array $modules = []
 Module name/ResourceLoaderModule object pairs. More...
 
array $sources = []
 E.g. More...
 
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', ... More...
 

Static Protected Attributes

static bool $debugMode = null
 
static int $filterCacheVersion = 7
 

Static Private Member Functions

static applyFilter ($filter, $data)
 
static isEmptyObject (stdClass $obj)
 
static trimArray (array &$array)
 Remove empty values from the end of an array. More...
 

Private Attributes

array $lessVars = null
 
LoggerInterface $logger
 

Detailed Description

Dynamic JavaScript and CSS resource loading system.

Most of the documentation is on the MediaWiki documentation wiki starting at: https://www.mediawiki.org/wiki/ResourceLoader

Definition at line 36 of file ResourceLoader.php.

Constructor & Destructor Documentation

ResourceLoader::__construct ( Config  $config = null,
LoggerInterface  $logger = null 
)

Register core modules and runs registration hooks.

Parameters
Config$config[optional]
LoggerInterface$logger[optional]

Definition at line 235 of file ResourceLoader.php.

References $config, $IP, addSource(), ConfigFactory\getDefaultInstance(), global, registerTestModules(), Hooks\run(), setMessageBlobStore(), and true.

Member Function Documentation

ResourceLoader::addSource (   $id,
  $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).

Parameters
array | string$idSource ID (string), or [ id1 => loadUrl, id2 => loadUrl, ... ]
string | array$loadUrlload.php url (string), or array with loadUrl key for backwards-compatibility.
Exceptions
MWException

Definition at line 444 of file ResourceLoader.php.

References $value, and as.

Referenced by __construct(), and ResourceLoaderTest\testAddSource().

static ResourceLoader::applyFilter (   $filter,
  $data 
)
staticprivate
static ResourceLoader::clearCache ( )
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 1493 of file ResourceLoader.php.

Referenced by ResourceLoaderTestCase\setUp(), and ResourceLoaderTest\testMakeLoaderImplementScript().

static ResourceLoader::createLoaderQuery ( ResourceLoaderContext  $context,
  $extraQuery = [] 
)
staticprotected

Helper for createLoaderURL()

Since
1.24
See also
makeLoaderQuery
Parameters
ResourceLoaderContext$context
array$extraQuery
Returns
array

Definition at line 1524 of file ResourceLoader.php.

ResourceLoader::createLoaderURL (   $source,
ResourceLoaderContext  $context,
  $extraQuery = [] 
)

Build a load.php URL.

Since
1.24
Parameters
string$sourceName of the ResourceLoader source
ResourceLoaderContext$context
array$extraQuery
Returns
string URL to load.php. May be protocol-relative if $wgLoadScript is, too.

Definition at line 1506 of file ResourceLoader.php.

static ResourceLoader::filter (   $filter,
  $data,
array  $options = [] 
)
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.

Parameters
string$filterName of filter to run
string$dataText to filter, such as JavaScript or CSS text
array$optionsKeys:
  • (bool) cache: Whether to allow caching this data. Default: true.
Returns
string Filtered data, or a comment containing an error message

Definition at line 178 of file ResourceLoader.php.

References $cache, $options, CACHE_ANYTHING, ObjectCache\getLocalServerInstance(), and RequestContext\getMain().

Referenced by ResourceLoaderModule\buildContent(), and ResourceLoaderStartUpModule\getModuleRegistrations().

static ResourceLoader::formatException (   $e)
static

Handle exception display.

Parameters
Exception$eException to be shown to the user
Returns
string Sanitized text in a CSS/JS comment that can be returned to the user

Definition at line 947 of file ResourceLoader.php.

References $e.

static ResourceLoader::formatExceptionNoComment (   $e)
staticprotected

Handle exception display.

Since
1.25
Parameters
Exception$eException to be shown to the user
Returns
string Sanitized text that can be returned to the user

Definition at line 958 of file ResourceLoader.php.

References $e, MWExceptionHandler\getLogMessage(), MWExceptionHandler\getPublicLogMessage(), and global.

ResourceLoader::getCombinedVersion ( ResourceLoaderContext  $context,
array  $moduleNames 
)

Helper method to get and combine versions of multiple modules.

Since
1.26
Parameters
ResourceLoaderContext$context
string[]$modules List of known module names
Returns
string Hash

Definition at line 619 of file ResourceLoader.php.

References $hashes, and use.

ResourceLoader::getConfig ( )
Returns
Config

Definition at line 269 of file ResourceLoader.php.

References $config.

Referenced by ResourceLoaderContext\__construct().

ResourceLoader::getLessCompiler (   $extraVars = [])

Returns LESS compiler set up for use with MediaWiki.

Since
1.27
Parameters
array$extraVarsAssociative array of extra (i.e., other than the globally-configured ones) that should be used for compilation.
Exceptions
MWException
Returns
Less_Parser

Definition at line 1610 of file ResourceLoader.php.

ResourceLoader::getLessVars ( )

Get global LESS variables.

Since
1.27
Returns
array Map of variable names to string CSS values.

Definition at line 1634 of file ResourceLoader.php.

ResourceLoader::getLoadScript (   $source)

Get the URL to the load.php endpoint for the given ResourceLoader source.

Since
1.24
Parameters
string$source
Exceptions
MWExceptionOn an invalid $source name
Returns
string

Definition at line 594 of file ResourceLoader.php.

References $source.

ResourceLoader::getLogger ( )
Since
1.27
Returns
LoggerInterface

Definition at line 285 of file ResourceLoader.php.

References $logger.

Referenced by ResourceLoaderContext\__construct(), and EmptyResourceLoader\__construct().

ResourceLoader::getMessageBlobStore ( )
Since
1.26
Returns
MessageBlobStore

Definition at line 293 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.

Parameters
string$nameModule name
Returns
ResourceLoaderModule|null If module has been registered, return a ResourceLoaderModule instance. Otherwise, return null.

Definition at line 529 of file ResourceLoader.php.

References $name.

Referenced by ResourceLoaderClientHtml\getData(), and preloadModuleInfo().

ResourceLoader::getModuleNames ( )

Get a list of module names.

Returns
array List of module names

Definition at line 480 of file ResourceLoader.php.

ResourceLoader::getModulesByMessage (   $messageKey)

Get names of modules that use a certain message.

Parameters
string$messageKey
Returns
array List of module names

Definition at line 1111 of file ResourceLoader.php.

ResourceLoader::getSources ( )

Get the list of sources.

Returns
array Like [ id => load.php url, ... ]

Definition at line 581 of file ResourceLoader.php.

ResourceLoader::getTestModuleNames (   $framework = 'all')

Get a list of test module names for one (or all) frameworks.

If the given framework id is unknkown, or if the in-object variable is not an array, then it will return an empty array.

Parameters
string$frameworkGet only the test module names for one particular framework (optional)
Returns
array

Definition at line 494 of file ResourceLoader.php.

static ResourceLoader::isEmptyObject ( stdClass  $obj)
staticprivate

Definition at line 1268 of file ResourceLoader.php.

ResourceLoader::isFileModule (   $name)
protected

Return whether the definition of a module corresponds to a simple ResourceLoaderFileModule.

Parameters
string$nameModule name
Returns
bool

Definition at line 565 of file ResourceLoader.php.

References $name.

ResourceLoader::isModuleRegistered (   $name)

Check whether a ResourceLoader module is registered.

Since
1.25
Parameters
string$name
Returns
bool

Definition at line 514 of file ResourceLoader.php.

References $name.

static ResourceLoader::isValidModuleName (   $moduleName)
static

Check a module name for validity.

Module names may not contain pipes (|), commas (,) or exclamation marks (!) and can be at most 255 bytes.

Parameters
string$moduleNameModule name to check
Returns
bool Whether $moduleName is a valid module name

Definition at line 1597 of file ResourceLoader.php.

static ResourceLoader::makeCombinedStyles ( array  $stylePairs)
static

Combines an associative array mapping media type to CSS into a single stylesheet with "@media" blocks.

Parameters
array$stylePairsArray keyed by media type containing (arrays of) CSS strings
Returns
array

Definition at line 1186 of file ResourceLoader.php.

Referenced by WebInstallerOutput\getCSS().

static ResourceLoader::makeComment (   $text)
static

Generate a CSS or JS comment block.

Only use this for public data, not error message details.

Parameters
string$text
Returns
string

Definition at line 936 of file ResourceLoader.php.

Referenced by ResourceLoaderWikiModule\getScript(), and ResourceLoaderWikiModule\getStyles().

static ResourceLoader::makeConfigSetScript ( array  $configuration)
static

Returns JS code which will set the MediaWiki configuration array to the given value.

Parameters
array$configurationList of configuration values keyed by variable name
Returns
string

Definition at line 1437 of file ResourceLoader.php.

Referenced by SpecialJavaScriptTest\exportQUnit(), MWDebug\getDebugHTML(), ResourceLoaderClientHtml\getHeadHtml(), ResourceLoaderUploadDialogModule\getScript(), and Skin\makeVariablesScript().

static ResourceLoader::makeCustomLoaderScript (   $name,
  $version,
  $dependencies,
  $group,
  $source,
  $script 
)
static

Returns JS code which calls the script given by $script.

The script will be called with local variables name, version, dependencies and group, which will have values corresponding to $name, $version, $dependencies and $group as supplied.

Parameters
string$nameModule name
string$versionModule version hash
array$dependenciesList of module names on which this module depends
string$groupGroup which the module is in.
string$sourceSource of the module, or 'local' if not foreign.
string$scriptJavaScript code
Returns
string

Definition at line 1257 of file ResourceLoader.php.

static ResourceLoader::makeHash (   $value)
static
Since
1.26
Parameters
string$value
Returns
string Hash

Definition at line 606 of file ResourceLoader.php.

References $value.

Referenced by ResourceLoaderStartUpModule\getModuleRegistrations(), and ResourceLoaderModule\getVersionHash().

static ResourceLoader::makeInlineScript (   $script)
static

Construct an inline script tag with given JS code.

The code will be wrapped in a closure, and it will be executed by ResourceLoader only if the client has adequate support for MediaWiki JavaScript code.

Parameters
string$scriptJavaScript code
Returns
WrappedString HTML

Definition at line 1421 of file ResourceLoader.php.

Referenced by ResourceLoaderClientHtml\getBodyHtml(), OutputPage\getBottomScripts(), MWDebug\getDebugHTML(), EditPage\getEditToolbar(), ResourceLoaderClientHtml\getHeadHtml(), ResourceLoaderClientHtml\makeLoad(), and Skin\makeVariablesScript().

static ResourceLoader::makeLoaderConditionalScript (   $script)
static

Returns JS code which runs given JS code if the client-side framework is present.

Deprecated:
since 1.25; use makeInlineScript instead
Parameters
string$scriptJavaScript code
Returns
string

Definition at line 1407 of file ResourceLoader.php.

Referenced by SpecialJavaScriptTest\exportQUnit().

static ResourceLoader::makeLoaderImplementScript (   $name,
  $scripts,
  $styles,
  $messages,
  $templates 
)
staticprotected

Return JS code that calls mw.loader.implement with given module properties.

Parameters
string$nameModule name or implement key (format "`[name]@[version]`")
XmlJsCode | array | string$scriptsCode as XmlJsCode (to be wrapped in a closure), list of URLs to JavaScript files, or a string of JavaScript for $.globalEval.
mixed$stylesArray of CSS strings keyed by media type, or an array of lists of URLs to CSS files keyed by media type
mixed$messagesList 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$templatesKeys are name of templates and values are the source of the template.
Exceptions
MWException
Returns
string

Definition at line 1140 of file ResourceLoader.php.

static ResourceLoader::makeLoaderQuery (   $modules,
  $lang,
  $skin,
  $user = null,
  $version = null,
  $debug = false,
  $only = null,
  $printable = false,
  $handheld = false,
  $extraQuery = [] 
)
static

Build a query array (array representation of query string) for load.php.

Helper function for createLoaderURL().

Parameters
array$modules
string$lang
string$skin
string$user
string$version
bool$debug
string$only
bool$printable
bool$handheld
array$extraQuery
Returns
array

Definition at line 1556 of file ResourceLoader.php.

Referenced by OutputPage\getRlClientContext().

static ResourceLoader::makeLoaderRegisterScript (   $name,
  $version = null,
  $dependencies = null,
  $group = null,
  $source = null,
  $skip = null 
)
static

Returns JS code which calls mw.loader.register with the given parameters.

Has three calling conventions:

Parameters
string$nameModule name
string$versionModule version hash
array$dependenciesList of module names on which this module depends
string$groupGroup which the module is in
string$sourceSource of the module, or 'local' if not foreign
string$skipScript body of the skip function
Returns
string

Definition at line 1329 of file ResourceLoader.php.

Referenced by ResourceLoaderStartUpModule\getModuleRegistrations().

static ResourceLoader::makeLoaderSourcesScript (   $id,
  $loadUrl = null 
)
static

Returns JS code which calls mw.loader.addSource() with the given parameters.

Has two calling conventions:

Parameters
string$idSource ID
string$loadUrlload.php url
Returns
string

Definition at line 1383 of file ResourceLoader.php.

Referenced by ResourceLoaderStartUpModule\getModuleRegistrations(), and ResourceLoaderTest\testMakeLoaderSourcesScript().

static ResourceLoader::makeLoaderStateScript (   $name,
  $state = null 
)
static

Returns a JS call to mw.loader.state, which sets the state of a module or modules to a given value.

Has two calling conventions:

Parameters
string$name
string$state
Returns
string

Definition at line 1227 of file ResourceLoader.php.

Referenced by ResourceLoaderClientHtml\getHeadHtml().

static ResourceLoader::makeMessageSetScript (   $messages)
static

Returns JS code which, when called, will register a given list of messages.

Parameters
mixed$messagesEither an associative array mapping message key to value, or a JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object.
Returns
string

Definition at line 1171 of file ResourceLoader.php.

ResourceLoader::makeModuleResponse ( ResourceLoaderContext  $context,
array  $modules,
array  $missing = [] 
)

Generate code for a response.

Parameters
ResourceLoaderContext$contextContext 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)
Returns
string Response data

Definition at line 976 of file ResourceLoader.php.

References $content, $e, $image, $name, $out, as, FormatJson\encode(), errors, ResourceLoaderContext\getDebug(), ResourceLoaderContext\getImageObj(), ResourceLoaderContext\getOnly(), ResourceLoaderContext\getRaw(), inDebugMode(), MWExceptionHandler\logException(), and ResourceLoaderContext\shouldIncludeScripts().

static ResourceLoader::makePackedModulesString (   $modules)
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'

Parameters
array$modulesList of module names (strings)
Returns
string Packed query string

Definition at line 1453 of file ResourceLoader.php.

Referenced by ResourceLoaderTest\testMakePackedModulesString().

ResourceLoader::makeVersionQuery ( ResourceLoaderContext  $context)

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.

Since
1.28
Parameters
ResourceLoaderContext$context
string[]$modules List of module names
Returns
string Hash

Definition at line 643 of file ResourceLoader.php.

References $name, as, and ResourceLoaderContext\getModules().

ResourceLoader::preloadModuleInfo ( array  $moduleNames,
ResourceLoaderContext  $context 
)

Load information stored in the database about modules.

This method grabs modules dependencies from the database and updates modules objects.

This is not inside the module code because it is much faster to request all of the information at once than it is to have each module requests its own information. This sacrifice of modularity yields a substantial performance improvement.

Parameters
array$moduleNamesList of module names to preload information for
ResourceLoaderContext$contextContext to load the information within

Definition at line 107 of file ResourceLoader.php.

References $blob, $dbr, $lang, $name, $res, $skin, as, DB_REPLICA, FormatJson\decode(), ResourceLoaderModule\expandRelativePaths(), ResourceLoaderContext\getLanguage(), getMessageBlobStore(), getModule(), ResourceLoaderContext\getSkin(), ResourceLoaderWikiModule\preloadTitleInfo(), and wfGetDB().

ResourceLoader::register (   $name,
  $info = null 
)

Register a module with the ResourceLoader system.

Parameters
mixed$nameName of module as a string or List of name/object pairs as an array
array$infoModule info array. For backwards compatibility with 1.17alpha, this may also be a ResourceLoaderModule object. Optional when using multiple-registration calling style.
Exceptions
MWExceptionIf a duplicate module registration is attempted
MWExceptionIf a module name contains illegal characters (pipes or commas)
MWExceptionIf something other than a ResourceLoaderModule is being registered
Returns
bool False if there were any errors, in which case one or more modules were not registered

Definition at line 318 of file ResourceLoader.php.

References $name, $path, array(), as, definition, ResourceLoaderFileModule\extractBasePaths(), from, MessageBlobStore\get(), list, or, and the.

ResourceLoader::registerTestModules ( )

Definition at line 396 of file ResourceLoader.php.

References $IP, as, global, Hooks\run(), and true.

Referenced by __construct().

ResourceLoader::sendResponseHeaders ( ResourceLoaderContext  $context,
  $etag,
  $errors 
)
protected

Send main response headers to the client.

Deals with Content-Type, CORS (for stylesheets), and caching.

Parameters
ResourceLoaderContext$context
string$etagETag header value
bool$errorsWhether there are errors in the response
Returns
void

Definition at line 795 of file ResourceLoader.php.

References ResourceLoaderContext\getDebug(), ResourceLoaderContext\getImageObj(), ResourceLoaderContext\getOnly(), ResourceLoaderContext\getVersion(), TS_RFC2822, and wfTimestamp().

ResourceLoader::setLogger ( LoggerInterface  $logger)
Since
1.26
Parameters
LoggerInterface$logger

Definition at line 277 of file ResourceLoader.php.

References $logger.

Referenced by EmptyResourceLoader\__construct().

ResourceLoader::setMessageBlobStore ( MessageBlobStore  $blobStore)
Since
1.25
Parameters
MessageBlobStore$blobStore

Definition at line 301 of file ResourceLoader.php.

References $blobStore.

Referenced by EmptyResourceLoader\__construct(), and __construct().

static ResourceLoader::trimArray ( array $array)
staticprivate

Remove empty values from the end of an array.

Values considered empty:

  • null
  • []
  • new XmlJsCode( '{}' )
  • new stdClass() // (object) []
Parameters
Array$array

Definition at line 1287 of file ResourceLoader.php.

ResourceLoader::tryRespondFromFileCache ( ResourceFileCache  $fileCache,
ResourceLoaderContext  $context,
  $etag 
)
protected

Send out code for a response from file cache if possible.

Parameters
ResourceFileCache$fileCacheCache object for this request URL
ResourceLoaderContext$contextContext in which to generate a response
string$etagETag header value
Returns
bool If this found a cache file and handled the response

Definition at line 883 of file ResourceLoader.php.

References $e, $response, FileCacheBase\cacheTimestamp(), DB_REPLICA, FileCacheBase\fetchText(), ResourceLoaderContext\getDebug(), ResourceLoaderContext\getVersion(), FileCacheBase\isCacheGood(), TS_MW, wfGetDB(), and wfTimestamp().

ResourceLoader::tryRespondNotModified ( ResourceLoaderContext  $context,
  $etag 
)
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.

Parameters
ResourceLoaderContext$context
string$etagETag header value
Returns
bool True if HTTP 304 was sent and output handled

Definition at line 850 of file ResourceLoader.php.

References ResourceLoaderContext\getDebug(), WebRequest\GETHEADER_LIST, ResourceLoaderContext\getRequest(), HttpStatus\header(), and wfResetOutputBuffers().

Member Data Documentation

MessageBlobStore ResourceLoader::$blobStore
protected

Definition at line 83 of file ResourceLoader.php.

Referenced by getMessageBlobStore(), and setMessageBlobStore().

ResourceLoader::$config
protected

Definition at line 59 of file ResourceLoader.php.

Referenced by EmptyResourceLoader\__construct(), __construct(), and getConfig().

bool ResourceLoader::$debugMode = null
staticprotected

Definition at line 41 of file ResourceLoader.php.

array ResourceLoader::$errors = []
protected

Errors accumulated during current respond() call.

Definition at line 78 of file ResourceLoader.php.

int ResourceLoader::$filterCacheVersion = 7
staticprotected

Definition at line 38 of file ResourceLoader.php.

array ResourceLoader::$lessVars = null
private

Definition at line 44 of file ResourceLoader.php.

LoggerInterface ResourceLoader::$logger
private

Definition at line 88 of file ResourceLoader.php.

Referenced by EmptyResourceLoader\__construct(), getLogger(), and setLogger().

array ResourceLoader::$moduleInfos = []
protected

Associative array mapping module name to info associative array.

Definition at line 56 of file ResourceLoader.php.

array ResourceLoader::$modules = []
protected

Module name/ResourceLoaderModule object pairs.

Definition at line 50 of file ResourceLoader.php.

array ResourceLoader::$sources = []
protected

E.g.

[ 'source-id' => 'http://.../load.php' ]

Definition at line 72 of file ResourceLoader.php.

array ResourceLoader::$testModuleNames = []
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 66 of file ResourceLoader.php.


The documentation for this class was generated from the following file: