100 # Only colorize output if stdout is a terminal.
106 $this->
color =
false;
119 $this->showDiffs = !isset(
$options[
'quick'] );
120 $this->showProgress = !isset(
$options[
'quiet'] );
124 || isset(
$options[
'compare'] ) ) );
126 $this->showOutput = isset(
$options[
'show-output'] );
127 $this->useDwdiff = isset(
$options[
'dwdiff'] );
128 $this->markWhitespace = isset(
$options[
'mark-ws'] );
131 foreach ( explode(
',',
$options[
'norm'] )
as $func ) {
132 if ( in_array( $func, [
'removeTbody',
'trimWhitespace' ] ) ) {
133 $this->normalizationFunctions[] = $func;
135 echo
"Warning: unknown normalization option \"$func\"\n";
140 if ( isset(
$options[
'filter'] ) ) {
145 if ( isset(
$options[
'record'] ) ) {
146 echo
"Warning: --record cannot be used with --regex, disabling --record\n";
156 $this->keepUploads = isset(
$options[
'keep-uploads'] );
158 if ( $this->keepUploads ) {
159 $this->uploadDir =
wfTempDir() .
'/mwParser-images';
161 $this->uploadDir =
wfTempDir() .
"/mwParser-" . mt_rand() .
"-images";
165 $this->fuzzSeed = intval(
$options[
'seed'] ) - 1;
168 $this->runDisabled = isset(
$options[
'run-disabled'] );
169 $this->runParsoid = isset(
$options[
'run-parsoid'] );
173 if ( !$this->tidySupport->isEnabled() ) {
174 echo
"Warning: tidy is not installed, skipping some tests\n";
177 if ( !extension_loaded(
'gd' ) ) {
178 echo
"Warning: GD extension is not present, thumbnailing tests will probably fail\n";
182 $this->functionHooks = [];
183 $this->transparentHooks = [];
197 $wgScript =
'/index.php';
198 $wgStylePath =
'/skins';
199 $wgResourceBasePath =
'';
200 $wgExtensionAssetsPath =
'/extensions';
201 $wgArticlePath =
'/wiki/$1';
202 $wgThumbnailScriptPath =
false;
203 $wgLockManagers = [ [
204 'name' =>
'fsLockManager',
205 'class' =>
'FSLockManager',
206 'lockDirectory' => $this->uploadDir .
'/lockdir',
208 'name' =>
'nullLockManager',
209 'class' =>
'NullLockManager',
212 'class' =>
'LocalRepo',
214 'url' =>
'http://example.com/images',
216 'transformVia404' =>
false,
218 'name' =>
'local-backend',
220 'containerPaths' => [
221 'local-public' => $this->uploadDir .
'/public',
222 'local-thumb' => $this->uploadDir .
'/thumb',
223 'local-temp' => $this->uploadDir .
'/temp',
224 'local-deleted' => $this->uploadDir .
'/deleted',
229 $wgNamespaceAliases[
'Image'] =
NS_FILE;
231 # add a namespace shadowing a interwiki link, to test
232 # proper precedence when resolving links. (bug 51680)
233 $wgExtraNamespaces[100] =
'MemoryAlpha';
234 $wgExtraNamespaces[101] =
'MemoryAlpha talk';
237 if ( $wgMainCacheType ===
CACHE_DB ) {
240 if ( $wgMessageCacheType ===
CACHE_DB ) {
243 if ( $wgParserCacheType ===
CACHE_DB ) {
257 $wgRequest =
$context->getRequest();
258 $wgParser =
new StubObject(
'wgParser', $wgParserConf[
'class'], [ $wgParserConf ] );
260 if ( $wgStyleDirectory ===
false ) {
261 $wgStyleDirectory =
"$IP/skins";
264 self::setupInterwikis();
265 $wgLocalInterwikis = [
'local',
'mi' ];
268 array_push( $wgExtraInterlanguageLinkPrefixes,
'mul' );
285 # Hack: insert a few Wikipedia in-project interwiki prefixes,
286 # for testing inter-language links
287 Hooks::register(
'InterwikiLoadPrefix',
function ( $prefix, &$iwData ) {
288 static $testInterwikis = [
290 'iw_url' =>
'http://doesnt.matter.org/$1',
295 'iw_url' =>
'http://en.wikipedia.org/wiki/$1',
300 'iw_url' =>
'http://www.usemod.com/cgi-bin/mb.pl?$1',
305 'iw_url' =>
'http://www.memory-alpha.org/en/index.php/$1',
310 'iw_url' =>
'http://zh.wikipedia.org/wiki/$1',
315 'iw_url' =>
'http://es.wikipedia.org/wiki/$1',
320 'iw_url' =>
'http://fr.wikipedia.org/wiki/$1',
325 'iw_url' =>
'http://ru.wikipedia.org/wiki/$1',
330 'iw_url' =>
'http://mi.wikipedia.org/wiki/$1',
335 'iw_url' =>
'http://wikisource.org/wiki/$1',
340 if ( array_key_exists( $prefix, $testInterwikis ) ) {
341 $iwData = $testInterwikis[$prefix];
361 $services = MediaWikiServices::getInstance();
362 $services->resetServiceForTesting(
'TitleFormatter' );
363 $services->resetServiceForTesting(
'TitleParser' );
364 $services->resetServiceForTesting(
'_MediaWikiTitleCodec' );
365 $services->resetServiceForTesting(
'LinkRenderer' );
366 $services->resetServiceForTesting(
'LinkRendererFactory' );
370 if ( isset(
$options[
'record'] ) ) {
372 $this->recorder->version = isset(
$options[
'setversion'] ) ?
374 } elseif ( isset(
$options[
'compare'] ) ) {
388 if ( substr(
$s, -1 ) ===
"\n" ) {
389 return substr(
$s, 0, -1 );
403 $dictSize = strlen( $dict );
404 $logMaxLength = log( $this->maxFuzzTestLength );
406 ini_set(
'memory_limit', $this->memoryLimit * 1048576 );
416 mt_srand( ++$this->fuzzSeed );
417 $totalLength = mt_rand( 1, $this->maxFuzzTestLength );
420 while ( strlen( $input ) < $totalLength ) {
421 $logHairLength = mt_rand( 0, 1000000 ) / 1000000 * $logMaxLength;
422 $hairLength = min( intval( exp( $logHairLength ) ), $dictSize );
423 $offset = mt_rand( 0, $dictSize - $hairLength );
424 $input .= substr( $dict, $offset, $hairLength );
434 }
catch ( Exception $exception ) {
439 echo
"Test failed with seed {$this->fuzzSeed}\n";
441 printf(
"string(%d) \"%s\"\n\n", strlen( $input ), $input );
451 if ( $numTotal % 100 == 0 ) {
452 $usage = intval( memory_get_usage(
true ) / $this->memoryLimit / 1048576 * 100 );
453 echo
"{$this->fuzzSeed}: $numSuccess/$numTotal (mem: $usage%)\n";
455 echo
"Out of memory:\n";
458 foreach ( $memStats
as $name => $usage ) {
459 echo
"$name: $usage\n";
475 foreach ( $filenames
as $filename ) {
476 $contents = file_get_contents( $filename );
478 '/!!\s*(input|wikitext)\n(.*?)\n!!\s*(result|html|html\/\*|html\/php)/s',
484 $dict .= $match .
"\n";
502 $classes = get_declared_classes();
504 foreach ( $classes
as $class ) {
505 $rc =
new ReflectionClass( $class );
506 $props = $rc->getStaticProperties();
507 $memStats[$class] = strlen(
serialize( $props ) );
508 $methods = $rc->getMethods();
510 foreach ( $methods
as $method ) {
511 $memStats[$class] += strlen(
serialize( $method->getStaticVariables() ) );
515 $functions = get_defined_functions();
517 foreach ( $functions[
'user']
as $function ) {
518 $rf =
new ReflectionFunction( $function );
519 $memStats[
"$function()"] = strlen(
serialize( $rf->getStaticVariables() ) );
550 $this->recorder->start();
555 foreach ( $filenames
as $filename ) {
556 echo
"Running parser tests from: $filename\n";
558 $ok = $this->
runTests( $tests ) && $ok;
562 $this->recorder->report();
564 echo $e->getMessage();
566 $this->recorder->end();
574 foreach ( $tests
as $t ) {
576 $this->
runTest( $t[
'test'], $t[
'input'], $t[
'result'], $t[
'options'], $t[
'config'] );
578 $this->recorder->record( $t[
'test'], $t[
'subtest'], $result );
581 if ( $this->showProgress ) {
597 $class = $wgParserConf[
'class'];
598 $parser =
new $class( [
'preprocessorClass' => $preprocessor ] + $wgParserConf );
604 foreach ( $this->functionHooks
as $tag => $bits ) {
609 foreach ( $this->transparentHooks
as $tag => $callback ) {
631 if ( $this->showProgress ) {
641 if ( isset( $opts[
'djvu'] ) ) {
642 if ( !$this->djVuSupport->isEnabled() ) {
647 if ( isset( $opts[
'tidy'] ) ) {
648 if ( !$this->tidySupport->isEnabled() ) {
655 if ( isset( $opts[
'title'] ) ) {
656 $titleText = $opts[
'title'];
658 $titleText =
'Parser test';
662 $local = isset( $opts[
'local'] );
663 $preprocessor = isset( $opts[
'preprocessor'] ) ? $opts[
'preprocessor'] : null;
667 if ( isset( $opts[
'pst'] ) ) {
669 } elseif ( isset( $opts[
'msg'] ) ) {
671 } elseif ( isset( $opts[
'section'] ) ) {
674 } elseif ( isset( $opts[
'replace'] ) ) {
676 $replace = $opts[
'replace'][1];
678 } elseif ( isset( $opts[
'comment'] ) ) {
680 } elseif ( isset( $opts[
'preload'] ) ) {
686 if ( isset( $opts[
'tidy'] ) ) {
687 $out = preg_replace(
'/\s+$/',
'',
$out );
690 if ( isset( $opts[
'showtitle'] ) ) {
695 $out =
"$title\n$out";
698 if ( isset( $opts[
'showindicators'] ) ) {
701 $indicators .=
"$id=$content\n";
706 if ( isset( $opts[
'ill'] ) ) {
708 } elseif ( isset( $opts[
'cat'] ) ) {
709 $outputPage =
$context->getOutput();
711 $cats = $outputPage->getCategoryLinks();
713 if ( isset( $cats[
'normal'] ) ) {
714 $out = implode(
' ', $cats[
'normal'] );
723 if ( count( $this->normalizationFunctions ) ) {
729 $testResult->expected =
$result;
730 $testResult->actual =
$out;
758 $key = strtolower( $key );
760 if ( isset( $opts[$key] ) ) {
776 (?<qstr> # Quoted string
778 (?:[^\\\\"] | \\\\.)*
784 [^"{}] | # Not a quoted string or object, or
785 (?&qstr) | # A quoted string, or
786 (?&json) # A json object (recursively)
792 (?&qstr) # Quoted val
800 (?&json) # JSON object
804 $regex =
'/' . $defs .
'\b
820 $valueregex =
'/' . $defs .
'(?&value)/x';
822 if ( preg_match_all(
$regex, $instring,
$matches, PREG_SET_ORDER ) ) {
824 $key = strtolower( $bits[
'k'] );
825 if ( !isset( $bits[
'v'] ) ) {
828 preg_match_all( $valueregex, $bits[
'v'], $vmatches );
829 $opts[$key] = array_map( [ $this,
'cleanupOption' ], $vmatches[0] );
830 if ( count( $opts[$key] ) == 1 ) {
831 $opts[$key] = $opts[$key][0];
840 if ( substr( $opt, 0, 1 ) ==
'"' ) {
841 return stripcslashes( substr( $opt, 1, -1 ) );
844 if ( substr( $opt, 0, 2 ) ==
'[[' ) {
845 return substr( $opt, 2, -2 );
848 if ( substr( $opt, 0, 1 ) ==
'{' ) {
862 # Find out values for some special options.
864 self::getOptionValue(
'language', $opts,
'en' );
866 self::getOptionValue(
'variant', $opts,
false );
868 self::getOptionValue(
'wgMaxTocLevel', $opts, 999 );
869 $linkHolderBatchSize =
870 self::getOptionValue(
'wgLinkHolderBatchSize', $opts, 1000 );
873 'wgServer' =>
'http://example.org',
874 'wgServerName' =>
'example.org',
875 'wgScript' =>
'/index.php',
876 'wgScriptPath' =>
'',
877 'wgArticlePath' =>
'/wiki/$1',
878 'wgActionPaths' => [],
879 'wgLockManagers' => [ [
880 'name' =>
'fsLockManager',
881 'class' =>
'FSLockManager',
882 'lockDirectory' => $this->uploadDir .
'/lockdir',
884 'name' =>
'nullLockManager',
885 'class' =>
'NullLockManager',
887 'wgLocalFileRepo' => [
888 'class' =>
'LocalRepo',
890 'url' =>
'http://example.com/images',
892 'transformVia404' =>
false,
894 'name' =>
'local-backend',
896 'containerPaths' => [
897 'local-public' => $this->uploadDir,
898 'local-thumb' => $this->uploadDir .
'/thumb',
899 'local-temp' => $this->uploadDir .
'/temp',
900 'local-deleted' => $this->uploadDir .
'/delete',
904 'wgEnableUploads' => self::getOptionValue(
'wgEnableUploads', $opts,
true ),
905 'wgUploadNavigationUrl' =>
false,
906 'wgStylePath' =>
'/skins',
907 'wgSitename' =>
'MediaWiki',
908 'wgLanguageCode' =>
$lang,
909 'wgDBprefix' => $this->db->getType() !=
'oracle' ?
'parsertest_' :
'pt_',
910 'wgRawHtml' => self::getOptionValue(
'wgRawHtml', $opts,
false ),
912 'wgContLang' => null,
913 'wgNamespacesWithSubpages' => [ 0 => isset( $opts[
'subpage'] ) ],
914 'wgMaxTocLevel' => $maxtoclevel,
915 'wgCapitalLinks' =>
true,
916 'wgNoFollowLinks' =>
true,
917 'wgNoFollowDomainExceptions' => [
'no-nofollow.org' ],
918 'wgThumbnailScriptPath' =>
false,
919 'wgUseImageResize' =>
true,
920 'wgSVGConverter' =>
'null',
921 'wgSVGConverters' => [
'null' =>
'echo "1">$output' ],
922 'wgLocaltimezone' =>
'UTC',
923 'wgAllowExternalImages' => self::getOptionValue(
'wgAllowExternalImages', $opts,
true ),
924 'wgThumbLimits' => [ self::getOptionValue(
'thumbsize', $opts, 180 ) ],
925 'wgDefaultLanguageVariant' => $variant,
926 'wgVariantArticlePath' =>
false,
927 'wgGroupPermissions' => [
'*' => [
928 'createaccount' =>
true,
931 'createpage' =>
true,
932 'createtalk' =>
true,
934 'wgNamespaceProtection' => [
NS_MEDIAWIKI =>
'editinterface' ],
935 'wgDefaultExternalStore' => [],
936 'wgForeignFileRepos' => [],
937 'wgLinkHolderBatchSize' => $linkHolderBatchSize,
938 'wgExperimentalHtmlIds' =>
false,
939 'wgExternalLinkTarget' =>
false,
941 'wgAdaptiveMessageCache' =>
true,
942 'wgDisableLangConversion' =>
false,
943 'wgDisableTitleConversion' =>
false,
945 'wgUseTidy' =>
false,
946 'wgTidyConfig' => isset( $opts[
'tidy'] ) ? $this->tidySupport->getConfig() : null
950 $configLines = explode(
"\n", $config );
952 foreach ( $configLines
as $line ) {
953 list( $var,
$value ) = explode(
'=', $line, 2 );
955 $settings[$var] = eval(
"return $value;" );
959 $this->savedGlobals = [];
962 Hooks::run(
'ParserTestGlobals', [ &$settings ] );
964 foreach ( $settings
as $var => $val ) {
965 if ( array_key_exists( $var,
$GLOBALS ) ) {
966 $this->savedGlobals[$var] =
$GLOBALS[$var];
983 $context->getUser()->setOption(
'thumbsize', 0 );
987 $wgHooks[
'ParserTestParser'][] =
'ParserTestParserHook::setup';
988 $wgHooks[
'ParserGetVariableValueTs'][] =
'ParserTest::getFakeTimestamp';
994 self::resetTitleServices();
1005 $tables = [
'user',
'user_properties',
'user_former_groups',
'page',
'page_restrictions',
1006 'protected_titles',
'revision',
'text',
'pagelinks',
'imagelinks',
1007 'categorylinks',
'templatelinks',
'externallinks',
'langlinks',
'iwlinks',
1008 'site_stats',
'ipblocks',
'image',
'oldimage',
1009 'recentchanges',
'watchlist',
'interwiki',
'logging',
'log_search',
1010 'querycache',
'objectcache',
'job',
'l10n_cache',
'redirect',
'querycachetwo',
1011 'archive',
'user_groups',
'page_props',
'category'
1014 if ( in_array( $this->db->getType(), [
'mysql',
'sqlite',
'oracle' ] ) ) {
1015 array_push(
$tables,
'searchindex' );
1034 if ( $this->databaseSetupDone ) {
1039 $dbType = $this->db->getType();
1041 if ( $wgDBprefix ===
'parsertest_' || ( $dbType ==
'oracle' && $wgDBprefix ===
'pt_' ) ) {
1042 throw new MWException(
'setupDatabase should be called before setupGlobals' );
1045 $this->databaseSetupDone =
true;
1047 # SqlBagOStuff broke when using temporary tables on r40209 (bug 15892).
1048 # It seems to have been fixed since (r55079?), but regressed at some point before r85701.
1049 # This works around it for now...
1052 # CREATE TEMPORARY TABLE breaks if there is more than one server
1053 if (
wfGetLB()->getServerCount() != 1 ) {
1054 $this->useTemporaryTables =
false;
1057 $temporary = $this->useTemporaryTables || $dbType ==
'postgres';
1058 $prefix = $dbType !=
'oracle' ?
'parsertest_' :
'pt_';
1061 $this->dbClone->useTemporaryTables( $temporary );
1062 $this->dbClone->cloneTableStructure();
1064 if ( $dbType ==
'oracle' ) {
1065 $this->db->query(
'BEGIN FILL_WIKI_INFO; END;' );
1066 # Insert 0 user to prevent FK violations
1069 $this->db->insert(
'user', [
1071 'user_name' =>
'Anonymous' ] );
1074 # Update certain things in site_stats
1075 $this->db->insert(
'site_stats',
1076 [
'ss_row_id' => 1,
'ss_images' => 2,
'ss_good_articles' => 1 ] );
1078 # Reinitialise the LocalisationCache to match the database state
1081 # Clear the message cache
1089 # note that the size/width/height/bits/etc of the file
1090 # are actually set by inspecting the file itself; the arguments
1091 # to recordUpload2 have no effect. That said, we try to make things
1092 # match up so it is less confusing to readers of the code & tests.
1093 $image->recordUpload2(
'',
'Upload of some lame file',
'Some lame file', [
1099 'mime' =>
'image/jpeg',
1101 'sha1' => Wikimedia\base_convert(
'1', 16, 36, 31 ),
1102 'fileExists' =>
true
1103 ], $this->db->timestamp(
'20010115123500' ),
$user );
1106 # again, note that size/width/height below are ignored; see above.
1107 $image->recordUpload2(
'',
'Upload of some lame thumbnail',
'Some lame thumbnail', [
1113 'mime' =>
'image/png',
1115 'sha1' => Wikimedia\base_convert(
'2', 16, 36, 31 ),
1116 'fileExists' =>
true
1117 ], $this->db->timestamp(
'20130225203040' ),
$user );
1120 $image->recordUpload2(
'',
'Upload of some lame SVG',
'Some lame SVG', [
1126 'mime' =>
'image/svg+xml',
1128 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1129 'fileExists' =>
true
1130 ], $this->db->timestamp(
'20010115123500' ),
$user );
1132 # This image will be blacklisted in [[MediaWiki:Bad image list]]
1134 $image->recordUpload2(
'',
'zomgnotcensored',
'Borderline image', [
1140 'mime' =>
'image/jpeg',
1142 'sha1' => Wikimedia\base_convert(
'3', 16, 36, 31 ),
1143 'fileExists' =>
true
1144 ], $this->db->timestamp(
'20010115123500' ),
$user );
1147 $image->recordUpload2(
'',
'A pretty movie',
'Will it play', [
1153 'mime' =>
'application/ogg',
1155 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1156 'fileExists' =>
true
1157 ], $this->db->timestamp(
'20010115123500' ),
$user );
1160 $image->recordUpload2(
'',
'An awesome hitsong',
'Will it play', [
1166 'mime' =>
'application/ogg',
1168 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1169 'fileExists' =>
true
1170 ], $this->db->timestamp(
'20010115123500' ),
$user );
1174 $image->recordUpload2(
'',
'Upload a DjVu',
'A DjVu', [
1180 'mime' =>
'image/vnd.djvu',
1181 'metadata' =>
'<?xml version="1.0" ?>
1182 <!DOCTYPE DjVuXML PUBLIC "-//W3C//DTD DjVuXML 1.1//EN" "pubtext/DjVuXML-s.dtd">
1185 <BODY><OBJECT height="3508" width="2480">
1186 <PARAM name="DPI" value="300" />
1187 <PARAM name="GAMMA" value="2.2" />
1189 <OBJECT height="3508" width="2480">
1190 <PARAM name="DPI" value="300" />
1191 <PARAM name="GAMMA" value="2.2" />
1193 <OBJECT height="3508" width="2480">
1194 <PARAM name="DPI" value="300" />
1195 <PARAM name="GAMMA" value="2.2" />
1197 <OBJECT height="3508" width="2480">
1198 <PARAM name="DPI" value="300" />
1199 <PARAM name="GAMMA" value="2.2" />
1201 <OBJECT height="3508" width="2480">
1202 <PARAM name="DPI" value="300" />
1203 <PARAM name="GAMMA" value="2.2" />
1207 'sha1' => Wikimedia\base_convert(
'', 16, 36, 31 ),
1208 'fileExists' =>
true
1209 ], $this->db->timestamp(
'20010115123600' ),
$user );
1213 if ( !$this->databaseSetupDone ) {
1219 $this->dbClone->destroy();
1220 $this->databaseSetupDone =
false;
1222 if ( $this->useTemporaryTables ) {
1223 if ( $this->db->getType() ==
'sqlite' ) {
1224 # Under SQLite the searchindex table is virtual and need
1225 # to be explicitly destroyed. See bug 29912
1226 # See also MediaWikiTestCase::destroyDB()
1227 wfDebug( __METHOD__ .
" explicitly destroying sqlite virtual table parsertest_searchindex\n" );
1228 $this->db->query(
"DROP TABLE `parsertest_searchindex`" );
1230 # Don't need to do anything
1238 if ( $this->db->getType() ==
'oracle' ) {
1239 $this->db->query(
"DROP TABLE pt_$table DROP CONSTRAINTS" );
1241 $this->db->query(
"DROP TABLE `parsertest_$table`" );
1245 if ( $this->db->getType() ==
'oracle' ) {
1246 $this->db->query(
'BEGIN FILL_WIKI_INFO; END;' );
1262 if ( $this->keepUploads && is_dir(
$dir ) ) {
1267 if ( file_exists(
$dir ) ) {
1268 wfDebug(
"Already exists!\n" );
1273 copy(
"$IP/tests/phpunit/data/parser/headbg.jpg",
"$dir/3/3a/Foobar.jpg" );
1275 copy(
"$IP/tests/phpunit/data/parser/wiki.png",
"$dir/e/ea/Thumb.png" );
1277 copy(
"$IP/tests/phpunit/data/parser/headbg.jpg",
"$dir/0/09/Bad.jpg" );
1279 file_put_contents(
"$dir/f/ff/Foobar.svg",
1280 '<?xml version="1.0" encoding="utf-8"?>' .
1281 '<svg xmlns="http://www.w3.org/2000/svg"' .
1282 ' version="1.1" width="240" height="180"/>' );
1284 copy(
"$IP/tests/phpunit/data/parser/LoremIpsum.djvu",
"$dir/5/5f/LoremIpsum.djvu" );
1286 copy(
"$IP/tests/phpunit/data/parser/320x240.ogv",
"$dir/0/00/Video.ogv" );
1288 copy(
"$IP/tests/phpunit/data/media/say-test.ogg",
"$dir/4/41/Audio.oga" );
1304 foreach ( $this->savedGlobals
as $var => $val ) {
1314 if ( $this->keepUploads ) {
1321 "$dir/3/3a/Foobar.jpg",
1322 "$dir/thumb/3/3a/Foobar.jpg/*.jpg",
1323 "$dir/e/ea/Thumb.png",
1324 "$dir/0/09/Bad.jpg",
1325 "$dir/5/5f/LoremIpsum.djvu",
1326 "$dir/thumb/5/5f/LoremIpsum.djvu/*-LoremIpsum.djvu.jpg",
1327 "$dir/f/ff/Foobar.svg",
1328 "$dir/thumb/f/ff/Foobar.svg/*-Foobar.svg.png",
1329 "$dir/math/f/a/5/fa50b8b616463173474302ca3e63586b.png",
1330 "$dir/0/00/Video.ogv",
1331 "$dir/thumb/0/00/Video.ogv/120px--Video.ogv.jpg",
1332 "$dir/thumb/0/00/Video.ogv/180px--Video.ogv.jpg",
1333 "$dir/thumb/0/00/Video.ogv/240px--Video.ogv.jpg",
1334 "$dir/thumb/0/00/Video.ogv/320px--Video.ogv.jpg",
1335 "$dir/thumb/0/00/Video.ogv/270px--Video.ogv.jpg",
1336 "$dir/thumb/0/00/Video.ogv/320px-seek=2-Video.ogv.jpg",
1337 "$dir/thumb/0/00/Video.ogv/320px-seek=3.3666666666667-Video.ogv.jpg",
1338 "$dir/4/41/Audio.oga",
1346 "$dir/thumb/3/3a/Foobar.jpg",
1353 "$dir/thumb/f/ff/Foobar.svg",
1361 "$dir/thumb/0/00/Video.ogv",
1364 "$dir/thumb/5/5f/LoremIpsum.djvu",
1386 foreach ( glob( $pattern )
as $file ) {
1387 if ( file_exists( $file ) ) {
1400 if ( is_dir( $dir ) ) {
1411 print "Running test $desc... ";
1423 if ( $this->showProgress ) {
1424 print $this->
term->color(
'1;32' ) .
'PASSED' . $this->
term->reset() .
"\n";
1441 if ( !$this->showProgress ) {
1442 # In quiet mode we didn't show the 'Testing' message before the
1443 # test, in case it succeeded. Show it now:
1447 print $this->
term->color(
'31' ) .
'FAILED!' . $this->
term->reset() .
"\n";
1449 if ( $this->showOutput ) {
1450 print "--- Expected ---\n{$testResult->expected}\n";
1451 print "--- Actual ---\n{$testResult->actual}\n";
1454 if ( $this->showDiffs ) {
1455 print $this->
quickDiff( $testResult->expected, $testResult->actual );
1456 if ( !$this->
wellFormed( $testResult->actual ) ) {
1457 print "XML error: $this->mXmlError\n";
1471 if ( $this->showProgress ) {
1472 print $this->
term->color(
'1;33' ) .
'SKIPPED' . $this->
term->reset() .
"\n";
1489 $inFileTail =
'expected', $outFileTail =
'actual'
1491 if ( $this->markWhitespace ) {
1497 $input = strtr( $input, $pairs );
1501 # Windows, or at least the fc utility, is retarded
1503 $prefix =
wfTempDir() .
"{$slash}mwParser-" . mt_rand();
1505 $infile =
"$prefix-$inFileTail";
1508 $outfile =
"$prefix-$outFileTail";
1516 if ( $this->useDwdiff ) {
1517 $shellCommand =
'dwdiff -Pc';
1522 $diff =
wfShellExec(
"$shellCommand $shellInfile $shellOutfile" );
1527 if ( $this->useDwdiff ) {
1541 $file = fopen( $filename,
"wt" );
1542 fwrite( $file, $data .
"\n" );
1554 return preg_replace(
1555 [
'/^(-.*)$/m',
'/^(\+.*)$/m' ],
1556 [ $this->
term->color( 34 ) .
'$1' . $this->
term->reset(),
1557 $this->
term->color( 31 ) .
'$1' . $this->
term->reset() ],
1568 "Reading tests from \"$path\"..." .
1569 $this->
term->reset() .
1586 $wgCapitalLinks =
true;
1588 $text = self::chomp( $text );
1593 if ( is_null(
$title ) ) {
1594 throw new MWException(
"invalid title '$name' at line $line\n" );
1598 $page->loadPageData(
'fromdbmaster' );
1600 if (
$page->exists() ) {
1601 if ( $ignoreDuplicate ==
'ignoreduplicate' ) {
1604 throw new MWException(
"duplicate article '$name' at line $line\n" );
1610 $wgCapitalLinks = $oldCapitalLinks;
1624 $wgParser->firstCallInit();
1626 if ( isset( $wgParser->mTagHooks[
$name] ) ) {
1629 echo
" This test suite requires the '$name' hook extension, skipping.\n";
1647 $wgParser->firstCallInit();
1649 if ( isset( $wgParser->mFunctionHooks[
$name] ) ) {
1650 $this->functionHooks[
$name] = $wgParser->mFunctionHooks[
$name];
1652 echo
" This test suite requires the '$name' function hook extension, skipping.\n";
1670 $wgParser->firstCallInit();
1672 if ( isset( $wgParser->mTransparentTagHooks[
$name] ) ) {
1673 $this->transparentHooks[
$name] = $wgParser->mTransparentTagHooks[
$name];
1675 echo
" This test suite requires the '$name' transparent hook extension, skipping.\n";
1689 $parser = xml_parser_create(
"UTF-8" );
1691 # case folding violates XML standard, turn it off
1692 xml_parser_set_option(
$parser, XML_OPTION_CASE_FOLDING,
false );
1695 $err = xml_error_string( xml_get_error_code(
$parser ) );
1696 $position = xml_get_current_byte_index(
$parser );
1698 $this->mXmlError =
"$err at byte $position:\n$fragment";
1710 $start = max( 0, $position - 10 );
1711 $before = $position - $start;
1713 $this->
term->color( 34 ) .
1714 substr( $text, $start, $before ) .
1715 $this->
term->color( 0 ) .
1716 $this->
term->color( 31 ) .
1717 $this->
term->color( 1 ) .
1718 substr( $text, $position, 1 ) .
1719 $this->
term->color( 0 ) .
1720 $this->
term->color( 34 ) .
1721 substr( $text, $position + 1, 9 ) .
1722 $this->
term->color( 0 ) .
1724 $display = str_replace(
"\n",
' ', $fragment );
1726 str_repeat(
' ', $before ) .
1727 $this->
term->color( 31 ) .
1729 $this->
term->color( 0 );
1731 return "$display\n$caret";
1744 $norm =
new self( $text );
1745 if ( $norm->invalid ) {
1748 foreach ( $funcs
as $func ) {
1751 return $norm->serialize();
1755 $this->doc =
new DOMDocument(
'1.0',
'utf-8' );
1761 MediaWiki\suppressWarnings();
1762 if ( !$this->doc->loadXML(
'<html><body>' . $text .
'</body></html>' ) ) {
1763 $this->invalid =
true;
1765 MediaWiki\restoreWarnings();
1766 $this->xpath =
new DOMXPath( $this->doc );
1767 $this->body = $this->xpath->query(
'//body' )->item( 0 );
1771 foreach ( $this->xpath->query(
'//tbody' )
as $tbody ) {
1772 while ( $tbody->firstChild ) {
1773 $child = $tbody->firstChild;
1774 $tbody->removeChild( $child );
1775 $tbody->parentNode->insertBefore( $child, $tbody );
1777 $tbody->parentNode->removeChild( $tbody );
1793 foreach ( $this->xpath->query(
'//text()' )
as $child ) {
1794 if ( strtolower( $child->parentNode->nodeName ) ===
'pre' ) {
1796 if ( substr_compare( $child->data,
"\n", 0 ) === 0 ) {
1797 $child->data = substr( $child->data, 1 );
1799 if ( substr_compare( $child->data,
"\n", -1 ) === 0 ) {
1800 $child->data = substr( $child->data, 0, -1 );
1804 $child->data = trim( $child->data );
1806 if ( $child->data ===
'' ) {
1807 $child->parentNode->removeChild( $child );
1816 return strtr( $this->doc->saveXML( $this->body ),
1817 [
'<body>' =>
'',
'</body>' =>
'' ] );
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 getLocalisationCache()
Get the LocalisationCache instance.
static getMainWANInstance()
Get the main WAN cache object.
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 and may include noclasses & $html
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.
static clearPendingUpdates()
Clear all pending updates without performing them.
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.
static getFakeTimestamp(&$parser, &$ts)
$wgScript
The URL path to index.php.
Group all the pieces relevant to the context of a request into one instance.
__construct($options=[])
Sets terminal colorization and diff/quick modes depending on OS and command-line options (–color and ...
runTest($desc, $input, $result, $opts, $config)
Run a given wikitext input through a freshly-constructed wiki parser, and compare the output against ...
static addArticle($name, $text, $line= 'unknown', $ignoreDuplicate= '')
Insert a temporary test article.
listTables()
List of temporary tables to create, without prefix.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfMkdirParents($dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
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 to get request data $messageMemc
setupGlobals($opts= '', $config= '')
Set up the global variables for a consistent environment for each test.
teardownUploadDir($dir)
Remove the dummy uploads directory.
$wgThumbnailScriptPath
Give a path here to use thumb.php for thumbnail generation on client request, instead of generating t...
if(!isset($args[0])) $lang
getFuzzInput($filenames)
Get an input dictionary from a set of parser test files.
setupUploadDir()
Create a dummy uploads directory which will contain a couple of files in order to pass existence test...
static destroySingleton()
Destroy the singleton instance, so that a new one will be created next time singleton() is called...
$wgLocalFileRepo
File repository structures.
CloneDatabase $dbClone
Database clone helper.
getParser($preprocessor=null)
Get a Parser object.
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
$wgNamespaceAliases
Namespace aliases.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
$wgHooks['ArticleShow'][]
static hackDocType()
Hack up a private DOCTYPE with HTML's standard entity declarations.
static createNew($name, $params=[])
Add a user to the database, return the user object.
wfShellExec($cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
requireFunctionHook($name)
Steal a callback function from the primary parser, save it for application to our scary parser...
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
static chomp($s)
Remove last character if it is a newline utility.
static destroySingleton()
Destroy the singleton instance.
wfIsWindows()
Check if the operating system is Windows.
static posix_isatty($fd)
Wrapper for posix_isatty() We default as considering stdin a tty (for nice readline methods) but trea...
static newFromUser($user)
Get a ParserOptions object from a given user.
wfLocalFile($title)
Get an object referring to a locally registered file.
which are not or by specifying more than one search term(only pages containing all of the search terms will appear in the result).</td >< td >
wfGetMessageCacheStorage()
Get the cache object used by the message cache.
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.
wfGetParserCacheStorage()
Get the cache object used by the parser cache.
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 $wgLang
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
static deleteDirs($dirs)
Delete the specified directories, if they exist.
showSuccess(ParserTestResult $testResult)
Print a happy success message.
static BagOStuff[] $instances
Map of (id => BagOStuff)
static destroySingleton()
Destroy the current singleton instance.
$wgExtraInterlanguageLinkPrefixes
List of additional interwiki prefixes that should be treated as interlanguage links (i...
static tearDownInterwikis()
Remove the hardcoded interwiki lookup table.
$wgStylePath
The URL path of the skins directory.
static register($name, $callback)
Attach an event handler to a given hook.
wfGetLB($wiki=false)
Get a load balancer object.
$wgParserCacheType
The cache type for storing article HTML.
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().
$wgCapitalLinks
Set this to false to avoid forcing the first letter of links to capitals.
quickDiff($input, $output, $inFileTail= 'expected', $outFileTail= 'actual')
Run given strings through a diff and return the (colorized) output.
trimWhitespace()
The point of this function is to produce a normalized DOM in which Tidy's output matches the output o...
$wgLocalInterwikis
Array for multiple $wgLocalInterwiki values, in case there are several interwiki prefixes that point ...
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
requireHook($name)
Steal a callback function from the primary parser, save it for application to our scary parser...
$wgMessageCacheType
The cache type for storing the contents of the MediaWiki namespace.
controlled by $wgMainCacheType * $parserMemc
showTesting($desc)
"Running test $desc..."
static clearCache()
Clear the self::$mObjects variable For use in parser tests.
teardownGlobals()
Restore default values and perform any necessary clean-up after each test runs.
static destroySingletons()
Destroy the singleton instances.
serialize()
Serialize the XML DOM for comparison purposes.
$wgResourceBasePath
The default 'remoteBasePath' value for instances of ResourceLoaderFileModule.
static resetMain()
Resets singleton returned by getMain().
CACHE_MEMCACHED $wgMainCacheType
dumpToFile($data, $filename)
Write the given string to a file, adding a final newline.
Class to implement stub globals, which are globals that delay loading the their associated module cod...
static setupInterwikis()
Insert hardcoded interwiki in the lookup table.
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead.&$feedLinks conditions will AND in the final query as a Content object as a Content object $title
A BagOStuff object with no objects in it.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using hooks
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
isSuccess()
Whether the test passed.
extractFragment($text, $position)
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 $tag
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
setupDatabase()
Set up a temporary set of wiki tables to work with for the tests.
showRunFile($path)
Show "Reading tests from ...".
Initialize and detect the DjVu files support.
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
showFailure(ParserTestResult $testResult)
Print a failure message and provide some explanatory output about what went wrong if so configured...
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...
getMemoryBreakdown()
Get a memory usage breakdown.
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
in the sidebar</td >< td > font color
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.
$wgDiff3
Path to the GNU diff3 utility.
Simple store for keeping values in an associative array for the current process.
$wgExtraNamespaces
Additional namespaces.
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
$wgNamespaceProtection
Set the minimum permissions required to edit pages in each namespace.
Terminal that supports ANSI escape sequences.
static getOptionValue($key, $opts, $default)
Use a regex to find out the value of an option.
showTestResult(ParserTestResult $testResult)
Refactored in 1.22 to use ParserTestResult.
$wgScriptPath
The path we should point to.
colorDiff($text)
Colorize unified diff output if set for ANSI color output.
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
wfGetMainCache()
Get the main cache object.
$wgExtensionAssetsPath
The URL path of the extensions directory.
$wgDBprefix
Table name prefix.
DatabaseBase $db
Our connection to the database.
$wgStyleDirectory
Filesystem stylesheets directory.
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
wfEscapeShellArg()
Windows-compatible version of escapeshellarg() Windows doesn't recognise single-quotes in the shell...
$wgLockManagers
Array of configuration arrays for each lock manager.
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 to get request data $wgMemc
runTestsFromFiles($filenames)
Run a series of tests listed in the given text files.
static getVersion($flags= '', $lang=null)
Return a string of the MediaWiki version with Git revision if available.
Class for a file system (FS) based file backend.
static factory($code)
Get a cached or new language object for a given language code.
Represent the result of a parser test.
showSkipped()
Print a skipped message.
requireTransparentHook($name)
Steal a callback function from the primary parser, save it for application to our scary parser...
fuzzTest($filenames)
Run a fuzz test series Draw input from a set of test files.
static resetTitleServices()
Reset the Title-related services that need resetting for each test.
static getCanonicalNamespaces($rebuild=false)
Returns array of all defined namespaces with their canonical (English) names.
if(is_null($wgLocalTZoffset)) if(!$wgDBerrorLogTZ) $wgRequest
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
static singleton()
Get the signleton instance of this class.
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 deleteFiles($files)
Delete the specified files, if they exist.
Allows to change the fields on the form that will be generated $name