Those added in this same release do not need alias methods.
Change-Id: I05feeb9b0b13afe43aea1f95551965489cdbe094
$infoMap = [];
// Make sure at least the current wiki is set, for simple configurations.
// This also makes it the first in the map, which is useful for common cases.
- $wikiId = self::getWikiIdFromDomain( self::getCurrentWikiDomain() );
+ $wikiId = self::getWikiIdFromDbDomain( self::getCurrentWikiDbDomain() );
$infoMap[$wikiId] = [
'url' => $wgCanonicalServer,
'parts' => wfParseUrl( $wgCanonicalServer )
*
* @param string|DatabaseDomain $domain
* @return string
+ * @since 1.31
*/
- public static function getWikiIdFromDomain( $domain ) {
+ public static function getWikiIdFromDbDomain( $domain ) {
$domain = DatabaseDomain::newFromId( $domain );
if ( !in_array( $domain->getSchema(), [ null, 'mediawiki' ], true ) ) {
: (string)$domain->getDatabase();
}
+ /**
+ * @param string $domain
+ * @return string
+ * @deprecated Since 1.33; use getWikiIdFromDbDomain()
+ */
+ public static function getWikiIdFromDomain( $domain ) {
+ return self::getWikiIdFromDbDomain( $domain );
+ }
+
/**
* @return DatabaseDomain Database domain of the current wiki
* @since 1.33
*/
- public static function getCurrentWikiDomain() {
+ public static function getCurrentWikiDbDomain() {
global $wgDBname, $wgDBmwschema, $wgDBprefix;
// Avoid invoking LBFactory to avoid any chance of recursion
return new DatabaseDomain( $wgDBname, $wgDBmwschema, (string)$wgDBprefix );
* @return bool Whether $domain has the same DB/prefix as the current wiki
* @since 1.33
*/
- public static function isCurrentWikiDomain( $domain ) {
+ public static function isCurrentWikiDbDomain( $domain ) {
$domain = DatabaseDomain::newFromId( $domain );
- $curDomain = self::getCurrentWikiDomain();
+ $curDomain = self::getCurrentWikiDbDomain();
if ( !in_array( $curDomain->getSchema(), [ null, 'mediawiki' ], true ) ) {
// Include the schema if it is set and is not the default placeholder.
* @since 1.33
*/
public static function isCurrentWikiId( $wikiId ) {
- return ( self::getWikiIdFromDomain( self::getCurrentWikiDomain() ) === $wikiId );
+ return ( self::getWikiIdFromDbDomain( self::getCurrentWikiDbDomain() ) === $wikiId );
}
}
$date = $d->format( 'D M j G:i:s T Y' );
$host = wfHostname();
- $wiki = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() );
+ $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
$text = "{$date}\t{$host}\t{$wiki}\t{$message}\n";
return $text;
*/
protected static function formatAsWfDebugLog( $channel, $message, $context ) {
$time = wfTimestamp( TS_DB );
- $wiki = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() );
+ $wiki = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
$host = wfHostname();
$text = "{$time} {$host} {$wiki}: {$message}\n";
return $text;
public function __invoke( array $record ) {
global $wgVersion;
$record['extra']['host'] = wfHostname();
- $record['extra']['wiki'] = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() );
+ $record['extra']['wiki'] = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
$record['extra']['mwversion'] = $wgVersion;
$record['extra']['reqId'] = \WebRequest::getRequestId();
if ( wfIsCLI() && isset( $_SERVER['argv'] ) ) {
public function getAsJobSpecification() {
return [
- 'wiki' => WikiMap::getWikiIdFromDomain( $this->getDB()->getDomainID() ),
+ 'wiki' => WikiMap::getWikiIdFromDbDomain( $this->getDB()->getDomainID() ),
'job' => new JobSpecification(
'deleteLinks',
[ 'pageId' => $this->pageId, 'timestamp' => $this->timestamp ],
}
return [
- 'wiki' => WikiMap::getWikiIdFromDomain( $this->getDB()->getDomainID() ),
+ 'wiki' => WikiMap::getWikiIdFromDbDomain( $this->getDB()->getDomainID() ),
'job' => new JobSpecification(
'refreshLinksPrioritized',
[
*/
public static function singleton( $domain = false ) {
if ( $domain === false ) {
- $domain = WikiMap::getCurrentWikiDomain()->getId();
+ $domain = WikiMap::getCurrentWikiDbDomain()->getId();
}
if ( !isset( self::$instances[$domain] ) ) {
private function getInterwikiCacheEntry( $prefix ) {
wfDebug( __METHOD__ . "( $prefix )\n" );
- $wikiId = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() );
+ $wikiId = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
$value = false;
try {
private function getAllPrefixesCached( $local ) {
wfDebug( __METHOD__ . "()\n" );
- $wikiId = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() );
+ $wikiId = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
$data = [];
try {
global $wgJobClasses;
$this->assertNotReadOnly();
- if ( !WikiMap::isCurrentWikiDomain( $this->domain ) ) {
+ if ( !WikiMap::isCurrentWikiDbDomain( $this->domain ) ) {
throw new MWException(
"Cannot pop '{$this->type}' job off foreign '{$this->domain}' wiki queue." );
} elseif ( !isset( $wgJobClasses[$this->type] ) ) {
global $wgLocalDatabases;
if ( $domain === false ) {
- $domain = WikiMap::getCurrentWikiDomain()->getId();
+ $domain = WikiMap::getCurrentWikiDbDomain()->getId();
}
if ( !isset( self::$instances[$domain] ) ) {
self::$instances[$domain] = new self( $domain, wfConfiguredReadOnlyReason() );
// Make sure jobs are not getting pushed to bogus wikis. This can confuse
// the job runner system into spawning endless RPC requests that fail (T171371).
- $wikiId = WikiMap::getWikiIdFromDomain( $domain );
+ $wikiId = WikiMap::getWikiIdFromDbDomain( $domain );
if (
- !WikiMap::isCurrentWikiDomain( $domain ) &&
+ !WikiMap::isCurrentWikiDbDomain( $domain ) &&
!in_array( $wikiId, $wgLocalDatabases )
) {
self::$instances[$domain]->invalidDomain = true;
*/
private function getCachedConfigVar( $name ) {
// @TODO: cleanup this whole method with a proper config system
- if ( WikiMap::isCurrentWikiDomain( $this->domain ) ) {
+ if ( WikiMap::isCurrentWikiDbDomain( $this->domain ) ) {
return $GLOBALS[$name]; // common case
} else {
- $wiki = WikiMap::getWikiIdFromDomain( $this->domain );
+ $wiki = WikiMap::getWikiIdFromDbDomain( $this->domain );
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$value = $cache->getWithSetCallback(
$cache->makeGlobalKey( 'jobqueue', 'configvalue', $this->domain, $name ),
$type = is_string( $type ) ? $type : $this->type;
// Use wiki ID for b/c
- $keyspace = WikiMap::getWikiIdFromDomain( $this->domain );
+ $keyspace = WikiMap::getWikiIdFromDbDomain( $this->domain );
$parts = [ $keyspace, 'jobqueue', $type, $prop ];
static function makeMsgId() {
global $wgSMTP, $wgServer;
- $domainId = WikiMap::getCurrentWikiDomain()->getId();
+ $domainId = WikiMap::getCurrentWikiDbDomain()->getId();
$msgid = uniqid( $domainId . ".", true /** for cygwin */ );
if ( is_array( $wgSMTP ) && isset( $wgSMTP['IDHost'] ) && $wgSMTP['IDHost'] ) {
$domain = $wgSMTP['IDHost'];
return $keyspace;
}
- return WikiMap::getCurrentWikiDomain()->getId();
+ return WikiMap::getCurrentWikiDbDomain()->getId();
}
/**
// means that some cache invalidations happen that are not strictly needed.
$cache->makeGlobalKey(
'interwiki-page',
- WikiMap::getCurrentWikiDomain()->getId(),
+ WikiMap::getCurrentWikiDbDomain()->getId(),
$title->getDBkey()
)
);
*/
public function getProfileID() {
if ( $this->profileID === false ) {
- return WikiMap::getCurrentWikiDomain()->getId();
+ return WikiMap::getCurrentWikiDbDomain()->getId();
} else {
return $this->profileID;
}
$packet['server_name'] = $wgServerName;
$packet['server_script_path'] = $wgScriptPath ?: '/';
- $packet['wiki'] = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() );
+ $packet['wiki'] = WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() );
return $this->formatArray( $packet );
}
$rev = $timestamp ? Revision::loadFromTimestamp( $dbr, $utp, $timestamp ) : null;
return [
[
- 'wiki' => WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ),
+ 'wiki' => WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ),
'link' => $utp->getLocalURL(),
'rev' => $rev
]
/**
* @dataProvider provideGetWikiIdFromDomain
- * @covers WikiMap::getWikiIdFromDomain()
+ * @covers WikiMap::getWikiIdFromDbDomain()
*/
public function testGetWikiIdFromDomain( $domain, $wikiId ) {
- $this->assertEquals( $wikiId, WikiMap::getWikiIdFromDomain( $domain ) );
+ $this->assertEquals( $wikiId, WikiMap::getWikiIdFromDbDomain( $domain ) );
}
/**
- * @covers WikiMap::isCurrentWikiDomain()
- * @covers WikiMap::getCurrentWikiDomain()
+ * @covers WikiMap::isCurrentWikiDbDomain()
+ * @covers WikiMap::getCurrentWikiDbDomain()
*/
public function testIsCurrentWikiDomain() {
- $this->assertTrue( WikiMap::isCurrentWikiDomain( wfWikiID() ) );
+ $this->assertTrue( WikiMap::isCurrentWikiDbDomain( wfWikiID() ) );
$localDomain = DatabaseDomain::newFromId( wfWikiID() );
$domain1 = new DatabaseDomain(
$domain2 = new DatabaseDomain(
$localDomain->getDatabase(), null, $localDomain->getTablePrefix() );
- $this->assertTrue( WikiMap::isCurrentWikiDomain( $domain1 ), 'Schema ignored' );
- $this->assertTrue( WikiMap::isCurrentWikiDomain( $domain2 ), 'Schema ignored' );
+ $this->assertTrue( WikiMap::isCurrentWikiDbDomain( $domain1 ), 'Schema ignored' );
+ $this->assertTrue( WikiMap::isCurrentWikiDbDomain( $domain2 ), 'Schema ignored' );
- $this->assertTrue( WikiMap::isCurrentWikiDomain( WikiMap::getCurrentWikiDomain() ) );
+ $this->assertTrue( WikiMap::isCurrentWikiDbDomain( WikiMap::getCurrentWikiDbDomain() ) );
}
public function provideIsCurrentWikiId() {
/**
* @dataProvider provideIsCurrentWikiId
* @covers WikiMap::isCurrentWikiId()
- * @covers WikiMap::getCurrentWikiDomain()
- * @covers WikiMap::getWikiIdFromDomain()
+ * @covers WikiMap::getCurrentWikiDbDomain()
+ * @covers WikiMap::getWikiIdFromDbDomain()
*/
public function testIsCurrentWikiId( $wikiId, $db, $schema, $prefix ) {
$this->setMwGlobals(