44 'staticSetup' =>
false,
45 'perTestSetup' =>
false,
46 'setupDatabase' =>
false,
47 'setDatabase' =>
false,
48 'setupUploads' =>
false,
113 if ( in_array( $func, [
'removeTbody',
'trimWhitespace' ] ) ) {
114 $this->normalizationFunctions[] = $func;
117 "Warning: unknown normalization option \"$func\"\n" );
129 $this->keepUploads = !empty(
$options[
'keep-uploads'] );
131 $this->fileBackendName = isset(
$options[
'file-backend'] ) ?
134 $this->runDisabled = !empty(
$options[
'run-disabled'] );
135 $this->runParsoid = !empty(
$options[
'run-parsoid'] );
138 if ( !$this->tidySupport->isEnabled() ) {
139 $this->recorder->warning(
140 "Warning: tidy is not installed, skipping some tests\n" );
143 if ( isset(
$options[
'upload-dir'] ) ) {
144 $this->uploadDir =
$options[
'upload-dir'];
201 $setup[
'wgSitename'] =
'MediaWiki';
202 $setup[
'wgServer'] =
'http://example.org';
203 $setup[
'wgServerName'] =
'example.org';
204 $setup[
'wgScriptPath'] =
'';
205 $setup[
'wgScript'] =
'/index.php';
206 $setup[
'wgResourceBasePath'] =
'';
207 $setup[
'wgStylePath'] =
'/skins';
208 $setup[
'wgExtensionAssetsPath'] =
'/extensions';
209 $setup[
'wgArticlePath'] =
'/wiki/$1';
210 $setup[
'wgActionPaths'] = [];
211 $setup[
'wgVariantArticlePath'] =
false;
212 $setup[
'wgUploadNavigationUrl'] =
false;
213 $setup[
'wgCapitalLinks'] =
true;
214 $setup[
'wgNoFollowLinks'] =
true;
215 $setup[
'wgNoFollowDomainExceptions'] = [
'no-nofollow.org' ];
216 $setup[
'wgExternalLinkTarget'] =
false;
217 $setup[
'wgExperimentalHtmlIds'] =
false;
218 $setup[
'wgLocaltimezone'] =
'UTC';
219 $setup[
'wgHtml5'] =
true;
220 $setup[
'wgDisableLangConversion'] =
false;
221 $setup[
'wgDisableTitleConversion'] =
false;
225 $setup[
'wgExtraInterlanguageLinkPrefixes'] = [
'mul' ];
230 $teardown[] =
function () {
235 $setup[
'wgLockManagers'] = [ [
236 'name' =>
'fsLockManager',
237 'class' =>
'NullLockManager',
239 'name' =>
'nullLockManager',
240 'class' =>
'NullLockManager',
242 $reset =
function() {
246 $teardown[] = $reset;
249 $setup[
'wgDefaultExternalStore'] =
false;
252 $setup[
'wgAdaptiveMessageCache'] =
true;
255 $setup[
'wgUseDatabaseMessages'] =
true;
256 $reset =
function () {
260 $teardown[] = $reset;
263 $setup[
'wgSVGConverter'] =
'null';
264 $setup[
'wgSVGConverters'] = [
'null' =>
'echo "1">$output' ];
267 Hooks::register(
'ParserGetVariableValueTs',
'ParserTestRunner::getFakeTimestamp' );
268 $teardown[] =
function () {
279 $setup[
'wgLocalInterwikis'] = [
'local',
'mi' ];
280 $reset =
function () {
284 $teardown[] = $reset;
287 MediaWikiServices::getInstance()->disableService(
'MediaHandlerFactory' );
288 MediaWikiServices::getInstance()->redefineService(
289 'MediaHandlerFactory',
294 $teardown[] =
function () {
295 MediaWikiServices::getInstance()->resetServiceForTesting(
'MediaHandlerFactory' );
306 $teardown[] =
function ()
use ( $savedCache ) {
320 $setup[
'wgExtraNamespaces'] = [
321 100 =>
'MemoryAlpha',
322 101 =>
'MemoryAlpha_talk'
326 $reset =
function () {
328 $GLOBALS[
'wgContLang']->resetNamespaces();
331 $teardown[] = $reset;
339 if ( $this->uploadDir ) {
340 if ( $this->fileBackendName ) {
341 throw new MWException(
'You cannot specify both use-filebackend and upload-dir' );
344 'name' =>
'local-backend',
346 'basePath' => $this->uploadDir,
349 } elseif ( $this->fileBackendName ) {
353 foreach ( $wgFileBackends
as $conf ) {
354 if ( $conf[
'name'] ===
$name ) {
358 if ( $useConfig ===
false ) {
359 throw new MWException(
"Unable to find file backend \"$name\"" );
361 $useConfig[
'name'] =
'local-backend';
362 unset( $useConfig[
'lockManager'] );
363 unset( $useConfig[
'fileJournal'] );
364 $class = $useConfig[
'class'];
365 $backend =
new $class( $useConfig );
367 # Replace with a mock. We do not care about generating real
368 # files on the filesystem, just need to expose the file
371 'name' =>
'local-backend',
378 'class' =>
'MockLocalRepo',
380 'url' =>
'http://example.com/images',
382 'transformVia404' =>
false,
383 'backend' => $backend
405 if ( is_int(
$name ) ) {
412 return function ()
use ( $saved ) {
430 return new ScopedCallback(
function()
use ( $teardown, $nextTeardown ) {
432 $teardown = array_reverse( $teardown );
435 if ( $nextTeardown ) {
436 ScopedCallback::consume( $nextTeardown );
449 if ( $this->setupDone[$funcName] ) {
450 throw new MWException(
"$funcName is already done" );
452 $this->setupDone[$funcName] =
true;
453 return function ()
use ( $funcName ) {
454 $this->setupDone[$funcName] =
false;
463 if ( !$this->setupDone[$funcName]
464 && ( $funcName === null || !$this->setupDone[$funcName2] )
466 throw new MWException(
"$funcName must be called before calling " .
478 return isset( $this->setupDone[$funcName] ) ? $this->setupDone[$funcName] :
false;
493 # Hack: insert a few Wikipedia in-project interwiki prefixes,
494 # for testing inter-language links
495 Hooks::register(
'InterwikiLoadPrefix',
function ( $prefix, &$iwData ) {
496 static $testInterwikis = [
498 'iw_url' =>
'http://doesnt.matter.org/$1',
503 'iw_url' =>
'http://en.wikipedia.org/wiki/$1',
508 'iw_url' =>
'http://www.usemod.com/cgi-bin/mb.pl?$1',
513 'iw_url' =>
'http://www.memory-alpha.org/en/index.php/$1',
518 'iw_url' =>
'http://zh.wikipedia.org/wiki/$1',
523 'iw_url' =>
'http://es.wikipedia.org/wiki/$1',
528 'iw_url' =>
'http://fr.wikipedia.org/wiki/$1',
533 'iw_url' =>
'http://ru.wikipedia.org/wiki/$1',
538 'iw_url' =>
'http://mi.wikipedia.org/wiki/$1',
543 'iw_url' =>
'http://wikisource.org/wiki/$1',
548 if ( array_key_exists( $prefix, $testInterwikis ) ) {
549 $iwData = $testInterwikis[$prefix];
567 $services = MediaWikiServices::getInstance();
568 $services->resetServiceForTesting(
'TitleFormatter' );
569 $services->resetServiceForTesting(
'TitleParser' );
570 $services->resetServiceForTesting(
'_MediaWikiTitleCodec' );
571 $services->resetServiceForTesting(
'LinkRenderer' );
572 $services->resetServiceForTesting(
'LinkRendererFactory' );
582 if ( substr(
$s, -1 ) ===
"\n" ) {
583 return substr(
$s, 0, -1 );
609 $this->recorder->start();
613 foreach ( $filenames
as $filename ) {
615 'runDisabled' => $this->runDisabled,
616 'runParsoid' => $this->runParsoid,
617 'regex' => $this->regex ] );
620 if ( !$testFileInfo[
'tests'] ) {
624 $this->recorder->startSuite( $filename );
625 $ok = $this->
runTests( $testFileInfo ) && $ok;
626 $this->recorder->endSuite( $filename );
629 $this->recorder->report();
631 $this->recorder->warning( $e->getMessage() );
633 $this->recorder->end();
635 ScopedCallback::consume( $teardownGuard );
645 foreach ( $requirements
as $requirement ) {
646 switch ( $requirement[
'type'] ) {
653 case 'transparentHook':
677 if ( !$testFileInfo[
'tests'] ) {
683 foreach ( $testFileInfo[
'tests']
as $test ) {
684 $this->recorder->startTest( $test );
685 $this->recorder->skipped( $test,
'required extension not enabled' );
694 foreach ( $testFileInfo[
'tests']
as $test ) {
695 $this->recorder->startTest( $test );
699 $ok = $ok &&
$result->isSuccess();
700 $this->recorder->record( $test,
$result );
716 $class = $wgParserConf[
'class'];
717 $parser =
new $class( [
'preprocessorClass' => $preprocessor ] + $wgParserConf );
741 wfDebug( __METHOD__.
": running {$test['desc']}" );
749 if ( isset( $opts[
'tidy'] ) ) {
750 if ( !$this->tidySupport->isEnabled() ) {
751 $this->recorder->skipped( $test,
'tidy extension is not installed' );
758 if ( isset( $opts[
'title'] ) ) {
759 $titleText = $opts[
'title'];
761 $titleText =
'Parser test';
764 $local = isset( $opts[
'local'] );
765 $preprocessor = isset( $opts[
'preprocessor'] ) ? $opts[
'preprocessor'] : null;
769 if ( isset( $opts[
'pst'] ) ) {
771 } elseif ( isset( $opts[
'msg'] ) ) {
773 } elseif ( isset( $opts[
'section'] ) ) {
776 } elseif ( isset( $opts[
'replace'] ) ) {
778 $replace = $opts[
'replace'][1];
780 } elseif ( isset( $opts[
'comment'] ) ) {
782 } elseif ( isset( $opts[
'preload'] ) ) {
788 if ( isset( $opts[
'tidy'] ) ) {
789 $out = preg_replace(
'/\s+$/',
'',
$out );
792 if ( isset( $opts[
'showtitle'] ) ) {
797 $out =
"$title\n$out";
800 if ( isset( $opts[
'showindicators'] ) ) {
803 $indicators .=
"$id=$content\n";
808 if ( isset( $opts[
'ill'] ) ) {
810 } elseif ( isset( $opts[
'cat'] ) ) {
816 $out .=
"cat=$name sort=$sortkey";
821 ScopedCallback::consume( $teardownGuard );
823 $expected = $test[
'result'];
824 if ( count( $this->normalizationFunctions ) ) {
826 $test[
'expected'], $this->normalizationFunctions );
842 $key = strtolower( $key );
844 if ( isset( $opts[$key] ) ) {
867 (?<qstr> # Quoted string
869 (?:[^\\\\"] | \\\\.)*
875 [^"{}] | # Not a quoted string or object, or
876 (?&qstr) | # A quoted string, or
877 (?&json) # A json object (recursively)
883 (?&qstr) # Quoted val
891 (?&json) # JSON object
895 $regex =
'/' . $defs .
'\b
911 $valueregex =
'/' . $defs .
'(?&value)/x';
913 if ( preg_match_all(
$regex, $instring,
$matches, PREG_SET_ORDER ) ) {
915 $key = strtolower( $bits[
'k'] );
916 if ( !isset( $bits[
'v'] ) ) {
919 preg_match_all( $valueregex, $bits[
'v'], $vmatches );
920 $opts[$key] = array_map( [ $this,
'cleanupOption' ], $vmatches[0] );
921 if ( count( $opts[$key] ) == 1 ) {
922 $opts[$key] = $opts[$key][0];
931 if ( substr( $opt, 0, 1 ) ==
'"' ) {
932 return stripcslashes( substr( $opt, 1, -1 ) );
935 if ( substr( $opt, 0, 2 ) ==
'[[' ) {
936 return substr( $opt, 2, -2 );
939 if ( substr( $opt, 0, 1 ) ==
'{' ) {
961 $config = $test[
'config'];
965 self::getOptionValue(
'language', $opts,
'en' );
967 self::getOptionValue(
'variant', $opts,
false );
969 self::getOptionValue(
'wgMaxTocLevel', $opts, 999 );
970 $linkHolderBatchSize =
971 self::getOptionValue(
'wgLinkHolderBatchSize', $opts, 1000 );
974 'wgEnableUploads' => self::getOptionValue(
'wgEnableUploads', $opts,
true ),
975 'wgLanguageCode' => $langCode,
976 'wgRawHtml' => self::getOptionValue(
'wgRawHtml', $opts,
false ),
977 'wgNamespacesWithSubpages' => [ 0 => isset( $opts[
'subpage'] ) ],
978 'wgMaxTocLevel' => $maxtoclevel,
979 'wgAllowExternalImages' => self::getOptionValue(
'wgAllowExternalImages', $opts,
true ),
980 'wgThumbLimits' => [ self::getOptionValue(
'thumbsize', $opts, 180 ) ],
981 'wgDefaultLanguageVariant' => $variant,
982 'wgLinkHolderBatchSize' => $linkHolderBatchSize,
985 'wgEnableMagicLinks' => self::getOptionValue(
'wgEnableMagicLinks', $opts, [] )
986 + [
'ISBN' =>
true,
'PMID' =>
true,
'RFC' =>
true ],
990 $configLines = explode(
"\n", $config );
992 foreach ( $configLines
as $line ) {
993 list( $var,
$value ) = explode(
'=', $line, 2 );
994 $setup[$var] = eval(
"return $value;" );
999 Hooks::run(
'ParserTestGlobals', [ &$setup ] );
1002 if ( isset( $opts[
'tidy'] ) ) {
1004 if ( $this->tidyDriver === null ) {
1005 $this->tidyDriver =
MWTidy::factory( $this->tidySupport->getConfig() );
1012 $teardown[] =
function () {
1018 $setup[
'wgContLang'] =
$lang;
1019 $reset =
function () {
1024 $teardown[] = $reset;
1028 $user->setOption(
'language', $langCode );
1029 $setup[
'wgLang'] =
$lang;
1032 $user->setOption(
'thumbsize', 0 );
1034 $setup[
'wgUser'] =
$user;
1057 $tables = [
'user',
'user_properties',
'user_former_groups',
'page',
'page_restrictions',
1058 'protected_titles',
'revision',
'text',
'pagelinks',
'imagelinks',
1059 'categorylinks',
'templatelinks',
'externallinks',
'langlinks',
'iwlinks',
1060 'site_stats',
'ipblocks',
'image',
'oldimage',
1061 'recentchanges',
'watchlist',
'interwiki',
'logging',
'log_search',
1062 'querycache',
'objectcache',
'job',
'l10n_cache',
'redirect',
'querycachetwo',
1063 'archive',
'user_groups',
'page_props',
'category'
1066 if ( in_array( $this->db->getType(), [
'mysql',
'sqlite',
'oracle' ] ) ) {
1067 array_push(
$tables,
'searchindex' );
1080 $this->setupDone[
'setDatabase'] =
true;
1104 $dbType = $this->db->getType();
1106 if ( $dbType ==
'oracle' ) {
1111 if ( in_array( $wgDBprefix, $suspiciousPrefixes ) ) {
1112 throw new MWException(
"\$wgDBprefix=$wgDBprefix suggests DB setup is already done" );
1119 # CREATE TEMPORARY TABLE breaks if there is more than one server
1120 if (
wfGetLB()->getServerCount() != 1 ) {
1121 $this->useTemporaryTables =
false;
1124 $temporary = $this->useTemporaryTables || $dbType ==
'postgres';
1125 $prefix = $dbType !=
'oracle' ?
'parsertest_' :
'pt_';
1128 $this->dbClone->useTemporaryTables( $temporary );
1129 $this->dbClone->cloneTableStructure();
1131 if ( $dbType ==
'oracle' ) {
1132 $this->db->query(
'BEGIN FILL_WIKI_INFO; END;' );
1133 # Insert 0 user to prevent FK violations
1136 $this->db->insert(
'user', [
1138 'user_name' =>
'Anonymous' ] );
1141 $teardown[] =
function () {
1146 $reset =
function () {
1153 $teardown[] = $reset;
1181 # note that the size/width/height/bits/etc of the file
1182 # are actually set by inspecting the file itself; the arguments
1183 # to recordUpload2 have no effect. That said, we try to make things
1184 # match up so it is less confusing to readers of the code & tests.
1185 $image->recordUpload2(
'',
'Upload of some lame file',
'Some lame file', [
1191 'mime' =>
'image/jpeg',
1193 'sha1' => Wikimedia\base_convert(
'1', 16, 36, 31 ),
1194 'fileExists' =>
true
1195 ], $this->db->timestamp(
'20010115123500' ),
$user );
1198 # again, note that size/width/height below are ignored; see above.
1199 $image->recordUpload2(
'',
'Upload of some lame thumbnail',
'Some lame thumbnail', [
1205 'mime' =>
'image/png',
1207 'sha1' => Wikimedia\base_convert(
'2', 16, 36, 31 ),
1208 'fileExists' =>
true
1209 ], $this->db->timestamp(
'20130225203040' ),
$user );
1212 $image->recordUpload2(
'',
'Upload of some lame SVG',
'Some lame SVG', [
1218 'mime' =>
'image/svg+xml',
1220 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1221 'fileExists' =>
true
1222 ], $this->db->timestamp(
'20010115123500' ),
$user );
1224 # This image will be blacklisted in [[MediaWiki:Bad image list]]
1226 $image->recordUpload2(
'',
'zomgnotcensored',
'Borderline image', [
1232 'mime' =>
'image/jpeg',
1234 'sha1' => Wikimedia\base_convert(
'3', 16, 36, 31 ),
1235 'fileExists' =>
true
1236 ], $this->db->timestamp(
'20010115123500' ),
$user );
1239 $image->recordUpload2(
'',
'A pretty movie',
'Will it play', [
1245 'mime' =>
'application/ogg',
1247 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1248 'fileExists' =>
true
1249 ], $this->db->timestamp(
'20010115123500' ),
$user );
1252 $image->recordUpload2(
'',
'An awesome hitsong',
'Will it play', [
1258 'mime' =>
'application/ogg',
1260 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1261 'fileExists' =>
true
1262 ], $this->db->timestamp(
'20010115123500' ),
$user );
1266 $image->recordUpload2(
'',
'Upload a DjVu',
'A DjVu', [
1272 'mime' =>
'image/vnd.djvu',
1273 'metadata' =>
'<?xml version="1.0" ?>
1274 <!DOCTYPE DjVuXML PUBLIC "-//W3C//DTD DjVuXML 1.1//EN" "pubtext/DjVuXML-s.dtd">
1277 <BODY><OBJECT height="3508" width="2480">
1278 <PARAM name="DPI" value="300" />
1279 <PARAM name="GAMMA" value="2.2" />
1281 <OBJECT height="3508" width="2480">
1282 <PARAM name="DPI" value="300" />
1283 <PARAM name="GAMMA" value="2.2" />
1285 <OBJECT height="3508" width="2480">
1286 <PARAM name="DPI" value="300" />
1287 <PARAM name="GAMMA" value="2.2" />
1289 <OBJECT height="3508" width="2480">
1290 <PARAM name="DPI" value="300" />
1291 <PARAM name="GAMMA" value="2.2" />
1293 <OBJECT height="3508" width="2480">
1294 <PARAM name="DPI" value="300" />
1295 <PARAM name="GAMMA" value="2.2" />
1299 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1300 'fileExists' =>
true
1301 ], $this->db->timestamp(
'20010115123600' ),
$user );
1315 $this->dbClone->destroy();
1316 $this->databaseSetupDone =
false;
1318 if ( $this->useTemporaryTables ) {
1319 if ( $this->db->getType() ==
'sqlite' ) {
1320 # Under SQLite the searchindex table is virtual and need
1321 # to be explicitly destroyed. See bug 29912
1322 # See also MediaWikiTestCase::destroyDB()
1323 wfDebug( __METHOD__ .
" explicitly destroying sqlite virtual table parsertest_searchindex\n" );
1324 $this->db->query(
"DROP TABLE `parsertest_searchindex`" );
1326 # Don't need to do anything
1333 if ( $this->db->getType() ==
'oracle' ) {
1334 $this->db->query(
"DROP TABLE pt_$table DROP CONSTRAINTS" );
1336 $this->db->query(
"DROP TABLE `parsertest_$table`" );
1340 if ( $this->db->getType() ==
'oracle' ) {
1341 $this->db->query(
'BEGIN FILL_WIKI_INFO; END;' );
1354 $base = $repo->getZonePath(
'public' );
1355 $backend = $repo->getBackend();
1356 $backend->prepare( [
'dir' =>
"$base/3/3a" ] );
1358 'src' =>
"$IP/tests/phpunit/data/parser/headbg.jpg",
1359 'dst' =>
"$base/3/3a/Foobar.jpg"
1361 $backend->prepare( [
'dir' =>
"$base/e/ea" ] );
1363 'src' =>
"$IP/tests/phpunit/data/parser/wiki.png",
1364 'dst' =>
"$base/e/ea/Thumb.png"
1366 $backend->prepare( [
'dir' =>
"$base/0/09" ] );
1368 'src' =>
"$IP/tests/phpunit/data/parser/headbg.jpg",
1369 'dst' =>
"$base/0/09/Bad.jpg"
1371 $backend->prepare( [
'dir' =>
"$base/5/5f" ] );
1373 'src' =>
"$IP/tests/phpunit/data/parser/LoremIpsum.djvu",
1374 'dst' =>
"$base/5/5f/LoremIpsum.djvu"
1378 $data =
'<?xml version="1.0" encoding="utf-8"?>' .
1379 '<svg xmlns="http://www.w3.org/2000/svg"' .
1380 ' version="1.1" width="240" height="180"/>';
1382 $backend->prepare( [
'dir' =>
"$base/f/ff" ] );
1383 $backend->quickCreate( [
1384 'content' => $data,
'dst' =>
"$base/f/ff/Foobar.svg"
1387 return function ()
use ( $backend ) {
1400 if ( $this->keepUploads ) {
1405 $public = $repo->getZonePath(
'public' );
1409 "$public/3/3a/Foobar.jpg",
1410 "$public/e/ea/Thumb.png",
1411 "$public/0/09/Bad.jpg",
1412 "$public/5/5f/LoremIpsum.djvu",
1413 "$public/f/ff/Foobar.svg",
1414 "$public/0/00/Video.ogv",
1415 "$public/4/41/Audio.oga",
1428 $backend->delete( [
'src' => $file ], [
'force' => 1 ] );
1435 if ( !$backend->clean( [
'dir' => $tmp ] )->isOK() ) {
1455 if ( $wgContLang->getCode() !==
'en' ) {
1456 $setup[
'wgLanguageCode'] =
'en';
1464 $setup[
'wgCapitalLinks'] =
true;
1468 foreach ( $articles
as $info ) {
1469 $this->
addArticle( $info[
'name'], $info[
'text'], $info[
'file'], $info[
'line'] );
1489 $text = self::chomp( $text );
1493 wfDebug( __METHOD__ .
": adding $name" );
1495 if ( is_null(
$title ) ) {
1496 throw new MWException(
"invalid title '$name' at $file:$line\n" );
1500 $page->loadPageData(
'fromdbmaster' );
1502 if (
$page->exists() ) {
1503 throw new MWException(
"duplicate article '$name' at $file:$line\n" );
1526 $wgParser->firstCallInit();
1527 if ( isset( $wgParser->mTagHooks[
$name] ) ) {
1530 $this->recorder->warning(
" This test suite requires the '$name' hook " .
1531 "extension, skipping." );
1545 $wgParser->firstCallInit();
1547 if ( isset( $wgParser->mFunctionHooks[
$name] ) ) {
1550 $this->recorder->warning(
" This test suite requires the '$name' function " .
1551 "hook extension, skipping." );
1565 $wgParser->firstCallInit();
1567 if ( isset( $wgParser->mTransparentTagHooks[
$name] ) ) {
1570 $this->recorder->warning(
" This test suite requires the '$name' transparent " .
1571 "hook extension, skipping.\n" );
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
static getMainWANInstance()
Get the main WAN cache object.
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
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
Database error base class.
runTest($test)
Run a given wikitext input through a freshly-constructed wiki parser, and compare the output against ...
addArticle($name, $text, $file, $line)
Insert a temporary test article.
warning($message)
Show a warning to the user.
Class simulating a backend store.
static factory(array $config)
Create a new Tidy driver object from configuration.
static getFakeTimestamp(&$parser, &$ts)
The ParserGetVariableValueTs hook, used to make sure time-related parser functions give a persistent ...
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
requireTransparentHook($name)
Check if a transparent tag hook is installed.
if(!isset($args[0])) $lang
static destroyInstance()
Destroy the singleton instance.
$wgFileBackends
File backend structure configuration.
requireHook($name)
Check if a hook is installed.
static destroySingleton()
Destroy the singleton instance, so that a new one will be created next time singleton() is called...
setupUploadBackend()
Upload test files to the backend created by createRepoGroup().
teardownUploadBackend()
Remove the dummy uploads directory.
resetTitleServices()
Reset the Title-related services that need resetting for each test.
static chomp($s)
Remove last character if it is a newline utility.
teardownDatabase()
Helper for database teardown, called from the teardown closure.
parseOptions($instring)
Given the options string, return an associative array of options.
static normalize($text, $funcs)
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 MediaWikiServices
string null $fileBackendName
The name of the file backend to use, or null to use MockFileBackend.
static createNew($name, $params=[])
Add a user to the database, return the user object.
createRepoGroup()
Create a RepoGroup object appropriate for the current configuration.
staticSetup($nextTeardown=null)
Do any setup which can be done once for all tests, independent of test options, except for database s...
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
when a variable name is used in a it is silently declared as a new local masking the global
setDatabase(IDatabase $db)
wfLocalFile($title)
Get an object referring to a locally registered file.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
executeSetupSnippets($setup)
Execute an array in which elements with integer keys are taken to be callable objects, and other elements are taken to be global variable set operations, with the key giving the variable name and the value giving the new global variable value.
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:Associative array mapping language codes to prefixed links of the form"language:title".&$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
Database $db
Our connection to the database.
static BagOStuff[] $instances
Map of (id => BagOStuff)
static destroySingleton()
Destroy the current singleton instance.
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
perTestSetup($test, $nextTeardown=null)
Do any required setup which is dependent on test options.
createTeardownObject($teardown, $nextTeardown)
Take a setup array in the same format as the one given to executeSetupSnippets(), and return a Scoped...
static register($name, $callback)
Attach an event handler to a given hook.
wfGetLB($wiki=false)
Get a load balancer object.
wfTempDir()
Tries to get the system directory for temporary files.
static getMain()
Static methods.
static singleton()
Get an instance of this class.
static clear($name)
Clears hooks registered via Hooks::register().
TidyDriverBase $tidyDriver
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static singleton()
Get a RepoGroup instance.
meetsRequirements($requirements)
Determine whether the current parser has the hooks registered in it that are required by a file read ...
static clearCache()
Clear the self::$mObjects variable For use in parser tests.
static destroySingletons()
Destroy the singleton instances.
setupDatabase($nextTeardown=null)
Set up temporary DB tables.
runTestsFromFiles($filenames)
Run a series of tests listed in the given text files.
isSetupDone($funcName)
Determine whether a particular setup function has been run.
getParser($preprocessor=null)
Get a Parser object.
runTests($testFileInfo)
Run the tests from a single file.
namespace and then decline to actually register it file or subcat img or subcat $title
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
__construct(TestRecorder $recorder, $options=[])
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.
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 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
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...
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
string $regex
A complete regex for filtering tests.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
Initialize and detect the tidy support.
Interface to record parser test results.
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
array $normalizationFunctions
A list of normalization functions to apply to the expected and actual output.
setupInterwikis()
Insert hardcoded interwiki in the lookup table.
markSetupDone($funcName)
Set a setupDone flag to indicate that setup has been done, and return the teardown closure...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
$wgDBprefix
Table name prefix.
checkSetupDone($funcName, $funcName2=null)
Ensure a given setup stage has been done, throw an exception if it has not.
Prioritized list of file repositories.
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
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
setupUploads($nextTeardown=null)
Add data about uploads to the new test DB, and set up the upload directory.
$wgObjectCaches
Advanced object cache configuration.
requireFunctionHook($name)
Check if a function hook is installed.
appendNamespaceSetup(&$setup, &$teardown)
static setSingleton($instance)
Set the singleton instance to a given object Used by extensions which hook into the Repo chain...
static getOptionValue($key, $opts, $default)
Use a regex to find out the value of an option.
addArticles($articles)
Add articles to the test DB.
Class for a file system (FS) based file backend.
listTables()
List of temporary tables to create, without prefix.
static factory($code)
Get a cached or new language object for a given language code.
deleteFiles($files)
Delete the specified files and their parent directories.
Represent the result of a parser test.
static read($file, array $options=[])
static getCanonicalNamespaces($rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
CloneDatabase $dbClone
Database clone helper.
string null $uploadDir
The upload directory, or null to not set up an upload directory.
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
wfGetCaller($level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
static setInstance($instance)
Set the driver to be used.
static singleton()
Get the signleton instance of this class.
Basic database interface for live and lazy-loaded relation database handles.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
static parentStoragePath($storagePath)
Get the parent storage directory of a storage path.
Allows to change the fields on the form that will be generated $name