37 public static function getWiki( $wikiID ) {
38 $wikiReference = self::getWikiReferenceFromWgConf( $wikiID );
39 if ( $wikiReference ) {
44 return self::getWikiWikiReferenceFromSites( $wikiID );
56 list( $major, $minor ) =
$wgConf->siteFromDB( $wikiID );
57 if ( $major ===
null ) {
60 $server =
$wgConf->get(
'wgServer', $wikiID, $major,
61 [
'lang' => $minor,
'site' => $major ] );
63 $canonicalServer =
$wgConf->get(
'wgCanonicalServer', $wikiID, $major,
64 [
'lang' => $minor,
'site' => $major ] );
65 if ( $canonicalServer ===
false || $canonicalServer ===
null ) {
66 $canonicalServer = $server;
69 $path =
$wgConf->get(
'wgArticlePath', $wikiID, $major,
70 [
'lang' => $minor,
'site' => $major ] );
87 $siteLookup = MediaWikiServices::getInstance()->getSiteLookup();
88 $site = $siteLookup->getSite( $wikiID );
96 if ( $urlParts ===
false || !
isset( $urlParts[
'path'] ) || !
isset( $urlParts[
'host'] ) ) {
102 $path = $urlParts[
'path'];
103 if (
isset( $urlParts[
'query'] ) ) {
104 $path .=
'?' . $urlParts[
'query'];
107 $canonicalServer = $urlParts[
'scheme'] ??
'http';
108 $canonicalServer .=
'://' . $urlParts[
'host'];
121 $wiki = self::getWiki( $wikiID );
124 return $wiki->getDisplayName();
138 return self::makeForeignLink( $wikiID,
"User:$user", $text );
154 $url = self::getForeignURL( $wikiID, $page );
155 if ( $url ===
false ) {
171 public static function getForeignURL( $wikiID, $page, $fragmentId =
null ) {
172 $wiki = self::getWiki( $wikiID );
175 return $wiki->getFullUrl( $page, $fragmentId );
188 $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
190 return $cache->getWithSetCallback(
191 $cache->makeGlobalKey(
'wikimap',
'canonical-urls' ),
199 $wikiId = self::getWikiIdFromDbDomain( self::getCurrentWikiDbDomain() );
200 $infoMap[$wikiId] = [
206 $wikiReference = self::getWiki( $wikiId );
207 if ( $wikiReference ) {
208 $url = $wikiReference->getCanonicalServer();
209 $infoMap[$wikiId] = [
'url' => $url,
'parts' =>
wfParseUrl( $url ) ];
225 if ( $urlPartsCheck ===
false ) {
230 foreach ( self::getCanonicalServerInfoForAllWikis() as $wikiId => $info ) {
231 $urlParts = $info[
'parts'];
232 if ( $urlParts ===
false ) {
237 if ( $urlParts == $urlPartsCheck ) {
260 $domain = DatabaseDomain::newFromId( $domain );
266 if ( !
in_array( $domain->getSchema(), [
null,
'mediawiki',
'dbo' ],
true ) ) {
270 return "{$domain->getDatabase()}-{$domain->getSchema()}-{$domain->getTablePrefix()}";
274 return strlen( $domain->getTablePrefix() )
275 ?
"{$domain->getDatabase()}-{$domain->getTablePrefix()}"
276 : (
string)$domain->getDatabase();
285 return self::getWikiIdFromDbDomain( $domain );
304 return self::getCurrentWikiDbDomain()->equals( DatabaseDomain::newFromId( $domain ) );
313 return ( self::getWikiIdFromDbDomain( self::getCurrentWikiDbDomain() ) === $wikiId );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgDBprefix
Table name prefix.
$wgDBmwschema
Mediawiki schema; this should be alphanumeric and not contain spaces nor hyphens.
$wgConf
wgConf hold the site configuration.
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
string[] $wgLocalDatabases
Other wikis on this site, can be administered from a single developer account.
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
Helper tools for dealing with other locally-hosted wikis.
static getWikiWikiReferenceFromSites( $wikiID)
static makeForeignLink( $wikiID, $page, $text=null)
Convenience to get a link to a page on a foreign wiki.
static getCanonicalServerInfoForAllWikis()
Get canonical server info for all local wikis in the map that have one.
static getWikiIdFromDbDomain( $domain)
Get the wiki ID of a database domain.
static getWiki( $wikiID)
Get a WikiReference object for $wikiID.
static isCurrentWikiId( $wikiId)
static getWikiReferenceFromWgConf( $wikiID)
static getWikiName( $wikiID)
Convenience to get the wiki's display name.
static getCurrentWikiDbDomain()
static getWikiIdFromDomain( $domain)
static foreignUserLink( $wikiID, $user, $text=null)
Convenience to get a link to a user page on a foreign wiki.
static getWikiFromUrl( $url)
static getForeignURL( $wikiID, $page, $fragmentId=null)
Convenience to get a url to a page on a foreign wiki.
static isCurrentWikiDbDomain( $domain)
Reference to a locally-hosted wiki.
Class to handle database/prefix specification for IDatabase domains.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
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 function
controlled by the following MediaWiki still creates a BagOStuff but calls it to it are no ops If the cache daemon can t be it should also disable itself fairly $wgDBname