37 public static function getWiki( $wikiID ) {
39 if ( $wikiReference ) {
40 return $wikiReference;
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;
70 [
'lang' => $minor,
'site' => $major ] );
75 if ( !is_string( $canonicalServer ) || !is_string(
$path ) || strpos(
$path,
'$1' ) ===
false ) {
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'];
124 return $wiki->getDisplayName();
155 if ( $url ===
false ) {
171 public static function getForeignURL( $wikiID, $page, $fragmentId =
null ) {
175 return $wiki->getFullUrl( $page, $fragmentId );
188 $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
190 return $cache->getWithSetCallback(
191 $cache->makeGlobalKey(
'wikimap',
'canonical-urls' ),
206 if ( $wikiReference ) {
207 $url = $wikiReference->getCanonicalServer();
208 $infoMap[$wikiId] = [
'url' => $url,
'parts' =>
wfParseUrl( $url ) ];
224 if ( $urlPartsCheck ===
false ) {
228 $urlPartsCheck = array_intersect_key( $urlPartsCheck, [
'host' => 1,
'port' => 1 ] );
229 foreach ( self::getCanonicalServerInfoForAllWikis()
as $wikiId => $info ) {
230 $urlParts = $info[
'parts'];
231 if ( $urlParts ===
false ) {
235 $urlParts = array_intersect_key( $urlParts, [
'host' => 1,
'port' => 1 ] );
236 if ( $urlParts == $urlPartsCheck ) {
254 $domain = DatabaseDomain::newFromId( $domain );
257 return strlen( $domain->getTablePrefix() )
258 ?
"{$domain->getDatabase()}-{$domain->getTablePrefix()}"
259 : $domain->getDatabase();
268 $domain = DatabaseDomain::newFromId( $domain );
271 if ( !in_array( $curDomain->getSchema(), [
null,
'mediawiki' ],
true ) ) {
276 return $curDomain->equals( $domain );
280 $curDomain->getDatabase() === $domain->getDatabase() &&
281 $curDomain->getTablePrefix() === $domain->getTablePrefix()
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgDBprefix
Table name prefix.
$wgLocalDatabases
Other wikis on this site, can be administered from a single developer account.
$wgDBmwschema
Mediawiki schema.
$wgConf
wgConf hold the site configuration.
$wgCanonicalServer
Canonical URL of the server, to use in IRC feeds and notification e-mails.
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
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 getWiki( $wikiID)
Get a WikiReference object for $wikiID.
static getWikiReferenceFromWgConf( $wikiID)
static getWikiName( $wikiID)
Convenience to get the wiki's display name.
static getCurrentWikiDbDomain()
static getWikiIdFromDomain( $domain)
Get the wiki ID of a database 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 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
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
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
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