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"
97 $data = self::getAllModules();
98 $validDeps = array_keys( $data[
'modules'] );
101 foreach ( $data[
'modules']
as $moduleName => $module ) {
102 $moduleTargets = $module->getTargets();
103 foreach ( $module->getDependencies( $data[
'context'] )
as $dep ) {
104 if ( !isset( $data[
'modules'][$dep] ) ) {
108 $targets = $data[
'modules'][$dep]->getTargets();
109 foreach ( $moduleTargets
as $moduleTarget ) {
110 $this->assertContains(
113 "The module '$moduleName' must not have target '$moduleTarget' "
114 .
"because its dependency '$dep' does not have it"
126 $basepath = __DIR__ .
'/../data/css/';
127 $css = file_get_contents( $basepath .
'comments.css' );
129 $expected = [ $basepath .
'not-commented.gif' ];
133 'Url(...) expression in comment should be omitted.'
147 $wgEnableJavaScriptTest =
true;
154 foreach ( $rl->getModuleNames()
as $moduleName ) {
155 $modules[$moduleName] = $rl->getModule( $moduleName );
159 $wgEnableJavaScriptTest = $org_wgEnableJavaScriptTest;
162 'modules' => $modules,
163 'resourceloader' => $rl,
173 $data = self::getAllModules();
176 foreach ( $data[
'modules']
as $moduleName => $module ) {
181 $reflectedModule =
new ReflectionObject( $module );
183 $getStyleFiles = $reflectedModule->getMethod(
'getStyleFiles' );
184 $getStyleFiles->setAccessible(
true );
186 $readStyleFile = $reflectedModule->getMethod(
'readStyleFile' );
187 $readStyleFile->setAccessible(
true );
189 $styleFiles = $getStyleFiles->invoke( $module, $data[
'context'] );
191 $flip = $module->getFlip( $data[
'context'] );
193 foreach ( $styleFiles
as $media =>
$files ) {
194 if ( $media && $media !==
'all' ) {
202 'cssText' => $readStyleFile->invoke(
226 $data = self::getAllModules();
246 foreach ( $data[
'modules']
as $moduleName => $module ) {
251 $reflectedModule =
new ReflectionObject( $module );
255 foreach ( $filePathProps[
'lists']
as $propName ) {
256 $property = $reflectedModule->getProperty( $propName );
259 foreach ( $list
as $key =>
$value ) {
264 if ( is_int( $key ) ) {
272 foreach ( $filePathProps[
'nested-lists']
as $propName ) {
273 $property = $reflectedModule->getProperty( $propName );
276 foreach ( $lists
as $list ) {
277 foreach ( $list
as $key =>
$value ) {
280 if ( is_int( $key ) ) {
290 $method = $reflectedModule->getMethod(
'getLocalPath' );
291 $method->setAccessible(
true );
296 $method->invoke( $module, $file ),
303 $module->readStyleFiles(
304 $module->getStyleFiles( $data[
'context'] ),
305 $module->getFlip( $data[
'context'] ),
309 $property = $reflectedModule->getProperty(
'missingLocalFileRefs' );
311 $missingLocalFileRefs =
$property->getValue( $module );
313 foreach ( $missingLocalFileRefs
as $file ) {
static provideMediaStylesheets()
Get all stylesheet files from modules that are an instance of ResourceLoaderFileModule (or one of its...
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.
$wgEnableJavaScriptTest
Allow running of javascript test suites via [[Special:JavaScriptTest]] (such as QUnit).
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.
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.
WebRequest clone which takes values from a provided array.
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...