7 '{blankVer}' => self::BLANK_VERSION
14 'msg' =>
'Empty registry',
18 "local": "/w/load.php"
20mw.loader.register( [] );'
23 'msg' =>
'Basic registry',
29 "local": "/w/load.php"
39 'msg' =>
'Omit raw modules from registry',
46 "local": "/w/load.php"
56 'msg' =>
'Version falls back gracefully if getVersionHash throws',
59 ( $mock = $this->getMockBuilder( ResourceLoaderTestModule::class )
60 ->setMethods( [
'getVersionHash' ] )->getMock() )
61 && $mock->method(
'getVersionHash' )->will(
62 $this->throwException(
new Exception )
68 "local": "/w/load.php"
81 'msg' =>
'Use version from getVersionHash',
84 ( $mock = $this->getMockBuilder( ResourceLoaderTestModule::class )
85 ->setMethods( [
'getVersionHash' ] )->getMock() )
86 && $mock->method(
'getVersionHash' )->willReturn(
'1234567' )
91 "local": "/w/load.php"
101 'msg' =>
'Re-hash version from getVersionHash if too long',
104 ( $mock = $this->getMockBuilder( ResourceLoaderTestModule::class )
105 ->setMethods( [
'getVersionHash' ] )->getMock() )
106 && $mock->method(
'getVersionHash' )->willReturn(
'12345678' )
110mw.loader.addSource( {
111 "local": "/w/load.php"
121 'msg' =>
'Group signature',
128mw.loader.addSource( {
129 "local": "/w/load.php"
151 'msg' =>
'Different target (non-test should not be registered)',
157mw.loader.addSource( {
158 "local": "/w/load.php"
168 'msg' =>
'Safemode disabled (default; register all modules)',
183mw.loader.addSource( {
184 "local": "/w/load.php"
192 "test.core-generated",
206 'msg' =>
'Safemode enabled (filter modules with user/site origin)',
207 'extraQuery' => [
'safemode' =>
'1' ],
222mw.loader.addSource( {
223 "local": "/w/load.php"
231 "test.core-generated",
237 'msg' =>
'Foreign source',
240 'loadScript' =>
'http://example.org/w/load.php',
241 'apiScript' =>
'http://example.org/w/api.php',
248mw.loader.addSource( {
249 "local": "/w/load.php",
250 "example": "http://example.org/w/load.php"
263 'msg' =>
'Conditional dependency function',
267 'skipFunction' =>
'return true;'
286mw.loader.addSource( {
287 "local": "/w/load.php"
308 "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);"
326 'msg' =>
'Advanced (everything combined)',
329 'loadScript' =>
'http://example.org/w/load.php',
330 'apiScript' =>
'http://example.org/w/api.php',
371 'source' =>
'example',
374 'targets' => [
'x-foo' ],
377 'source' =>
'example',
378 'targets' => [
'x-foo' ],
382mw.loader.addSource( {
383 "local": "/w/load.php",
384 "example": "http://example.org/w/load.php"
462 $extraQuery = $case[
'extraQuery'] ?? [];
464 $rl =
$context->getResourceLoader();
465 if ( isset( $case[
'sources'] ) ) {
466 $rl->addSource( $case[
'sources'] );
468 $rl->register( $case[
'modules'] );
470 $out = ltrim( $case[
'out'],
"\n" );
474 $this->
setLogger(
'exception',
new Psr\Log\NullLogger() );
477 self::expandPlaceholders(
$out ),
478 $module->getModuleRegistrations(
$context ),
510 $rl =
$context->getResourceLoader();
513 $out =
'mw.loader.addSource({"local":"/w/load.php"});' .
"\n"
514 .
'mw.loader.register(['
515 .
'["test.blank","{blankVer}"],'
516 .
'["test.min","{blankVer}",[0],null,null,'
517 .
'"return!!(window.JSON\u0026\u0026JSON.parse\u0026\u0026JSON.stringify);"'
521 self::expandPlaceholders(
$out ),
522 $module->getModuleRegistrations(
$context ),
533 $rl =
$context->getResourceLoader();
537'mw.loader.addSource( {
538 "local": "/w/load.php"
553 "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);"
558 self::expandPlaceholders(
$out ),
559 $module->getModuleRegistrations(
$context ),
571 $module =
new ResourceLoaderStartupModule();
572 $version1 = $module->getVersionHash(
$context );
573 $module =
new ResourceLoaderStartupModule();
574 $version2 = $module->getVersionHash(
$context );
577 $module =
new ResourceLoaderStartupModule();
578 $version3 = $module->getVersionHash(
$context );
583 'Deterministic version hash'
586 $this->assertNotEquals(
589 'Config change impacts version hash'
598 $rl1 = $context1->getResourceLoader();
603 $module =
new ResourceLoaderStartupModule();
604 $version1 = $module->getVersionHash( $context1 );
607 $rl2 = $context2->getResourceLoader();
612 $module =
new ResourceLoaderStartupModule();
613 $version2 = $module->getVersionHash( $context2 );
616 $rl3 = $context3->getResourceLoader();
621 $module =
new ResourceLoaderStartupModule();
622 $version3 = $module->getVersionHash( $context3 );
625 $this->assertNotEquals(
628 'Module name is significant'
631 $this->assertNotEquals(
634 'Hash change of any module impacts startup hash'
643 $rl =
$context->getResourceLoader();
647 $module =
new ResourceLoaderStartupModule();
648 $version1 = $module->getVersionHash(
$context );
651 $rl =
$context->getResourceLoader();
655 $module =
new ResourceLoaderStartupModule();
656 $version2 = $module->getVersionHash(
$context );
659 $this->assertNotEquals(
662 'Dependencies are significant'
const ORIGIN_USER_SITEWIDE
const ORIGIN_USER_INDIVIDUAL
const ORIGIN_CORE_INDIVIDUAL
testGetVersionHash_varyDeps()
ResourceLoaderStartupModule.
static provideRegistrations()
testGetVersionHash_varyConfig()
ResourceLoaderStartupModule::getDefinitionSummary.
provideGetModuleRegistrations()
testGetVersionHash_varyModule()
ResourceLoaderStartupModule.
testRegistrationsUnminified( $modules)
ResourceLoaderStartUpModule::getModuleRegistrations provideRegistrations.
testGetModuleRegistrations( $case)
provideGetModuleRegistrations ResourceLoaderStartUpModule::getModuleRegistrations ResourceLoaderStart...
static expandPlaceholders( $text)
testRegistrationsMinified( $modules)
ResourceLoaderStartUpModule::getModuleRegistrations provideRegistrations.
Module for ResourceLoader initialization.
getResourceLoaderContext( $options=[], ResourceLoader $rl=null)
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
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
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