21 $this->assertFileExists( $filename,
22 "File '$resource' referenced by '$module' must exist."
33 strpos( $cssText,
'@media' ) ===
false,
34 'Stylesheets should not both specify "media" and contain @media'
40 foreach ( $data[
'modules']
as $moduleName => $module ) {
41 $version = $module->getVersionHash( $data[
'context'] );
42 $this->assertEquals( 7, strlen( $version ),
"$moduleName must use ResourceLoader::makeHash" );
55 $illegalDeps = [
'jquery',
'mediawiki' ];
58 foreach ( $data[
'modules']
as $moduleName => $module ) {
59 foreach ( $illegalDeps
as $illegalDep ) {
60 $this->assertNotContains(
62 $module->getDependencies( $data[
'context'] ),
63 "Module '$moduleName' must not depend on '$illegalDep'"
74 $validDeps = array_keys( $data[
'modules'] );
77 foreach ( $data[
'modules']
as $moduleName => $module ) {
78 foreach ( $module->getDependencies( $data[
'context'] )
as $dep ) {
79 $this->assertContains(
82 "The module '$dep' required by '$moduleName' must exist"
93 $lang = Language::factory(
'en' );
96 foreach ( $data[
'modules']
as $moduleName => $module ) {
97 foreach ( $module->getMessages()
as $msgKey ) {
99 wfMessage( $msgKey )->useDatabase(
false )->inLanguage(
$lang )->exists(),
100 "Message '$msgKey' required by '$moduleName' must exist"
117 foreach ( $data[
'modules']
as $moduleName => $module ) {
118 $moduleTargets = $module->getTargets();
119 foreach ( $module->getDependencies( $data[
'context'] )
as $dep ) {
120 if ( !isset( $data[
'modules'][$dep] ) ) {
124 $targets = $data[
'modules'][$dep]->getTargets();
125 foreach ( $moduleTargets
as $moduleTarget ) {
126 $this->assertContains(
129 "The module '$moduleName' must not have target '$moduleTarget' "
130 .
"because its dependency '$dep' does not have it"
142 $basepath = __DIR__ .
'/../data/css/';
143 $css = file_get_contents( $basepath .
'comments.css' );
145 $expected = [ $basepath .
'not-commented.gif' ];
149 'Url(...) expression in comment should be omitted.'
170 foreach ( $rl->getModuleNames()
as $moduleName ) {
171 $modules[$moduleName] = $rl->getModule( $moduleName );
179 'resourceloader' => $rl,
192 foreach ( $data[
'modules']
as $moduleName => $module ) {
197 $reflectedModule =
new ReflectionObject( $module );
199 $getStyleFiles = $reflectedModule->getMethod(
'getStyleFiles' );
200 $getStyleFiles->setAccessible(
true );
202 $readStyleFile = $reflectedModule->getMethod(
'readStyleFile' );
203 $readStyleFile->setAccessible(
true );
205 $styleFiles = $getStyleFiles->invoke( $module, $data[
'context'] );
207 $flip = $module->getFlip( $data[
'context'] );
209 foreach ( $styleFiles
as $media => $files ) {
210 if ( $media && $media !==
'all' ) {
211 foreach ( $files
as $file ) {
218 'cssText' => $readStyleFile->invoke(
262 foreach ( $data[
'modules']
as $moduleName => $module ) {
267 $reflectedModule =
new ReflectionObject( $module );
271 foreach ( $filePathProps[
'lists']
as $propName ) {
272 $property = $reflectedModule->getProperty( $propName );
275 foreach ( $list
as $key =>
$value ) {
280 if ( is_int( $key ) ) {
288 foreach ( $filePathProps[
'nested-lists']
as $propName ) {
289 $property = $reflectedModule->getProperty( $propName );
292 foreach ( $lists
as $list ) {
293 foreach ( $list
as $key =>
$value ) {
296 if ( is_int( $key ) ) {
306 $method = $reflectedModule->getMethod(
'getLocalPath' );
307 $method->setAccessible(
true );
310 foreach ( $files
as $file ) {
312 $method->invoke( $module, $file ),
319 $module->readStyleFiles(
320 $module->getStyleFiles( $data[
'context'] ),
321 $module->getFlip( $data[
'context'] ),
325 $property = $reflectedModule->getProperty(
'missingLocalFileRefs' );
327 $missingLocalFileRefs =
$property->getValue( $module );
329 foreach ( $missingLocalFileRefs
as $file ) {
$wgEnableJavaScriptTest
Allow running of javascript test suites via [[Special:JavaScriptTest]] (such as QUnit).
static getLocalFileReferences( $source, $path)
Get a list of local files referenced in a stylesheet (includes non-existent files).
static minify( $css)
Removes whitespace from CSS data.
WebRequest clone which takes values from a provided array.
Object passed around to modules which contains information about the state of a specific loader reque...
ResourceLoader module based on local JavaScript/CSS files.
An object to represent a path to a JavaScript/CSS file, along with a remote and local base path,...
Dynamic JavaScript and CSS resource loading system.
testFileExistence( $filename, $module, $resource)
provideResourceFiles
static getAllModules()
Get all registered modules from ResouceLoader.
testUnsatisfiableDependencies()
Verify that all dependencies of all modules are always satisfiable with the 'targets' defined for the...
testIllegalDependencies()
Verify that nothing explicitly depends on the 'jquery' and 'mediawiki' modules.
static provideMediaStylesheets()
Get all stylesheet files from modules that are an instance of ResourceLoaderFileModule (or one of its...
static provideResourceFiles()
Get all resource files from modules that are an instance of ResourceLoaderFileModule (or one of its s...
testMissingDependencies()
Verify that all modules specified as dependencies of other modules actually exist.
testCommentedLocalFileReferences()
CSSMin::getLocalFileReferences should ignore url(...) expressions that have been commented out.
testStyleMedia( $moduleName, $media, $filename, $css)
provideMediaStylesheets
testMissingMessages()
Verify that all specified messages actually exist.
when a variable name is used in a it is silently declared as a new local masking the global
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
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
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 unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
if(!isset( $args[0])) $lang