30use Wikimedia\ScopedCallback;
31use Wikimedia\TestingAccessWrapper;
46 'extraParserTests.txt',
58 'staticSetup' =>
false,
59 'perTestSetup' =>
false,
60 'setupDatabase' =>
false,
61 'setDatabase' =>
false,
62 'setupUploads' =>
false,
127 if ( in_array( $func, [
'removeTbody',
'trimWhitespace' ] ) ) {
128 $this->normalizationFunctions[] = $func;
131 "Warning: unknown normalization option \"$func\"\n" );
143 $this->keepUploads = !empty(
$options[
'keep-uploads'] );
145 $this->fileBackendName = isset(
$options[
'file-backend'] ) ?
148 $this->runDisabled = !empty(
$options[
'run-disabled'] );
149 $this->runParsoid = !empty(
$options[
'run-parsoid'] );
152 if ( !$this->tidySupport->isEnabled() ) {
153 $this->recorder->warning(
154 "Warning: tidy is not installed, skipping some tests\n" );
157 if ( isset(
$options[
'upload-dir'] ) ) {
158 $this->uploadDir =
$options[
'upload-dir'];
171 $files = array_map(
function ( $item ) {
172 return __DIR__ .
"/$item";
180 foreach ( $registry->getAllThings()
as $info ) {
181 $dir = dirname( $info[
'path'] ) .
'/tests/parser';
182 if ( !file_exists( $dir ) ) {
186 $dirIterator =
new RecursiveIteratorIterator(
187 new RecursiveDirectoryIterator( $dir )
189 foreach ( $dirIterator
as $fileInfo ) {
191 if ( substr( $fileInfo->getFilename(), -4 ) ===
'.txt' ) {
192 $name = $info[
'name'] . $counter;
193 while ( isset( $files[
$name] ) ) {
194 $name = $info[
'name'] .
'_' . $counter++;
196 $files[
$name] = $fileInfo->getPathname();
201 return array_unique( $files );
257 $setup[
'wgSitename'] =
'MediaWiki';
258 $setup[
'wgServer'] =
'http://example.org';
259 $setup[
'wgServerName'] =
'example.org';
260 $setup[
'wgScriptPath'] =
'';
261 $setup[
'wgScript'] =
'/index.php';
262 $setup[
'wgResourceBasePath'] =
'';
263 $setup[
'wgStylePath'] =
'/skins';
264 $setup[
'wgExtensionAssetsPath'] =
'/extensions';
265 $setup[
'wgArticlePath'] =
'/wiki/$1';
266 $setup[
'wgActionPaths'] = [];
267 $setup[
'wgVariantArticlePath'] =
false;
268 $setup[
'wgUploadNavigationUrl'] =
false;
269 $setup[
'wgCapitalLinks'] =
true;
270 $setup[
'wgNoFollowLinks'] =
true;
271 $setup[
'wgNoFollowDomainExceptions'] = [
'no-nofollow.org' ];
272 $setup[
'wgExternalLinkTarget'] =
false;
273 $setup[
'wgExperimentalHtmlIds'] =
false;
274 $setup[
'wgLocaltimezone'] =
'UTC';
275 $setup[
'wgHtml5'] =
true;
276 $setup[
'wgDisableLangConversion'] =
false;
277 $setup[
'wgDisableTitleConversion'] =
false;
281 $setup[
'wgExtraInterlanguageLinkPrefixes'] = [
'mul' ];
286 $teardown[] =
function () {
291 $setup[
'wgLockManagers'] = [ [
292 'name' =>
'fsLockManager',
293 'class' =>
'NullLockManager',
295 'name' =>
'nullLockManager',
296 'class' =>
'NullLockManager',
298 $reset =
function () {
302 $teardown[] = $reset;
305 $setup[
'wgDefaultExternalStore'] =
false;
308 $setup[
'wgAdaptiveMessageCache'] =
true;
311 $setup[
'wgUseDatabaseMessages'] =
true;
312 $reset =
function () {
316 $teardown[] = $reset;
319 $setup[
'wgSVGConverter'] =
'null';
320 $setup[
'wgSVGConverters'] = [
'null' =>
'echo "1">$output' ];
323 Hooks::register(
'ParserGetVariableValueTs',
function ( &
$parser, &$ts ) {
327 $teardown[] =
function () {
328 Hooks::clear(
'ParserGetVariableValueTs' );
338 $setup[
'wgLocalInterwikis'] = [
'local',
'mi' ];
339 $reset =
function () {
343 $teardown[] = $reset;
346 MediaWikiServices::getInstance()->disableService(
'MediaHandlerFactory' );
347 MediaWikiServices::getInstance()->redefineService(
348 'MediaHandlerFactory',
350 $handlers =
$services->getMainConfig()->
get(
'ParserTestMediaHandlers' );
354 $teardown[] =
function () {
355 MediaWikiServices::getInstance()->resetServiceForTesting(
'MediaHandlerFactory' );
363 if ( isset( ObjectCache::$instances[
CACHE_DB] ) ) {
364 $savedCache = ObjectCache::$instances[
CACHE_DB];
366 $teardown[] =
function ()
use ( $savedCache ) {
367 ObjectCache::$instances[
CACHE_DB] = $savedCache;
380 $setup[
'wgExtraNamespaces'] = [
381 100 =>
'MemoryAlpha',
382 101 =>
'MemoryAlpha_talk'
386 $reset =
function () {
387 MWNamespace::getCanonicalNamespaces(
true );
388 $GLOBALS[
'wgContLang']->resetNamespaces();
391 $teardown[] = $reset;
399 if ( $this->uploadDir ) {
400 if ( $this->fileBackendName ) {
401 throw new MWException(
'You cannot specify both use-filebackend and upload-dir' );
404 'name' =>
'local-backend',
406 'basePath' => $this->uploadDir,
409 } elseif ( $this->fileBackendName ) {
414 if ( $conf[
'name'] ===
$name ) {
418 if ( $useConfig ===
false ) {
419 throw new MWException(
"Unable to find file backend \"$name\"" );
421 $useConfig[
'name'] =
'local-backend';
422 unset( $useConfig[
'lockManager'] );
423 unset( $useConfig[
'fileJournal'] );
424 $class = $useConfig[
'class'];
425 $backend =
new $class( $useConfig );
427 # Replace with a mock. We do not care about generating real
428 # files on the filesystem, just need to expose the file
431 'name' =>
'local-backend',
438 'class' =>
'MockLocalRepo',
440 'url' =>
'http://example.com/images',
442 'transformVia404' =>
false,
443 'backend' => $backend
465 if ( is_int(
$name ) ) {
472 return function ()
use ( $saved ) {
490 return new ScopedCallback(
function ()
use ( $teardown, $nextTeardown ) {
492 $teardown = array_reverse( $teardown );
495 if ( $nextTeardown ) {
496 ScopedCallback::consume( $nextTeardown );
509 if ( $this->setupDone[$funcName] ) {
510 throw new MWException(
"$funcName is already done" );
512 $this->setupDone[$funcName] =
true;
513 return function ()
use ( $funcName ) {
514 $this->setupDone[$funcName] =
false;
525 if ( !$this->setupDone[$funcName]
526 && ( $funcName ===
null || !$this->setupDone[$funcName2] )
528 throw new MWException(
"$funcName must be called before calling " .
540 return isset( $this->setupDone[$funcName] ) ? $this->setupDone[$funcName] :
false;
555 # Hack: insert a few Wikipedia in-project interwiki prefixes,
556 # for testing inter-language links
557 Hooks::register(
'InterwikiLoadPrefix',
function ( $prefix, &$iwData ) {
558 static $testInterwikis = [
560 'iw_url' =>
'http://doesnt.matter.org/$1',
565 'iw_url' =>
'http://en.wikipedia.org/wiki/$1',
570 'iw_url' =>
'http://www.usemod.com/cgi-bin/mb.pl?$1',
575 'iw_url' =>
'http://www.memory-alpha.org/en/index.php/$1',
580 'iw_url' =>
'http://zh.wikipedia.org/wiki/$1',
585 'iw_url' =>
'http://es.wikipedia.org/wiki/$1',
590 'iw_url' =>
'http://fr.wikipedia.org/wiki/$1',
595 'iw_url' =>
'http://ru.wikipedia.org/wiki/$1',
600 'iw_url' =>
'http://mi.wikipedia.org/wiki/$1',
605 'iw_url' =>
'http://wikisource.org/wiki/$1',
610 if ( array_key_exists( $prefix, $testInterwikis ) ) {
611 $iwData = $testInterwikis[$prefix];
620 Hooks::clear(
'InterwikiLoadPrefix' );
629 $services = MediaWikiServices::getInstance();
630 $services->resetServiceForTesting(
'TitleFormatter' );
631 $services->resetServiceForTesting(
'TitleParser' );
632 $services->resetServiceForTesting(
'_MediaWikiTitleCodec' );
633 $services->resetServiceForTesting(
'LinkRenderer' );
634 $services->resetServiceForTesting(
'LinkRendererFactory' );
644 if ( substr(
$s, -1 ) ===
"\n" ) {
645 return substr(
$s, 0, -1 );
671 $this->recorder->start();
675 foreach ( $filenames
as $filename ) {
677 'runDisabled' => $this->runDisabled,
678 'runParsoid' => $this->runParsoid,
679 'regex' => $this->regex ] );
682 if ( !$testFileInfo[
'tests'] ) {
686 $this->recorder->startSuite( $filename );
687 $ok = $this->
runTests( $testFileInfo ) && $ok;
688 $this->recorder->endSuite( $filename );
691 $this->recorder->report();
692 }
catch ( DBError
$e ) {
693 $this->recorder->warning(
$e->getMessage() );
695 $this->recorder->end();
697 ScopedCallback::consume( $teardownGuard );
709 foreach ( $requirements
as $requirement ) {
710 switch ( $requirement[
'type'] ) {
717 case 'transparentHook':
741 if ( !$testFileInfo[
'tests'] ) {
747 foreach ( $testFileInfo[
'tests']
as $test ) {
748 $this->recorder->startTest( $test );
749 $this->recorder->skipped( $test,
'required extension not enabled' );
758 foreach ( $testFileInfo[
'tests']
as $test ) {
759 $this->recorder->startTest( $test );
763 $ok = $ok &&
$result->isSuccess();
764 $this->recorder->record( $test,
$result );
805 wfDebug( __METHOD__.
": running {$test['desc']}" );
814 if ( !isset( $opts[
'wrap'] ) ) {
815 $options->setWrapOutputClass(
false );
818 if ( isset( $opts[
'tidy'] ) ) {
819 if ( !$this->tidySupport->isEnabled() ) {
820 $this->recorder->skipped( $test,
'tidy extension is not installed' );
827 if ( isset( $opts[
'title'] ) ) {
828 $titleText = $opts[
'title'];
830 $titleText =
'Parser test';
833 $local = isset( $opts[
'local'] );
834 $preprocessor = isset( $opts[
'preprocessor'] ) ? $opts[
'preprocessor'] :
null;
836 $title = Title::newFromText( $titleText );
838 if ( isset( $opts[
'pst'] ) ) {
841 } elseif ( isset( $opts[
'msg'] ) ) {
843 } elseif ( isset( $opts[
'section'] ) ) {
846 } elseif ( isset( $opts[
'replace'] ) ) {
848 $replace = $opts[
'replace'][1];
850 } elseif ( isset( $opts[
'comment'] ) ) {
852 } elseif ( isset( $opts[
'preload'] ) ) {
856 $output->setTOCEnabled( !isset( $opts[
'notoc'] ) );
858 if ( isset( $opts[
'tidy'] ) ) {
859 $out = preg_replace(
'/\s+$/',
'',
$out );
862 if ( isset( $opts[
'showtitle'] ) ) {
863 if (
$output->getTitleText() ) {
867 $out =
"$title\n$out";
870 if ( isset( $opts[
'showindicators'] ) ) {
872 foreach (
$output->getIndicators()
as $id => $content ) {
873 $indicators .=
"$id=$content\n";
878 if ( isset( $opts[
'ill'] ) ) {
879 $out = implode(
' ',
$output->getLanguageLinks() );
880 } elseif ( isset( $opts[
'cat'] ) ) {
886 $out .=
"cat=$name sort=$sortkey";
891 if ( isset(
$output ) && isset( $opts[
'showflags'] ) ) {
892 $actualFlags = array_keys( TestingAccessWrapper::newFromObject(
$output )->mFlags );
893 sort( $actualFlags );
894 $out .=
"\nflags=" . join(
', ', $actualFlags );
897 ScopedCallback::consume( $teardownGuard );
899 $expected = $test[
'result'];
900 if ( count( $this->normalizationFunctions ) ) {
902 $test[
'expected'], $this->normalizationFunctions );
918 $key = strtolower( $key );
920 if ( isset( $opts[$key] ) ) {
943 (?<qstr> # Quoted string
945 (?:[^\\\\"] | \\\\.)*
951 [^"{}] | # Not a quoted string or object, or
952 (?&qstr) | # A quoted string, or
953 (?&json) # A json object (recursively)
959 (?&qstr) # Quoted val
967 (?&json) # JSON object
971 $regex =
'/' . $defs .
'\b
987 $valueregex =
'/' . $defs .
'(?&value)/x';
989 if ( preg_match_all(
$regex, $instring,
$matches, PREG_SET_ORDER ) ) {
991 $key = strtolower( $bits[
'k'] );
992 if ( !isset( $bits[
'v'] ) ) {
995 preg_match_all( $valueregex, $bits[
'v'], $vmatches );
996 $opts[$key] = array_map( [ $this,
'cleanupOption' ], $vmatches[0] );
997 if ( count( $opts[$key] ) == 1 ) {
998 $opts[$key] = $opts[$key][0];
1007 if ( substr(
$opt, 0, 1 ) ==
'"' ) {
1008 return stripcslashes( substr(
$opt, 1, -1 ) );
1011 if ( substr(
$opt, 0, 2 ) ==
'[[' ) {
1012 return substr(
$opt, 2, -2 );
1015 if ( substr(
$opt, 0, 1 ) ==
'{' ) {
1016 return FormatJson::decode(
$opt,
true );
1037 $config = $test[
'config'];
1046 $linkHolderBatchSize =
1054 'wgLanguageCode' => $langCode,
1056 'wgNamespacesWithSubpages' => array_fill_keys(
1057 MWNamespace::getValidNamespaces(), isset( $opts[
'subpage'] )
1059 'wgMaxTocLevel' => $maxtoclevel,
1062 'wgDefaultLanguageVariant' => $variant,
1063 'wgLinkHolderBatchSize' => $linkHolderBatchSize,
1067 + [
'ISBN' =>
true,
'PMID' =>
true,
'RFC' =>
true ],
1069 'wgFragmentMode' => [
'legacy' ],
1073 $configLines = explode(
"\n", $config );
1075 foreach ( $configLines
as $line ) {
1077 $setup[$var] = eval(
"return $value;" );
1082 Hooks::run(
'ParserTestGlobals', [ &$setup ] );
1085 if ( isset( $opts[
'tidy'] ) ) {
1087 if ( $this->tidyDriver ===
null ) {
1088 $this->tidyDriver =
MWTidy::factory( $this->tidySupport->getConfig() );
1095 $teardown[] =
function () {
1100 $lang = Language::factory( $langCode );
1101 $setup[
'wgContLang'] =
$lang;
1102 $reset =
function () {
1107 $teardown[] = $reset;
1111 $user->setOption(
'language', $langCode );
1112 $setup[
'wgLang'] =
$lang;
1115 $user->setOption(
'thumbsize', 0 );
1117 $setup[
'wgUser'] =
$user;
1125 $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
1128 $setup[
'wgOut'] =
$context->getOutput();
1129 $teardown[] =
function ()
use (
$context, $oldSkin ) {
1131 $wrapper = TestingAccessWrapper::newFromObject(
1132 $context->getLanguage()->getConverter()
1134 $wrapper->reloadTables();
1153 $tables = [
'user',
'user_properties',
'user_former_groups',
'page',
'page_restrictions',
1154 'protected_titles',
'revision',
'ip_changes',
'text',
'pagelinks',
'imagelinks',
1155 'categorylinks',
'templatelinks',
'externallinks',
'langlinks',
'iwlinks',
1156 'site_stats',
'ipblocks',
'image',
'oldimage',
1157 'recentchanges',
'watchlist',
'interwiki',
'logging',
'log_search',
1158 'querycache',
'objectcache',
'job',
'l10n_cache',
'redirect',
'querycachetwo',
1159 'archive',
'user_groups',
'page_props',
'category'
1162 if ( in_array( $this->db->getType(), [
'mysql',
'sqlite',
'oracle' ] ) ) {
1163 array_push(
$tables,
'searchindex' );
1169 Hooks::run(
'ParserTestTables', [ &
$tables ] );
1176 $this->setupDone[
'setDatabase'] =
true;
1200 $dbType = $this->db->getType();
1202 if ( $dbType ==
'oracle' ) {
1203 $suspiciousPrefixes = [
'pt_', MediaWikiTestCase::ORA_DB_PREFIX ];
1205 $suspiciousPrefixes = [
'parsertest_', MediaWikiTestCase::DB_PREFIX ];
1207 if ( in_array(
$wgDBprefix, $suspiciousPrefixes ) ) {
1208 throw new MWException(
"\$wgDBprefix=$wgDBprefix suggests DB setup is already done" );
1215 # CREATE TEMPORARY TABLE breaks if there is more than one server
1216 if (
wfGetLB()->getServerCount() != 1 ) {
1217 $this->useTemporaryTables =
false;
1220 $temporary = $this->useTemporaryTables || $dbType ==
'postgres';
1221 $prefix = $dbType !=
'oracle' ?
'parsertest_' :
'pt_';
1224 $this->dbClone->useTemporaryTables( $temporary );
1225 $this->dbClone->cloneTableStructure();
1227 if ( $dbType ==
'oracle' ) {
1228 $this->db->query(
'BEGIN FILL_WIKI_INFO; END;' );
1229 # Insert 0 user to prevent FK violations
1232 $this->db->insert(
'user', [
1234 'user_name' =>
'Anonymous' ] );
1237 $teardown[] =
function () {
1242 $reset =
function () {
1243 LinkCache::singleton()->clear();
1249 $teardown[] = $reset;
1272 $user = User::createNew(
'WikiSysop' );
1277 # note that the size/width/height/bits/etc of the file
1278 # are actually set by inspecting the file itself; the arguments
1279 # to recordUpload2 have no effect. That said, we try to make things
1280 # match up so it is less confusing to readers of the code & tests.
1281 $image->recordUpload2(
'',
'Upload of some lame file',
'Some lame file', [
1287 'mime' =>
'image/jpeg',
1289 'sha1' => Wikimedia\base_convert(
'1', 16, 36, 31 ),
1290 'fileExists' =>
true
1291 ], $this->db->timestamp(
'20010115123500' ),
$user );
1294 # again, note that size/width/height below are ignored; see above.
1295 $image->recordUpload2(
'',
'Upload of some lame thumbnail',
'Some lame thumbnail', [
1301 'mime' =>
'image/png',
1303 'sha1' => Wikimedia\base_convert(
'2', 16, 36, 31 ),
1304 'fileExists' =>
true
1305 ], $this->db->timestamp(
'20130225203040' ),
$user );
1308 $image->recordUpload2(
'',
'Upload of some lame SVG',
'Some lame SVG', [
1314 'mime' =>
'image/svg+xml',
1316 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1317 'fileExists' =>
true
1318 ], $this->db->timestamp(
'20010115123500' ),
$user );
1320 # This image will be blacklisted in [[MediaWiki:Bad image list]]
1322 $image->recordUpload2(
'',
'zomgnotcensored',
'Borderline image', [
1328 'mime' =>
'image/jpeg',
1330 'sha1' => Wikimedia\base_convert(
'3', 16, 36, 31 ),
1331 'fileExists' =>
true
1332 ], $this->db->timestamp(
'20010115123500' ),
$user );
1335 $image->recordUpload2(
'',
'A pretty movie',
'Will it play', [
1341 'mime' =>
'application/ogg',
1343 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1344 'fileExists' =>
true
1345 ], $this->db->timestamp(
'20010115123500' ),
$user );
1348 $image->recordUpload2(
'',
'An awesome hitsong',
'Will it play', [
1354 'mime' =>
'application/ogg',
1356 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1357 'fileExists' =>
true
1358 ], $this->db->timestamp(
'20010115123500' ),
$user );
1362 $image->recordUpload2(
'',
'Upload a DjVu',
'A DjVu', [
1368 'mime' =>
'image/vnd.djvu',
1369 'metadata' =>
'<?xml version="1.0" ?>
1370<!DOCTYPE DjVuXML PUBLIC "-//W3C//DTD DjVuXML 1.1//EN" "pubtext/DjVuXML-s.dtd">
1373<BODY><OBJECT height="3508" width="2480">
1374<PARAM name="DPI" value="300" />
1375<PARAM name="GAMMA" value="2.2" />
1377<OBJECT height="3508" width="2480">
1378<PARAM name="DPI" value="300" />
1379<PARAM name="GAMMA" value="2.2" />
1381<OBJECT height="3508" width="2480">
1382<PARAM name="DPI" value="300" />
1383<PARAM name="GAMMA" value="2.2" />
1385<OBJECT height="3508" width="2480">
1386<PARAM name="DPI" value="300" />
1387<PARAM name="GAMMA" value="2.2" />
1389<OBJECT height="3508" width="2480">
1390<PARAM name="DPI" value="300" />
1391<PARAM name="GAMMA" value="2.2" />
1395 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1396 'fileExists' =>
true
1397 ], $this->db->timestamp(
'20010115123600' ),
$user );
1411 $this->dbClone->destroy();
1412 $this->databaseSetupDone =
false;
1414 if ( $this->useTemporaryTables ) {
1415 if ( $this->db->getType() ==
'sqlite' ) {
1416 # Under SQLite the searchindex table is virtual and need
1417 # to be explicitly destroyed. See T31912
1418 # See also MediaWikiTestCase::destroyDB()
1419 wfDebug( __METHOD__ .
" explicitly destroying sqlite virtual table parsertest_searchindex\n" );
1420 $this->db->query(
"DROP TABLE `parsertest_searchindex`" );
1422 # Don't need to do anything
1429 if ( $this->db->getType() ==
'oracle' ) {
1430 $this->db->query(
"DROP TABLE pt_$table DROP CONSTRAINTS" );
1432 $this->db->query(
"DROP TABLE `parsertest_$table`" );
1436 if ( $this->db->getType() ==
'oracle' ) {
1437 $this->db->query(
'BEGIN FILL_WIKI_INFO; END;' );
1450 $base = $repo->getZonePath(
'public' );
1451 $backend = $repo->getBackend();
1452 $backend->prepare( [
'dir' =>
"$base/3/3a" ] );
1454 'src' =>
"$IP/tests/phpunit/data/parser/headbg.jpg",
1455 'dst' =>
"$base/3/3a/Foobar.jpg"
1457 $backend->prepare( [
'dir' =>
"$base/e/ea" ] );
1459 'src' =>
"$IP/tests/phpunit/data/parser/wiki.png",
1460 'dst' =>
"$base/e/ea/Thumb.png"
1462 $backend->prepare( [
'dir' =>
"$base/0/09" ] );
1464 'src' =>
"$IP/tests/phpunit/data/parser/headbg.jpg",
1465 'dst' =>
"$base/0/09/Bad.jpg"
1467 $backend->prepare( [
'dir' =>
"$base/5/5f" ] );
1469 'src' =>
"$IP/tests/phpunit/data/parser/LoremIpsum.djvu",
1470 'dst' =>
"$base/5/5f/LoremIpsum.djvu"
1474 $data =
'<?xml version="1.0" encoding="utf-8"?>' .
1475 '<svg xmlns="http://www.w3.org/2000/svg"' .
1476 ' version="1.1" width="240" height="180"/>';
1478 $backend->prepare( [
'dir' =>
"$base/f/ff" ] );
1479 $backend->quickCreate( [
1480 'content' => $data,
'dst' =>
"$base/f/ff/Foobar.svg"
1483 return function ()
use ( $backend ) {
1496 if ( $this->keepUploads ) {
1501 $public = $repo->getZonePath(
'public' );
1505 "$public/3/3a/Foobar.jpg",
1506 "$public/e/ea/Thumb.png",
1507 "$public/0/09/Bad.jpg",
1508 "$public/5/5f/LoremIpsum.djvu",
1509 "$public/f/ff/Foobar.svg",
1510 "$public/0/00/Video.ogv",
1511 "$public/4/41/Audio.oga",
1523 foreach ( $files
as $file ) {
1524 $backend->delete( [
'src' => $file ], [
'force' => 1 ] );
1528 foreach ( $files
as $file ) {
1531 if ( !$backend->clean( [
'dir' => $tmp ] )->isOK() ) {
1552 $setup[
'wgLanguageCode'] =
'en';
1553 $setup[
'wgContLang'] = Language::factory(
'en' );
1560 $setup[
'wgCapitalLinks'] =
true;
1564 foreach ( $articles
as $info ) {
1565 $this->
addArticle( $info[
'name'], $info[
'text'], $info[
'file'], $info[
'line'] );
1570 ObjectCache::getMainWANInstance()->clearProcessCache();
1589 wfDebug( __METHOD__ .
": adding $name" );
1591 if ( is_null(
$title ) ) {
1592 throw new MWException(
"invalid title '$name' at $file:$line\n" );
1596 $page->loadPageData(
'fromdbmaster' );
1598 if ( $page->exists() ) {
1599 throw new MWException(
"duplicate article '$name' at $file:$line\n" );
1608 $status = $page->doEditContent(
1640 $this->recorder->warning(
" This test suite requires the '$name' hook " .
1641 "extension, skipping." );
1660 $this->recorder->warning(
" This test suite requires the '$name' function " .
1661 "hook extension, skipping." );
1680 $this->recorder->warning(
" This test suite requires the '$name' transparent " .
1681 "hook extension, skipping.\n" );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgObjectCaches
Advanced object cache configuration.
$wgFileBackends
File backend structure configuration.
$wgDBprefix
Table name prefix.
$wgParserTestFiles
Parser test suite files to be run by parserTests.php when no specific filename is passed to it.
$wgParserConf
Parser configuration.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTempDir()
Tries to get the system directory for temporary files.
wfGetLB( $wiki=false)
Get a load balancer object.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Class for a file system (FS) based file backend.
static parentStoragePath( $storagePath)
Get the parent storage directory of a storage path.
Simple store for keeping values in an associative array for the current process.
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
static destroySingletons()
Destroy the singleton instances.
static factory(array $config)
Create a new Tidy driver object from configuration.
static setInstance( $instance)
Set the driver to be used.
static destroySingleton()
Destroy the current singleton instance.
static clearCache()
Clear the self::$mObjects variable For use in parser tests.
static destroyInstance()
Destroy the singleton instance.
static singleton()
Get the signleton instance of this class.
Class simulating a backend store.
This class should be covered by a general architecture document which does not exist as of January 20...
A parser used during article insertion which does nothing, to avoid unnecessary log noise and other i...
static normalize( $text, $funcs)
Represent the result of a parser test.
listTables()
List of temporary tables to create, without prefix.
runTestsFromFiles( $filenames)
Run a series of tests listed in the given text files.
staticSetup( $nextTeardown=null)
Do any setup which can be done once for all tests, independent of test options, except for database s...
markSetupDone( $funcName)
Set a setupDone flag to indicate that setup has been done, and return the teardown closure.
string $regex
A complete regex for filtering tests.
runTest( $test)
Run a given wikitext input through a freshly-constructed wiki parser, and compare the output against ...
setupUploads( $nextTeardown=null)
Add data about uploads to the new test DB, and set up the upload directory.
createRepoGroup()
Create a RepoGroup object appropriate for the current configuration.
createTeardownObject( $teardown, $nextTeardown=null)
Take a setup array in the same format as the one given to executeSetupSnippets(), and return a Scoped...
teardownUploadBackend()
Remove the dummy uploads directory.
static array $coreTestFiles
MediaWiki core parser test files, paths will be prefixed with DIR .
string null $uploadDir
The upload directory, or null to not set up an upload directory.
setupDatabase( $nextTeardown=null)
Set up temporary DB tables.
checkSetupDone( $funcName, $funcName2=null)
Ensure a given setup stage has been done, throw an exception if it has not.
static getParserTestFiles()
Get list of filenames to extension and core parser tests.
requireHook( $name)
Check if a hook is installed.
setDatabase(IDatabase $db)
array $normalizationFunctions
A list of normalization functions to apply to the expected and actual output.
isSetupDone( $funcName)
Determine whether a particular setup function has been run.
resetTitleServices()
Reset the Title-related services that need resetting for each test.
string null $fileBackendName
The name of the file backend to use, or null to use MockFileBackend.
deleteFiles( $files)
Delete the specified files and their parent directories.
static getOptionValue( $key, $opts, $default)
Use a regex to find out the value of an option.
perTestSetup( $test, $nextTeardown=null)
Do any required setup which is dependent on test options.
Database $db
Our connection to the database.
setupInterwikis()
Insert hardcoded interwiki in the lookup table.
__construct(TestRecorder $recorder, $options=[])
requireTransparentHook( $name)
Check if a transparent tag hook is installed.
CloneDatabase $dbClone
Database clone helper.
runTests( $testFileInfo)
Run the tests from a single file.
teardownDatabase()
Helper for database teardown, called from the teardown closure.
requireFunctionHook( $name)
Check if a function hook is installed.
meetsRequirements( $requirements)
Determine whether the current parser has the hooks registered in it that are required by a file read ...
setupUploadBackend()
Upload test files to the backend created by createRepoGroup().
executeSetupSnippets( $setup)
Execute an array in which elements with integer keys are taken to be callable objects,...
addArticles( $articles)
Add articles to the test DB.
getFakeTimestamp()
Fake constant timestamp to make sure time-related parser functions give a persistent value.
static chomp( $s)
Remove last character if it is a newline utility.
TidyDriverBase $tidyDriver
parseOptions( $instring)
Given the options string, return an associative array of options.
addArticle( $name, $text, $file, $line)
Insert a temporary test article.
getParser( $preprocessor=null)
Get a Parser object.
appendNamespaceSetup(&$setup, &$teardown)
Prioritized list of file repositories.
static singleton()
Get a RepoGroup instance.
static setSingleton( $instance)
Set the singleton instance to a given object Used by extensions which hook into the Repo chain.
static destroySingleton()
Destroy the singleton instance, so that a new one will be created next time singleton() is called.
static getMain()
Static methods.
static read( $file, array $options=[])
Interface to record parser test results.
warning( $message)
Show a warning to the user.
Initialize and detect the tidy support.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
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
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
the array() calling protocol came about after MediaWiki 1.4rc1.
do that in ParserLimitReportFormat instead $parser
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check $image
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 & $options
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
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
Allows to change the fields on the form that will be generated $name
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 an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
returning false will NOT prevent logging $e
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