6 use Psr\Log\LoggerInterface;
108 parent::__construct(
$name, $data, $dataName );
110 $this->backupGlobals =
false;
111 $this->backupStaticAttributes =
false;
117 if ( isset( $this->called[
'setUp'] ) && !isset( $this->called[
'tearDown'] ) ) {
123 parent::setUpBeforeClass();
163 return self::getTestUser( [
'sysop',
'bureaucrat' ] );
185 static $servicesPrepared =
false;
187 if ( $servicesPrepared ) {
190 $servicesPrepared =
true;
193 self::resetGlobalServices( $bootstrapConfig );
210 $oldServices = MediaWikiServices::getInstance();
211 $oldConfigFactory = $oldServices->getConfigFactory();
213 $testConfig = self::makeTestConfig( $bootstrapConfig );
215 MediaWikiServices::resetGlobalInstance( $testConfig );
217 self::$serviceLocator = MediaWikiServices::getInstance();
218 self::installTestServices(
220 self::$serviceLocator
234 Config $baseConfig = null,
235 Config $customOverrides = null
239 if ( !$baseConfig ) {
240 $baseConfig = MediaWikiServices::getInstance()->getBootstrapConfig();
247 $hashCache = [
'class' =>
'HashBagOStuff' ];
253 'xcache' => $hashCache,
254 'wincache' => $hashCache,
255 ] + $baseConfig->get(
'ObjectCaches' );
257 $defaultOverrides->set(
'ObjectCaches', $objectCaches );
258 $defaultOverrides->set(
'MainCacheType',
CACHE_NONE );
261 $defaultOverrides->set(
'PasswordDefault',
'A' );
263 $testConfig = $customOverrides
264 ?
new MultiConfig( [ $customOverrides, $defaultOverrides, $baseConfig ] )
265 :
new MultiConfig( [ $defaultOverrides, $baseConfig ] );
286 self::makeTestConfigFactoryInstantiator(
288 [
'main' => $bootstrapConfig ]
301 array $configurations
307 $namesToClone = array_diff(
309 array_keys( $configurations )
312 foreach ( $namesToClone
as $name ) {
316 foreach ( $configurations
as $name => $config ) {
317 $factory->register( $name, $config );
345 if ( session_id() !==
'' ) {
346 session_write_close();
354 public function run( PHPUnit_Framework_TestResult
$result = null ) {
358 $needsResetDB =
false;
360 if ( !self::$dbSetup || $this->
needsDB() ) {
363 self::$useTemporaryTables = !$this->
getCliArg(
'use-normal-tables' );
364 self::$reuseDB = $this->
getCliArg(
'reuse-db' );
370 if ( !self::$dbSetup ) {
374 if ( ( $this->db->getType() ==
'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
375 $this->
resetDB( $this->db, $this->tablesUsed );
387 $needsResetDB =
true;
392 if ( $needsResetDB ) {
393 $this->
resetDB( $this->db, $this->tablesUsed );
406 $first = !isset( $this->db->_hasDataForTestClass )
407 || $this->db->_hasDataForTestClass !== $class;
409 $this->db->_hasDataForTestClass = $class;
419 return self::$useTemporaryTables;
432 $fileName = tempnam(
wfTempDir(),
'MW_PHPUnit_' . get_class( $this ) .
'_' );
433 $this->tmpFiles[] = $fileName;
463 $this->called[
'setUp'] =
true;
465 $this->phpErrorLevel = intval( ini_get(
'error_reporting' ) );
468 foreach ( $this->tmpFiles
as $fileName ) {
469 if ( is_file( $fileName ) || ( is_link( $fileName ) ) ) {
471 } elseif ( is_dir( $fileName ) ) {
476 if ( $this->
needsDB() && $this->db ) {
478 while ( $this->db->trxLevel() > 0 ) {
479 $this->db->rollback( __METHOD__,
'flush' );
486 ob_start(
'MediaWikiTestCase::wfResetOutputBuffersBarrier' );
490 $this->tmpFiles = array_merge( $this->tmpFiles, (
array)
$files );
497 if ( isset(
$status[
'name'] ) &&
498 $status[
'name'] ===
'MediaWikiTestCase::wfResetOutputBuffersBarrier'
503 $this->called[
'tearDown'] =
true;
505 foreach ( $this->tmpFiles
as $fileName ) {
506 if ( is_file( $fileName ) || ( is_link( $fileName ) ) ) {
508 } elseif ( is_dir( $fileName ) ) {
513 if ( $this->
needsDB() && $this->db ) {
515 while ( $this->db->trxLevel() > 0 ) {
516 $this->db->rollback( __METHOD__,
'flush' );
521 foreach ( $this->mwGlobals
as $key =>
$value ) {
524 $this->mwGlobals = [];
527 if ( self::$serviceLocator && MediaWikiServices::getInstance() !== self::$serviceLocator ) {
528 MediaWikiServices::forceGlobalInstance( self::$serviceLocator );
534 if ( session_id() !==
'' ) {
535 session_write_close();
545 ini_set(
'error_reporting', $this->phpErrorLevel );
547 $oldHex = strtoupper( dechex( $this->phpErrorLevel ) );
549 $message =
"PHP error_reporting setting was left dirty: "
550 .
"was 0x$oldHex before test, 0x$newHex after test!";
552 $this->fail( $message );
563 $this->assertArrayHasKey(
'setUp', $this->called,
579 if ( MediaWikiServices::getInstance() === self::$serviceLocator ) {
583 MediaWikiServices::getInstance()->disableService(
$name );
584 MediaWikiServices::getInstance()->redefineService(
586 function ()
use ( $object ) {
628 if ( is_string( $pairs ) ) {
629 $pairs = [ $pairs =>
$value ];
634 foreach ( $pairs
as $key =>
$value ) {
651 if ( is_array(
$value ) ) {
653 if ( !is_scalar( $subValue ) && $subValue !== null ) {
682 if ( is_string( $globalKeys ) ) {
683 $globalKeys = [ $globalKeys ];
686 foreach ( $globalKeys
as $globalKey ) {
690 if ( !array_key_exists( $globalKey, $this->mwGlobals ) ) {
691 if ( !array_key_exists( $globalKey,
$GLOBALS ) ) {
692 throw new Exception(
"Global with key {$globalKey} doesn't exist and cant be stashed" );
697 if ( self::canShallowCopy(
$GLOBALS[$globalKey] ) ) {
698 $this->mwGlobals[$globalKey] =
$GLOBALS[$globalKey];
706 $this->mwGlobals[$globalKey] = clone
$GLOBALS[$globalKey];
710 }
catch ( Exception
$e ) {
711 $this->mwGlobals[$globalKey] =
$GLOBALS[$globalKey];
737 if ( !is_array(
$GLOBALS[$name] ) ) {
738 throw new MWException(
"MW global $name is not an array." );
743 foreach ( $values
as $k => $v ) {
766 if ( !$configOverrides ) {
770 $oldInstance = MediaWikiServices::getInstance();
771 $oldConfigFactory = $oldInstance->getConfigFactory();
773 $testConfig = self::makeTestConfig( null, $configOverrides );
778 $wiringFiles = $testConfig->get(
'ServiceWiringFiles' );
779 $newInstance->loadWiringFiles( $wiringFiles );
782 Hooks::run(
'MediaWikiServices', [ $newInstance ] );
785 $newInstance->redefineService(
$name, $callback );
788 self::installTestServices(
792 MediaWikiServices::forceGlobalInstance( $newInstance );
812 $langCode =
$lang->getCode();
819 'wgLanguageCode' => $langCode,
820 'wgContLang' => $langObj,
830 protected function setLogger( $channel, LoggerInterface $logger ) {
834 $provider = LoggerFactory::getProvider();
836 $singletons = $wrappedProvider->singletons;
838 if ( !isset( $this->loggers[$channel] ) ) {
839 $this->loggers[$channel] = isset( $singletons[
'loggers'][$channel] )
840 ? $singletons[
'loggers'][$channel] : null;
842 $singletons[
'loggers'][$channel] = $logger;
843 } elseif ( $provider instanceof
LegacySpi ) {
844 if ( !isset( $this->loggers[$channel] ) ) {
845 $this->loggers[$channel] = isset( $singletons[$channel] ) ? $singletons[$channel] : null;
847 $singletons[$channel] = $logger;
849 throw new LogicException( __METHOD__ .
': setting a logger for ' . get_class( $provider )
850 .
' is not implemented' );
852 $wrappedProvider->singletons = $singletons;
860 $provider = LoggerFactory::getProvider();
862 $singletons = $wrappedProvider->singletons;
863 foreach ( $this->loggers
as $channel => $logger ) {
865 if ( $logger === null ) {
866 unset( $singletons[
'loggers'][$channel] );
868 $singletons[
'loggers'][$channel] = $logger;
870 } elseif ( $provider instanceof
LegacySpi ) {
871 if ( $logger === null ) {
872 unset( $singletons[$channel] );
874 $singletons[$channel] = $logger;
878 $wrappedProvider->singletons = $singletons;
887 return $this->db->getType() ==
'oracle' ? self::ORA_DB_PREFIX : self::DB_PREFIX;
895 # if the test says it uses database tables, it needs the database
896 if ( $this->tablesUsed ) {
900 # if the test says it belongs to the Database group, it needs the database
901 $rc =
new ReflectionClass( $this );
902 if ( preg_match(
'/@group +Database/im', $rc->getDocComment() ) ) {
919 protected function insertPage( $pageName, $text =
'Sample page for unit test.' ) {
922 $user = static::getTestSysop()->getUser();
923 $comment = __METHOD__ .
': Sample page for unit test.';
934 'id' =>
$page->getId(),
969 if ( $this->db->getType() ==
'oracle' ) {
971 # Insert 0 user to prevent FK violations
973 if ( !$this->db->selectField(
'user',
'1', [
'user_id' => 0 ] ) ) {
974 $this->db->insert(
'user', [
976 'user_name' =>
'Anonymous' ], __METHOD__, [
'IGNORE' ] );
979 # Insert 0 page to prevent FK violations
981 if ( !$this->db->selectField(
'page',
'1', [
'page_id' => 0 ] ) ) {
982 $this->db->insert(
'page', [
984 'page_namespace' => 0,
986 'page_restrictions' => null,
987 'page_is_redirect' => 0,
990 'page_touched' => $this->db->timestamp(),
992 'page_len' => 0 ], __METHOD__, [
'IGNORE' ] );
999 $user = static::getTestSysop()->getUser();
1003 if (
$page->getId() == 0 ) {
1004 $page->doEditContent(
1014 if ( session_id() !==
'' ) {
1015 session_write_close();
1031 if ( !self::$dbSetup ) {
1035 foreach ( $wgJobClasses
as $type => $class ) {
1042 self::$oldTablePrefix =
false;
1043 self::$dbSetup =
false;
1060 $tablesCloned = self::listTables( $db );
1061 $dbClone =
new CloneDatabase( $db, $tablesCloned, $prefix );
1062 $dbClone->useTemporaryTables( self::$useTemporaryTables );
1064 if ( ( $db->
getType() ==
'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
1069 $dbClone->cloneTableStructure();
1085 self::setupTestDB( $this->db, $testPrefix );
1087 if ( self::isUsingExternalStoreDB() ) {
1088 self::setupExternalStoreTestDBs( $testPrefix );
1116 'Cannot run unit tests, the database prefix is already "' . $prefix .
'"' );
1119 if ( self::$dbSetup ) {
1126 self::$dbSetup =
true;
1128 if ( !self::setupDatabaseWithTestPrefix( $db, $prefix ) ) {
1134 if ( $db->
getType() ==
'oracle' ) {
1135 $db->
query(
'BEGIN FILL_WIKI_INFO; END;' );
1145 $connections = self::getExternalStoreDatabaseConnections();
1146 foreach ( $connections
as $dbw ) {
1154 $dbw->tablePrefix( self::$oldTablePrefix );
1155 self::setupDatabaseWithTestPrefix( $dbw, $testPrefix );
1170 $defaultArray = (
array) $wgDefaultExternalStore;
1172 foreach ( $defaultArray
as $url ) {
1173 if ( strpos( $url,
'DB://' ) === 0 ) {
1174 list( $proto, $cluster ) = explode(
'://', $url, 2 );
1175 $dbw = $externalStoreDB->getMaster( $cluster );
1190 if ( !$wgDefaultExternalStore ) {
1194 $defaultArray = (
array) $wgDefaultExternalStore;
1195 foreach ( $defaultArray
as $url ) {
1196 if ( strpos( $url,
'DB://' ) === 0 ) {
1212 $userTables = [
'user',
'user_groups',
'user_properties' ];
1213 $coreDBDataTables = array_merge( $userTables, [
'page',
'revision' ] );
1216 if ( array_intersect(
$tablesUsed, $userTables ) ) {
1221 $truncate = in_array(
$db->
getType(), [
'oracle',
'mysql' ] );
1224 if ( $tbl ==
'interwiki' ) {
1234 if ( $tbl ===
'page' ) {
1241 if ( array_intersect(
$tablesUsed, $coreDBDataTables ) ) {
1258 static $compatibility = [
1259 'assertEmpty' =>
'assertEmpty2',
1262 if ( isset( $compatibility[$func] ) ) {
1263 return call_user_func_array( [ $this, $compatibility[$func] ],
$args );
1265 throw new MWException(
"Called non-existent $func method on "
1266 . get_class( $this ) );
1276 $this->assertTrue(
$value ==
'', $msg );
1280 $tableName = substr( $tableName, strlen( $prefix ) );
1284 return strpos( $table,
'unittest_' ) !== 0;
1299 # bug 43571: cannot clone VIEWs under MySQL
1303 array_walk(
$tables, [ __CLASS__,
'unprefixTable' ], $prefix );
1306 $tables = array_filter(
$tables, [ __CLASS__,
'isNotUnittest' ] );
1311 unset(
$tables[
'searchindex_content'] );
1312 unset(
$tables[
'searchindex_segdir'] );
1313 unset(
$tables[
'searchindex_segments'] );
1326 throw new MWException( $this->db->getType() .
" is not currently supported for unit testing." );
1358 MediaWiki\suppressWarnings();
1360 MediaWiki\restoreWarnings();
1383 throw new MWException(
'When testing database state, the test cases\'s needDB()' .
1384 ' method should return true. Use @group Database or $this->tablesUsed.' );
1394 foreach ( $expectedRows
as $expected ) {
1395 $r =
$res->fetchRow();
1396 self::stripStringKeys( $r );
1399 $this->assertNotEmpty( $r,
"row #$i missing" );
1401 $this->assertEquals( $expected, $r,
"row #$i mismatches" );
1404 $r =
$res->fetchRow();
1405 self::stripStringKeys( $r );
1407 $this->assertFalse( $r,
"found extra row (after #$i)" );
1423 function ( $element ) {
1424 return [ $element ];
1443 $ordered =
false, $named =
false
1451 $expected = array_values( $expected );
1452 $actual = array_values( $actual );
1455 call_user_func_array(
1456 [ $this,
'assertEquals' ],
1457 array_merge( [ $expected, $actual ], array_slice( func_get_args(), 4 ) )
1474 $expected = str_replace(
'>',
">\n", $expected );
1475 $actual = str_replace(
'>',
">\n", $actual );
1477 $this->assertEquals( $expected, $actual, $msg );
1490 function ( $a, $b ) {
1506 if ( !is_array( $r ) ) {
1510 foreach ( $r
as $k => $v ) {
1511 if ( is_string( $k ) ) {
1531 if ( $actual ===
$value ) {
1532 $this->assertTrue(
true, $message );
1550 if ( class_exists(
$type ) || interface_exists(
$type ) ) {
1551 $this->assertInstanceOf(
$type, $actual, $message );
1553 $this->assertInternalType(
$type, $actual, $message );
1569 if ( isset( $wgNamespaceContentModels[$ns] ) ) {
1586 static $wikitextNS = null;
1587 if ( $wikitextNS !== null ) {
1592 if ( !isset( $wgNamespaceContentModels[
NS_MAIN] ) ) {
1607 $talk = array_filter(
$namespaces,
function ( $ns ) {
1613 $namespaces = array_merge( $namespaces, $talk );
1616 foreach ( $namespaces
as $ns ) {
1617 if ( !isset( $wgNamespaceContentModels[$ns] ) ||
1630 throw new MWException(
"No namespace defaults to wikitext!" );
1642 # This check may also protect against code injection in
1643 # case of broken installations.
1644 MediaWiki\suppressWarnings();
1645 $haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 );
1646 MediaWiki\restoreWarnings();
1648 if ( !$haveDiff3 ) {
1649 $this->markTestSkipped(
"Skip test, since diff3 is not configured" );
1662 $loaded = extension_loaded( $extName );
1664 $this->markTestSkipped(
"PHP extension '$extName' is not loaded, skipping." );
1685 $html =
'<!DOCTYPE html><html><head><title>test</title></head><body>' .
$html .
'</body></html>';
1707 $this->markTestSkipped(
'Tidy extension not installed' );
1712 $allErrors = preg_split(
'/[\r\n]+/', $errorBuffer );
1717 $errors = preg_grep(
1718 '/^(.*Warning: (trimming empty|.* lacks ".*?" attribute).*|\s*)$/m',
1719 $allErrors, PREG_GREP_INVERT
1722 $this->assertEmpty( $errors, implode(
"\n", $errors ) );
1732 private static function tagMatch( $matcher, $actual, $isHtml =
true ) {
1734 $tags = PHPUnit_Util_XML::findNodes( $dom, $matcher, $isHtml );
1735 return count( $tags ) > 0 && $tags[0] instanceof DOMNode;
1749 public static function assertTag( $matcher, $actual, $message =
'', $isHtml =
true ) {
1752 self::assertTrue( self::tagMatch( $matcher, $actual, $isHtml ), $message );
1764 public static function assertNotTag( $matcher, $actual, $message =
'', $isHtml =
true ) {
1767 self::assertFalse( self::tagMatch( $matcher, $actual, $isHtml ), $message );
select($table, $vars, $conds= '', $fname=__METHOD__, $options=[], $join_conds=[])
Execute a SELECT query constructed using the various parameters provided.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
static $additionalOptions
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.
the array() calling protocol came about after MediaWiki 1.4rc1.
const CONTENT_MODEL_WIKITEXT
array $wgDefaultExternalStore
The place to put new revisions, false to put them in the local text table.
Factory class to create Config objects.
tableName($name, $format= 'quoted')
Format a table name ready for use in constructing an SQL query.
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
if(!isset($args[0])) $lang
static isTalk($index)
Is the given namespace a talk namespace?
listViews($prefix=null, $fname=__METHOD__)
Lists all the VIEWs in the database.
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load
static checkErrors($text, &$errorStr=null)
Check HTML for errors, used if $wgValidateAllHtml = true.
static changePrefix($prefix)
Change the table prefix on all open DB connections/.
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
lastError()
Get a description of the last error.
static resetIdByNameCache()
Reset the cache used in idFromName().
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 destroySingleton()
Destroy the singleton instance.
$wgJobClasses
Maps jobs to their handling classes; extensions can add to this to provide custom jobs...
listTables($prefix=null, $fname=__METHOD__)
List all tables on the database.
getType()
Get the type of the DBMS, as it appears in $wgDBtype.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
tablePrefix($prefix=null)
Get/set the table prefix.
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
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
static clear()
Clear the registry.
Accesses configuration settings from $GLOBALS.
wfTempDir()
Tries to get the system directory for temporary files.
static getMain()
Static methods.
Interface for configuration instances.
static singleton()
Get an instance of this class.
static getStoreObject($proto, array $params=[])
Get an external store object of the given type, with the given parameters.
makeConfig($name)
Create a given Config using the registered callback for $name.
MediaWiki Logger MonologSpi
Internationalisation code.
static resetMain()
Resets singleton returned by getMain().
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static getContentNamespaces()
Get a list of all namespace indices which are considered to contain content.
static getMutableTestUser($testName, $groups=[])
Get a TestUser object that the caller may modify.
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
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Content object for wiki text pages.
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
Provides a fallback sequence for Config objects.
namespace and then decline to actually register it & $namespaces
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
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
static singleton($wiki=false)
Database abstraction object.
$wgDiff3
Path to the GNU diff3 utility.
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
or there are no hooks to run
MediaWiki Logger LegacySpi
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
WebRequest clone which takes values from a provided array.
$wgDBprefix
Table name prefix.
query($sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.
wfRecursiveRemoveDir($dir)
Remove a directory and all its content.
$wgNamespaceContentModels
Associative array mapping namespace IDs to the name of the content model pages in that namespace shou...
static getImmutableTestUser($groups=[])
Get a TestUser object that the caller may not modify.
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
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 clear()
Clear all the cached instances.
static newFromObject($object)
Return the same object, without access restrictions.
static factory($code)
Get a cached or new language object for a given language code.
A Config instance which stores all settings as a member variable.
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
delete($table, $conds, $fname=__METHOD__)
DELETE query wrapper.
if(is_null($wgLocalTZoffset)) if(!$wgDBerrorLogTZ) $wgRequest
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 one of or reset 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
wfGetCaller($level=2)
Get the name of the function which called this function wfGetCaller( 1 ) is the function with the wfG...
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 destroySingletons()
Destroy the singleton instances.
Allows to change the fields on the form that will be generated $name