19 $module = TestingAccessWrapper::newFromClass( ResourceLoaderWikiModule::class );
21 foreach ( $mockInfo as $key => $val ) {
22 $info[ $module->makeTitleKey( Title::newFromText( $key ) ) ] =
$val;
33 [ [
'foo' =>
'baz' ] ],
35 [ [
'scripts' => [
'MediaWiki:Common.js' ] ] ],
45 $module->setConfig( $config );
49 $getPages->setAccessible(
true );
50 $out = $getPages->invoke( $module, ResourceLoaderContext::newDummyContext() );
61 'styles' => [
'MediaWiki:Common.css' ],
62 'scripts' => [
'MediaWiki:Common.js' ],
68 'MediaWiki:Common.js' => [
'type' =>
'script' ],
69 'MediaWiki:Common.css' => [
'type' =>
'style' ]
72 'MediaWiki:Common.js' => [
'type' =>
'script' ],
75 'MediaWiki:Common.css' => [
'type' =>
'style' ],
79 [
'UseSiteJs' =>
false,
'UseSiteCss' =>
false ]
100 [ [
'group' =>
'foobar' ],
'foobar' ],
109 $module = $this->
getMockBuilder( ResourceLoaderWikiModule::class )
110 ->setMethods( [
'getTitleInfo',
'getGroup',
'getDependencies' ] )
112 $module->expects( $this->
any() )
113 ->method(
'getTitleInfo' )
115 $module->expects( $this->
any() )
116 ->method(
'getGroup' )
118 $module->expects( $this->
any() )
119 ->method(
'getDependencies' )
122 ->disableOriginalConstructor()
130 [ [],
'test1', [],
true ],
133 [
'MediaWiki:Common.js' => [
'page_len' => 1234 ] ],
147 [
'MediaWiki:Common.js' => [
'page_len' => 0 ] ],
154 [
'MediaWiki:Foo.js' => [
'page_len' => 0 ] ],
161 [
'User:Example/common.js' => [
'page_len' => 25 ] ],
168 [
'User:Example/foo.js' => [
'page_len' => 0 ] ],
181 'MediaWiki:Common.css' => [
'type' =>
'styles' ],
182 'mediawiki: fallback.css' => [
'type' =>
'styles' ],
185 'MediaWiki:Common.css' => [
'page_len' => 1234 ],
186 'MediaWiki:Fallback.css' => [
'page_len' => 0 ],
188 $expected = $titleInfo;
190 $module = $this->
getMockBuilder( TestResourceLoaderWikiModule::class )
191 ->setMethods( [
'getPages' ] )
193 $module->method(
'getPages' )->willReturn( $pages );
195 $module::$returnFetchTitleInfo = $titleInfo;
198 ->disableOriginalConstructor()
201 $module = TestingAccessWrapper::newFromObject( $module );
212 'MediaWiki:Common.css' => [
'type' =>
'styles' ],
217 'mediawiki: fallback.css' => [
'type' =>
'styles' ],
220 'MediaWiki:Common.css' => [
'page_len' => 1234 ],
221 'MediaWiki:Fallback.css' => [
'page_len' => 0 ],
223 $expected = $titleInfo;
225 $module = $this->
getMockBuilder( TestResourceLoaderWikiModule::class )
226 ->setMethods( [
'getPages' ] )
228 $module->method(
'getPages' )->willReturn( $pages );
230 $module::$returnFetchTitleInfo = $titleInfo;
233 $rl->register(
'testmodule', $module );
237 Title::newFromText(
'MediaWiki:Common.css' ),
248 $module = TestingAccessWrapper::newFromObject( $module );
259 '[x]' => [
'type' =>
'styles' ],
264 $module = $this->
getMockBuilder( TestResourceLoaderWikiModule::class )
265 ->setMethods( [
'getPages' ] )->getMock();
266 $module->method(
'getPages' )->willReturn( $pages );
267 $module::$returnFetchTitleInfo = $titleInfo;
269 $rl->register(
'testmodule', $module );
280 $module = TestingAccessWrapper::newFromObject( $module );
292 ResourceLoaderWikiModule::preloadTitleInfo(
302 'Bad title' => [
null,
'[x]' ],
303 'Dead redirect' => [
null, [
304 'text' =>
'Dead redirect',
305 'title' =>
'Dead_redirect',
308 'Bad content model' => [
null, [
309 'text' =>
'MediaWiki:Wikitext',
311 'title' =>
'Wikitext',
313 'No JS content found' => [
null, [
314 'text' =>
'MediaWiki:Script.js',
316 'title' =>
'Script.js',
318 'No CSS content found' => [
null, [
319 'text' =>
'MediaWiki:Styles.css',
321 'title' =>
'Script.css',
332 $module = $this->
getMockBuilder( ResourceLoaderWikiModule::class )
333 ->setMethods( [
'getContentObj' ] )->getMock();
334 $module->expects( $this->
any() )
335 ->method(
'getContentObj' )->willReturn(
null );
338 $title += [
'ns' =>
NS_MAIN,
'id' => 1,
'len' => 1,
'redirect' => 0 ];
339 $titleText = $title[
'text'];
341 MediaWikiServices::getInstance()->getLinkCache()->addGoodLinkObj(
343 new TitleValue( $title[
'ns'], $title[
'title'] ),
351 $module = TestingAccessWrapper::newFromObject( $module );
354 $module->getContent( $titleText,
$context )
365 'MediaWiki:Common.css' => [
'type' =>
'style' ],
368 $module = $this->
getMockBuilder( TestResourceLoaderWikiModule::class )
369 ->setMethods( [
'getPages' ] )
371 $module->method(
'getPages' )->willReturn( $pages );
374 $rl->register(
'testmodule', $module );
379 if (
$t->getPrefixedText() ===
'MediaWiki:Common.css' ) {
380 return new CssContent(
'.override{}' );
388 "/*\nMediaWiki:Common.css\n*/\n.override{}"
390 ], $module->getStyles(
$context ) );
393 if (
$t->getPrefixedText() ===
'MediaWiki:Skin.css' ) {
394 return new CssContent(
'.override{}' );
410 $module = $this->
getMockBuilder( ResourceLoaderWikiModule::class )
411 ->setMethods( [
'getPages' ] )
413 $module->expects( $this->
any() )
414 ->method(
'getPages' )
416 'MediaWiki:Redirect.js' => [
'type' =>
'script' ]
418 $context->setContentOverrideCallback(
function (
Title $title ) {
419 if ( $title->getPrefixedText() ===
'MediaWiki:Redirect.js' ) {
420 $handler = new JavaScriptContentHandler();
421 return $handler->makeRedirectContent(
422 Title::makeTitle( NS_MEDIAWIKI,
'Target.js' )
424 } elseif ( $title->getPrefixedText() ===
'MediaWiki:Target.js' ) {
425 return new JavaScriptContent(
'target;' );
432 MediaWikiServices::getInstance()->getLinkCache()->addGoodLinkObj(
434 new TitleValue( NS_MEDIAWIKI,
'Redirect.js' ),
440 "/*\nMediaWiki:Redirect.js\n*/\ntarget;\n",
442 'Redirect resolved by getContent'
447 Title::clearCaches();
456 self::$returnFetchTitleInfo =
null;
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Allows changing specific properties of a context object, without changing the main one.
WebRequest clone which takes values from a provided array.
A Config instance which stores all settings as a member variable.
Object passed around to modules which contains information about the state of a specific loader reque...
getResourceLoaderContext( $options=[], ResourceLoader $rl=null)
testContentOverrides()
ResourceLoaderWikiModule::getContent ResourceLoaderWikiModule::getContentObj ResourceLoaderWikiModule...
prepareTitleInfo(array $mockInfo)
testGetContent( $expected, $title)
ResourceLoaderWikiModule::getContent provideGetContent.
testGetTitleInfo()
ResourceLoaderWikiModule::getTitleInfo.
testIsKnownEmpty( $titleInfo, $group, $dependencies, $expected)
ResourceLoaderWikiModule::isKnownEmpty provideIsKnownEmpty.
static provideGetContent()
testGetPreloadedTitleInfoEmpty()
ResourceLoaderWikiModule::preloadTitleInfo.
testConstructor( $params)
ResourceLoaderWikiModule::__construct provideConstructor.
static provideConstructor()
static provideIsKnownEmpty()
testGetGroup( $params, $expected)
ResourceLoaderWikiModule::getGroup provideGetGroup.
testGetPages( $params, Config $config, $expected)
provideGetPages ResourceLoaderWikiModule::getPages
testGetPreloadedTitleInfo()
ResourceLoaderWikiModule::getTitleInfo ResourceLoaderWikiModule::setTitleInfo ResourceLoaderWikiModul...
testGetContentForRedirects()
ResourceLoaderWikiModule::getContent ResourceLoaderWikiModule::getContentObj.
testGetPreloadedBadTitle()
ResourceLoaderWikiModule::preloadTitleInfo.
Abstraction for ResourceLoader modules which pull from wiki pages.
static preloadTitleInfo(ResourceLoaderContext $context, IDatabase $db, array $moduleNames)
static invalidateModuleCache(Title $title, Revision $old=null, Revision $new=null, $domain)
Clear the preloadTitleInfo() cache for all wiki modules on this wiki on page change if it was a JS or...
static $returnFetchTitleInfo
static fetchTitleInfo(IDatabase $db, array $pages, $fname=null)
Represents a page (or page fragment) title within MediaWiki.
Represents a title within MediaWiki.
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
namespace and then decline to actually register it file or subcat img or subcat $title
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 null
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 true
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
Interface for configuration instances.
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))