Go to the documentation of this file.
7 use Psr\Log\LoggerInterface;
8 use Wikimedia\TestingAccessWrapper;
117 parent::__construct(
$name, $data, $dataName );
119 $this->backupGlobals =
false;
120 $this->backupStaticAttributes =
false;
126 if ( isset( $this->called[
'setUp'] ) && !isset( $this->called[
'tearDown'] ) ) {
132 parent::setUpBeforeClass();
216 $oldServices = MediaWikiServices::getInstance();
217 $oldConfigFactory = $oldServices->getConfigFactory();
221 MediaWikiServices::resetGlobalInstance( $testConfig );
241 Config $baseConfig =
null,
242 Config $customOverrides =
null
246 if ( !$baseConfig ) {
247 $baseConfig = MediaWikiServices::getInstance()->getBootstrapConfig();
254 $hashCache = [
'class' =>
'HashBagOStuff',
'reportDupes' =>
false ];
260 'apcu' => $hashCache,
261 'xcache' => $hashCache,
262 'wincache' => $hashCache,
263 ] + $baseConfig->get(
'ObjectCaches' );
265 $defaultOverrides->set(
'ObjectCaches', $objectCaches );
266 $defaultOverrides->set(
'MainCacheType',
CACHE_NONE );
267 $defaultOverrides->set(
'JobTypeConf', [
'default' => [
'class' =>
'JobQueueMemory' ] ] );
270 $defaultOverrides->set(
'PasswordDefault',
'A' );
272 $testConfig = $customOverrides
273 ?
new MultiConfig( [ $customOverrides, $defaultOverrides, $baseConfig ] )
274 :
new MultiConfig( [ $defaultOverrides, $baseConfig ] );
295 self::makeTestConfigFactoryInstantiator(
297 [
'main' => $bootstrapConfig ]
310 array $configurations
316 $namesToClone = array_diff(
318 array_keys( $configurations )
321 foreach ( $namesToClone
as $name ) {
325 foreach ( $configurations
as $name => $config ) {
326 $factory->register(
$name, $config );
349 $services = MediaWikiServices::getInstance();
350 $services->resetServiceForTesting(
'MainObjectStash' );
351 $services->resetServiceForTesting(
'LocalServerObjectCache' );
352 $services->getMainWANObjectCache()->clearProcessCache();
357 if ( session_id() !==
'' ) {
358 session_write_close();
366 public function run( PHPUnit_Framework_TestResult
$result =
null ) {
370 $needsResetDB =
false;
372 if ( !self::$dbSetup || $this->
needsDB() ) {
375 self::$useTemporaryTables = !$this->
getCliArg(
'use-normal-tables' );
376 self::$reuseDB = $this->
getCliArg(
'reuse-db' );
382 if ( !self::$dbSetup ) {
387 $this->
resetDB( $this->db, $this->tablesUsed );
399 $needsResetDB =
true;
404 if ( $needsResetDB ) {
405 $this->
resetDB( $this->db, $this->tablesUsed );
418 $first = !isset( $this->db->_hasDataForTestClass )
419 || $this->db->_hasDataForTestClass !== $class;
421 $this->db->_hasDataForTestClass = $class;
445 $this->tmpFiles[] = $fileName;
475 $this->called[
'setUp'] =
true;
477 $this->phpErrorLevel = intval( ini_get(
'error_reporting' ) );
480 foreach ( $this->tmpFiles
as $fileName ) {
481 if ( is_file( $fileName ) || ( is_link( $fileName ) ) ) {
483 } elseif ( is_dir( $fileName ) ) {
488 if ( $this->
needsDB() && $this->db ) {
490 while ( $this->db->trxLevel() > 0 ) {
491 $this->db->rollback( __METHOD__,
'flush' );
494 if ( $this->db->getType() ===
'mysql' ) {
495 $this->db->query(
"SET sql_mode = 'STRICT_ALL_TABLES'" );
504 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
507 ob_start(
'MediaWikiTestCase::wfResetOutputBuffersBarrier' );
511 $this->tmpFiles = array_merge( $this->tmpFiles, (
array)$files );
518 if ( isset(
$status[
'name'] ) &&
519 $status[
'name'] ===
'MediaWikiTestCase::wfResetOutputBuffersBarrier'
524 $this->called[
'tearDown'] =
true;
526 foreach ( $this->tmpFiles
as $fileName ) {
527 if ( is_file( $fileName ) || ( is_link( $fileName ) ) ) {
529 } elseif ( is_dir( $fileName ) ) {
534 if ( $this->
needsDB() && $this->db ) {
536 while ( $this->db->trxLevel() > 0 ) {
537 $this->db->rollback( __METHOD__,
'flush' );
539 if ( $this->db->getType() ===
'mysql' ) {
540 $this->db->query(
"SET sql_mode = " . $this->db->addQuotes(
$wgSQLMode ) );
545 foreach ( $this->mwGlobals
as $key =>
$value ) {
548 foreach ( $this->mwGlobalsToUnset
as $value ) {
551 $this->mwGlobals = [];
552 $this->mwGlobalsToUnset = [];
555 if ( self::$serviceLocator && MediaWikiServices::getInstance() !== self::$serviceLocator ) {
556 MediaWikiServices::forceGlobalInstance( self::$serviceLocator );
561 if ( session_id() !==
'' ) {
562 session_write_close();
572 ini_set(
'error_reporting', $this->phpErrorLevel );
574 $oldHex = strtoupper( dechex( $this->phpErrorLevel ) );
576 $message =
"PHP error_reporting setting was left dirty: "
577 .
"was 0x$oldHex before test, 0x$newHex after test!";
579 $this->fail( $message );
594 $this->assertArrayHasKey(
'setUp', $this->called,
610 if ( MediaWikiServices::getInstance() === self::$serviceLocator ) {
614 MediaWikiServices::getInstance()->disableService(
$name );
615 MediaWikiServices::getInstance()->redefineService(
617 function ()
use ( $object ) {
659 if ( is_string( $pairs ) ) {
660 $pairs = [ $pairs =>
$value ];
665 foreach ( $pairs
as $key =>
$value ) {
682 if ( is_array(
$value ) ) {
684 if ( !is_scalar( $subValue ) && $subValue !==
null ) {
711 if ( is_string( $globalKeys ) ) {
712 $globalKeys = [ $globalKeys ];
715 foreach ( $globalKeys
as $globalKey ) {
720 !array_key_exists( $globalKey, $this->mwGlobals ) &&
721 !array_key_exists( $globalKey, $this->mwGlobalsToUnset )
723 if ( !array_key_exists( $globalKey,
$GLOBALS ) ) {
724 $this->mwGlobalsToUnset[$globalKey] = $globalKey;
730 if ( self::canShallowCopy(
$GLOBALS[$globalKey] ) ) {
731 $this->mwGlobals[$globalKey] =
$GLOBALS[$globalKey];
739 $this->mwGlobals[$globalKey] = clone
$GLOBALS[$globalKey];
743 }
catch ( Exception
$e ) {
744 $this->mwGlobals[$globalKey] =
$GLOBALS[$globalKey];
771 throw new MWException(
"MW global $name is not an array." );
776 foreach ( $values
as $k => $v ) {
799 if ( !$configOverrides ) {
803 $oldInstance = MediaWikiServices::getInstance();
804 $oldConfigFactory = $oldInstance->getConfigFactory();
811 $wiringFiles = $testConfig->get(
'ServiceWiringFiles' );
812 $newInstance->loadWiringFiles( $wiringFiles );
815 Hooks::run(
'MediaWikiServices', [ $newInstance ] );
818 $newInstance->redefineService(
$name, $callback );
825 MediaWikiServices::forceGlobalInstance( $newInstance );
845 $langCode =
$lang->getCode();
852 'wgLanguageCode' => $langCode,
853 'wgContLang' => $langObj,
863 protected function setLogger( $channel, LoggerInterface $logger ) {
867 $provider = LoggerFactory::getProvider();
868 $wrappedProvider = TestingAccessWrapper::newFromObject( $provider );
869 $singletons = $wrappedProvider->singletons;
871 if ( !isset( $this->loggers[$channel] ) ) {
872 $this->loggers[$channel] = isset( $singletons[
'loggers'][$channel] )
873 ? $singletons[
'loggers'][$channel] :
null;
875 $singletons[
'loggers'][$channel] = $logger;
876 } elseif ( $provider instanceof
LegacySpi ) {
877 if ( !isset( $this->loggers[$channel] ) ) {
878 $this->loggers[$channel] = isset( $singletons[$channel] ) ? $singletons[$channel] :
null;
880 $singletons[$channel] = $logger;
882 throw new LogicException( __METHOD__ .
': setting a logger for ' . get_class( $provider )
883 .
' is not implemented' );
885 $wrappedProvider->singletons = $singletons;
893 $provider = LoggerFactory::getProvider();
894 $wrappedProvider = TestingAccessWrapper::newFromObject( $provider );
895 $singletons = $wrappedProvider->singletons;
896 foreach ( $this->loggers
as $channel => $logger ) {
898 if ( $logger ===
null ) {
899 unset( $singletons[
'loggers'][$channel] );
901 $singletons[
'loggers'][$channel] = $logger;
903 } elseif ( $provider instanceof
LegacySpi ) {
904 if ( $logger ===
null ) {
905 unset( $singletons[$channel] );
907 $singletons[$channel] = $logger;
911 $wrappedProvider->singletons = $singletons;
928 # if the test says it uses database tables, it needs the database
929 if ( $this->tablesUsed ) {
933 # if the test says it belongs to the Database group, it needs the database
934 $rc =
new ReflectionClass( $this );
935 if ( preg_match(
'/@group +Database/im', $rc->getDocComment() ) ) {
955 $text =
'Sample page for unit test.',
958 if ( is_string( $pageName ) ) {
964 $user = static::getTestSysop()->getUser();
965 $comment = __METHOD__ .
': Sample page for unit test.';
976 'id' =>
$page->getId(),
1011 if ( $this->db->getType() ==
'oracle' ) {
1013 # Insert 0 user to prevent FK violations
1015 if ( !$this->db->selectField(
'user',
'1', [
'user_id' => 0 ] ) ) {
1016 $this->db->insert(
'user', [
1018 'user_name' =>
'Anonymous' ], __METHOD__, [
'IGNORE' ] );
1021 # Insert 0 page to prevent FK violations
1023 if ( !$this->db->selectField(
'page',
'1', [
'page_id' => 0 ] ) ) {
1024 $this->db->insert(
'page', [
1026 'page_namespace' => 0,
1027 'page_title' =>
' ',
1028 'page_restrictions' =>
null,
1029 'page_is_redirect' => 0,
1032 'page_touched' => $this->db->timestamp(),
1034 'page_len' => 0 ], __METHOD__, [
'IGNORE' ] );
1041 $user = static::getTestSysop()->getUser();
1045 if (
$page->getId() == 0 ) {
1046 $page->doEditContent(
1056 if ( session_id() !==
'' ) {
1057 session_write_close();
1073 if ( !self::$dbSetup ) {
1077 foreach ( $wgJobClasses
as $type => $class ) {
1084 self::$oldTablePrefix =
false;
1085 self::$dbSetup =
false;
1104 $dbClone->useTemporaryTables( self::$useTemporaryTables );
1111 $dbClone->cloneTableStructure();
1129 if ( self::isUsingExternalStoreDB() ) {
1156 if ( self::$dbSetup ) {
1160 if (
$db->tablePrefix() === $prefix ) {
1162 'Cannot run unit tests, the database prefix is already "' . $prefix .
'"' );
1168 self::$dbSetup =
true;
1170 if ( !self::setupDatabaseWithTestPrefix(
$db, $prefix ) ) {
1176 if (
$db->getType() ==
'oracle' ) {
1177 $db->query(
'BEGIN FILL_WIKI_INFO; END;' );
1188 foreach ( $connections
as $dbw ) {
1196 $dbw->tablePrefix( self::$oldTablePrefix );
1215 foreach ( $defaultArray
as $url ) {
1216 if ( strpos( $url,
'DB://' ) === 0 ) {
1217 list( $proto, $cluster ) = explode(
'://', $url, 2 );
1220 $dbws[] = $externalStoreDB->getMaster( $cluster );
1239 foreach ( $defaultArray
as $url ) {
1240 if ( strpos( $url,
'DB://' ) === 0 ) {
1256 $userTables = [
'user',
'user_groups',
'user_properties' ];
1257 $coreDBDataTables = array_merge( $userTables, [
'page',
'revision' ] );
1260 if ( array_intersect(
$tablesUsed, $userTables ) ) {
1265 $truncate = in_array(
$db->getType(), [
'oracle',
'mysql' ] );
1268 if ( $tbl ==
'interwiki' ) {
1273 $db->query(
'TRUNCATE TABLE ' .
$db->tableName( $tbl ), __METHOD__ );
1275 $db->delete( $tbl,
'*', __METHOD__ );
1278 if ( $tbl ===
'page' ) {
1285 if ( array_intersect(
$tablesUsed, $coreDBDataTables ) ) {
1302 static $compatibility = [
1303 'createMock' =>
'createMock2',
1306 if ( isset( $compatibility[$func] ) ) {
1307 return call_user_func_array( [ $this, $compatibility[$func] ],
$args );
1321 return $this->getMockBuilder( $originalClassName )
1322 ->disableOriginalConstructor()
1323 ->disableOriginalClone()
1324 ->disableArgumentCloning()
1331 $tableName = substr( $tableName, strlen( $prefix ) );
1335 return strpos( $table,
'unittest_' ) !== 0;
1346 $prefix =
$db->tablePrefix();
1347 $tables =
$db->listTables( $prefix, __METHOD__ );
1349 if (
$db->getType() ===
'mysql' ) {
1350 static $viewListCache =
null;
1351 if ( $viewListCache ===
null ) {
1352 $viewListCache =
$db->listViews(
null, __METHOD__ );
1357 array_walk(
$tables, [ __CLASS__,
'unprefixTable' ], $prefix );
1360 $tables = array_filter(
$tables, [ __CLASS__,
'isNotUnittest' ] );
1362 if (
$db->getType() ==
'sqlite' ) {
1365 unset(
$tables[
'searchindex_content'] );
1366 unset(
$tables[
'searchindex_segdir'] );
1367 unset(
$tables[
'searchindex_segments'] );
1380 throw new MWException( $this->db->getType() .
" is not currently supported for unit testing." );
1414 MediaWiki\suppressWarnings();
1416 MediaWiki\restoreWarnings();
1439 throw new MWException(
'When testing database state, the test cases\'s needDB()' .
1440 ' method should return true. Use @group Database or $this->tablesUsed.' );
1445 $res =
$db->select( $table, $fields, $condition,
wfGetCaller(), [
'ORDER BY' => $fields ] );
1446 $this->assertNotEmpty(
$res,
"query failed: " .
$db->lastError() );
1450 foreach ( $expectedRows
as $expected ) {
1451 $r =
$res->fetchRow();
1455 $this->assertNotEmpty( $r,
"row #$i missing" );
1457 $this->assertEquals( $expected, $r,
"row #$i mismatches" );
1460 $r =
$res->fetchRow();
1463 $this->assertFalse( $r,
"found extra row (after #$i)" );
1479 function ( $element ) {
1480 return [ $element ];
1499 $ordered =
false, $named =
false
1507 $expected = array_values( $expected );
1508 $actual = array_values( $actual );
1511 call_user_func_array(
1512 [ $this,
'assertEquals' ],
1513 array_merge( [ $expected, $actual ], array_slice( func_get_args(), 4 ) )
1530 $expected = str_replace(
'>',
">\n", $expected );
1531 $actual = str_replace(
'>',
">\n", $actual );
1533 $this->assertEquals( $expected, $actual, $msg );
1546 function ( $a, $b ) {
1562 if ( !is_array( $r ) ) {
1566 foreach ( $r
as $k => $v ) {
1567 if ( is_string( $k ) ) {
1587 if ( $actual ===
$value ) {
1588 $this->assertTrue(
true, $message );
1606 if ( class_exists(
$type ) || interface_exists(
$type ) ) {
1607 $this->assertInstanceOf(
$type, $actual, $message );
1609 $this->assertInternalType(
$type, $actual, $message );
1623 global $wgNamespaceContentModels;
1625 if ( isset( $wgNamespaceContentModels[$ns] ) ) {
1640 global $wgNamespaceContentModels;
1642 static $wikitextNS =
null;
1643 if ( $wikitextNS !==
null ) {
1648 if ( !isset( $wgNamespaceContentModels[
NS_MAIN] ) ) {
1663 $talk = array_filter(
$namespaces,
function ( $ns ) {
1673 if ( !isset( $wgNamespaceContentModels[$ns] ) ||
1686 throw new MWException(
"No namespace defaults to wikitext!" );
1698 # This check may also protect against code injection in
1699 # case of broken installations.
1700 MediaWiki\suppressWarnings();
1701 $haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
1702 MediaWiki\restoreWarnings();
1704 if ( !$haveDiff3 ) {
1705 $this->markTestSkipped(
"Skip test, since diff3 is not configured" );
1718 $loaded = extension_loaded( $extName );
1720 $this->markTestSkipped(
"PHP extension '$extName' is not loaded, skipping." );
1741 $html =
'<!DOCTYPE html><html><head><title>test</title></head><body>' .
$html .
'</body></html>';
1763 $this->markTestSkipped(
'Tidy extension not installed' );
1768 $allErrors = preg_split(
'/[\r\n]+/', $errorBuffer );
1773 $errors = preg_grep(
1774 '/^(.*Warning: (trimming empty|.* lacks ".*?" attribute).*|\s*)$/m',
1775 $allErrors, PREG_GREP_INVERT
1778 $this->assertEmpty( $errors, implode(
"\n", $errors ) );
static clear()
Clear all the cached instances.
WebRequest clone which takes values from a provided array.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
processing should stop and the error should be shown to the user * false
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
static isTalk( $index)
Is the given namespace a talk namespace?
Provides a fallback sequence for Config objects.
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
if(!isset( $args[0])) $lang
A Config instance which stores all settings as a member variable.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
namespace and then decline to actually register it & $namespaces
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup 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
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
static $additionalOptions
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 account $user
unserialize( $serialized)
static destroySingletons()
Destroy the singleton instances.
Allows to change the fields on the form that will be generated $name
static clearPendingUpdates()
Clear all pending updates without performing them.
const CONTENT_MODEL_WIKITEXT
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 my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
array $wgDefaultExternalStore
The place to put new revisions, false to put them in the local text table.
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
$wgDBprefix
Table name prefix.
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
Wraps the user object, so we can also retain full access to properties like password if we log in via...
static destroySingleton()
Destroy the 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 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
namespace and then decline to actually register it file or subcat img or subcat $title
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
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
Accesses configuration settings from $GLOBALS.
when a variable name is used in a it is silently declared as a new masking the global
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
Content object for wiki text pages.
and give any other recipients of the Program a copy of this License along with the Program You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Program or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these that in whole or in part contains or is derived from the Program or any part to be licensed as a whole at no charge to all third parties under the terms of this License c If the modified program normally reads commands interactively when run
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
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
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static resetMain()
Resets singleton returned by getMain().
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
MediaWiki Logger LegacySpi
makeConfig( $name)
Create a given Config using the registered callback for $name.
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 set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
static getMain()
Static methods.
static setLBFactoryTriggers(LBFactory $LBFactory)
MediaWiki Logger MonologSpi
wfTempDir()
Tries to get the system directory for temporary files.
static getStoreObject( $proto, array $params=[])
Get an external store object of the given type, with the given parameters.
static getMainWANInstance()
Get the main WAN cache object.
static changePrefix( $prefix)
Change the table prefix on all open DB connections/.
static resetIdByNameCache()
Reset the cache used in idFromName().
wfRecursiveRemoveDir( $dir)
Remove a directory and all its content.
static singleton()
Get an instance of this class.
static singleton( $wiki=false)
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
Factory class to create Config objects.
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
static factory( $code)
Get a cached or new language object for a given language code.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
static getMutableTestUser( $testName, $groups=[])
Get a TestUser object that the caller may modify.
if(! $wgDBerrorLogTZ) $wgRequest
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
static checkErrors( $text, &$errorStr=null)
Check HTML for errors, used if $wgValidateAllHtml = true.
static getImmutableTestUser( $groups=[])
Get a TestUser object that the caller may not modify.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
wfGetCaller( $level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
Internationalisation code.
the array() calling protocol came about after MediaWiki 1.4rc1.
$wgSQLMode
SQL Mode - default is turning off all modes, including strict, if set.
static clear()
Clear the registry.