22 $this->assertFileExists( $filename,
23 "File '$resource' referenced by '$module' must exist."
34 strpos( $cssText,
'@media' ) ===
false,
35 'Stylesheets should not both specify "media" and contain @media'
40 $data = self::getAllModules();
41 foreach ( $data[
'modules']
as $moduleName => $module ) {
42 $version = $module->getVersionHash( $data[
'context'] );
43 $this->assertEquals( 7, strlen( $version ),
"$moduleName must use ResourceLoader::makeHash" );
55 $data = self::getAllModules();
56 $illegalDeps = [
'jquery',
'mediawiki' ];
59 foreach ( $data[
'modules']
as $moduleName => $module ) {
60 foreach ( $illegalDeps
as $illegalDep ) {
61 $this->assertNotContains(
63 $module->getDependencies( $data[
'context'] ),
64 "Module '$moduleName' must not depend on '$illegalDep'"
74 $data = self::getAllModules();
75 $validDeps = array_keys( $data[
'modules'] );
78 foreach ( $data[
'modules']
as $moduleName => $module ) {
79 foreach ( $module->getDependencies( $data[
'context'] )
as $dep ) {
80 $this->assertContains(
83 "The module '$dep' required by '$moduleName' must exist"
93 $data = self::getAllModules();
94 $validDeps = array_keys( $data[
'modules'] );
98 foreach ( $data[
'modules']
as $moduleName => $module ) {
99 foreach ( $module->getMessages()
as $msgKey ) {
101 wfMessage( $msgKey )->useDatabase(
false )->inLanguage(
$lang )->exists(),
102 "Message '$msgKey' required by '$moduleName' must exist"
116 $data = self::getAllModules();
117 $validDeps = array_keys( $data[
'modules'] );
120 foreach ( $data[
'modules']
as $moduleName => $module ) {
121 $moduleTargets = $module->getTargets();
122 foreach ( $module->getDependencies( $data[
'context'] )
as $dep ) {
123 if ( !isset( $data[
'modules'][$dep] ) ) {
127 $targets = $data[
'modules'][$dep]->getTargets();
128 foreach ( $moduleTargets
as $moduleTarget ) {
129 $this->assertContains(
132 "The module '$moduleName' must not have target '$moduleTarget' "
133 .
"because its dependency '$dep' does not have it"
145 $basepath = __DIR__ .
'/../data/css/';
146 $css = file_get_contents( $basepath .
'comments.css' );
148 $expected = [ $basepath .
'not-commented.gif' ];
152 'Url(...) expression in comment should be omitted.'
161 global $wgEnableJavaScriptTest;
165 $org_wgEnableJavaScriptTest = $wgEnableJavaScriptTest;
166 $wgEnableJavaScriptTest =
true;
173 foreach ( $rl->getModuleNames()
as $moduleName ) {
174 $modules[$moduleName] = $rl->getModule( $moduleName );
178 $wgEnableJavaScriptTest = $org_wgEnableJavaScriptTest;
182 'resourceloader' => $rl,
192 $data = self::getAllModules();
195 foreach ( $data[
'modules']
as $moduleName => $module ) {
200 $reflectedModule =
new ReflectionObject( $module );
202 $getStyleFiles = $reflectedModule->getMethod(
'getStyleFiles' );
203 $getStyleFiles->setAccessible(
true );
205 $readStyleFile = $reflectedModule->getMethod(
'readStyleFile' );
206 $readStyleFile->setAccessible(
true );
208 $styleFiles = $getStyleFiles->invoke( $module, $data[
'context'] );
210 $flip = $module->getFlip( $data[
'context'] );
212 foreach ( $styleFiles
as $media =>
$files ) {
213 if ( $media && $media !==
'all' ) {
221 'cssText' => $readStyleFile->invoke(
245 $data = self::getAllModules();
265 foreach ( $data[
'modules']
as $moduleName => $module ) {
270 $reflectedModule =
new ReflectionObject( $module );
274 foreach ( $filePathProps[
'lists']
as $propName ) {
275 $property = $reflectedModule->getProperty( $propName );
278 foreach ( $list
as $key =>
$value ) {
283 if ( is_int( $key ) ) {
291 foreach ( $filePathProps[
'nested-lists']
as $propName ) {
292 $property = $reflectedModule->getProperty( $propName );
295 foreach ( $lists
as $list ) {
296 foreach ( $list
as $key =>
$value ) {
299 if ( is_int( $key ) ) {
309 $method = $reflectedModule->getMethod(
'getLocalPath' );
310 $method->setAccessible(
true );
315 $method->invoke( $module, $file ),
322 $module->readStyleFiles(
323 $module->getStyleFiles( $data[
'context'] ),
324 $module->getFlip( $data[
'context'] ),
328 $property = $reflectedModule->getProperty(
'missingLocalFileRefs' );
330 $missingLocalFileRefs =
$property->getValue( $module );
332 foreach ( $missingLocalFileRefs
as $file ) {
testMissingMessages()
Verify that all specified messages actually exist.
static provideMediaStylesheets()
Get all stylesheet files from modules that are an instance of ResourceLoaderFileModule (or one of its...
if(!isset($args[0])) $lang
when a variable name is used in a it is silently declared as a new local masking the global
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
testFileExistence($filename, $module, $resource)
provideResourceFiles
testMissingDependencies()
Verify that all modules specified as dependencies of other modules actually exist.
static array static getLocalFileReferences($source, $path)
Get a list of local files referenced in a stylesheet (includes non-existent files).
static getAllModules()
Get all registered modules from ResouceLoader.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock()-offset Set to overwrite offset parameter in $wgRequest set to ''to unsetoffset-wrap String Wrap the message in html(usually something like"<
ResourceLoader module based on local JavaScript/CSS files.
testStyleMedia($moduleName, $media, $filename, $css)
provideMediaStylesheets
testCommentedLocalFileReferences()
CSSMin::getLocalFileReferences should ignore url(...) expressions that have been commented out...
testIllegalDependencies()
Verify that nothing explicitly depends on the 'jquery' and 'mediawiki' modules.
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
An object to represent a path to a JavaScript/CSS file, along with a remote and local base path...
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
static minify($css)
Removes whitespace from CSS data.
static factory($code)
Get a cached or new language object for a given language code.
Dynamic JavaScript and CSS resource loading system.
static provideResourceFiles()
Get all resource files from modules that are an instance of ResourceLoaderFileModule (or one of its s...
testUnsatisfiableDependencies()
Verify that all dependencies of all modules are always satisfiable with the 'targets' defined for the...
Object passed around to modules which contains information about the state of a specific loader reque...