From dbccb3a361b2cfb7f470786b268295be1aec5109 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 21 Oct 2018 00:09:07 -0700 Subject: [PATCH] Use WikiMap methods for wiki ID logic in more places Change-Id: I25b53576a8fecb7cfb0e4d684f064bebf6c968fc --- includes/debug/logger/LegacyLogger.php | 5 +++-- includes/debug/logger/monolog/WikiProcessor.php | 4 +++- includes/rcfeed/MachineReadableRCFeedFormatter.php | 2 +- includes/user/User.php | 8 +++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/includes/debug/logger/LegacyLogger.php b/includes/debug/logger/LegacyLogger.php index 9d0789c4dc..20a7c81a3b 100644 --- a/includes/debug/logger/LegacyLogger.php +++ b/includes/debug/logger/LegacyLogger.php @@ -22,6 +22,7 @@ namespace MediaWiki\Logger; use DateTimeZone; use Exception; +use WikiMap; use MWDebug; use MWExceptionHandler; use Psr\Log\AbstractLogger; @@ -306,7 +307,7 @@ class LegacyLogger extends AbstractLogger { $date = $d->format( 'D M j G:i:s T Y' ); $host = wfHostname(); - $wiki = wfWikiID(); + $wiki = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ); $text = "{$date}\t{$host}\t{$wiki}\t{$message}\n"; return $text; @@ -322,7 +323,7 @@ class LegacyLogger extends AbstractLogger { */ protected static function formatAsWfDebugLog( $channel, $message, $context ) { $time = wfTimestamp( TS_DB ); - $wiki = wfWikiID(); + $wiki = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ); $host = wfHostname(); $text = "{$time} {$host} {$wiki}: {$message}\n"; return $text; diff --git a/includes/debug/logger/monolog/WikiProcessor.php b/includes/debug/logger/monolog/WikiProcessor.php index db5b9bf669..cb95be63a1 100644 --- a/includes/debug/logger/monolog/WikiProcessor.php +++ b/includes/debug/logger/monolog/WikiProcessor.php @@ -20,6 +20,8 @@ namespace MediaWiki\Logger\Monolog; +use WikiMap; + /** * Annotate log records with request-global metadata, such as the hostname, * wiki / request ID, and MediaWiki version. @@ -36,7 +38,7 @@ class WikiProcessor { public function __invoke( array $record ) { global $wgVersion; $record['extra']['host'] = wfHostname(); - $record['extra']['wiki'] = wfWikiID(); + $record['extra']['wiki'] = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ); $record['extra']['mwversion'] = $wgVersion; $record['extra']['reqId'] = \WebRequest::getRequestId(); if ( wfIsCLI() && isset( $_SERVER['argv'] ) ) { diff --git a/includes/rcfeed/MachineReadableRCFeedFormatter.php b/includes/rcfeed/MachineReadableRCFeedFormatter.php index a90d648eb3..71f6854bdb 100644 --- a/includes/rcfeed/MachineReadableRCFeedFormatter.php +++ b/includes/rcfeed/MachineReadableRCFeedFormatter.php @@ -125,7 +125,7 @@ abstract class MachineReadableRCFeedFormatter implements RCFeedFormatter { $packet['server_name'] = $wgServerName; $packet['server_script_path'] = $wgScriptPath ?: '/'; - $packet['wiki'] = wfWikiID(); + $packet['wiki'] = WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ); return $this->formatArray( $packet ); } diff --git a/includes/user/User.php b/includes/user/User.php index 8cbedb95eb..3f2378f1d2 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -2622,7 +2622,13 @@ class User implements IDBAccessObject, UserIdentity { $this->isAnon() ? [ 'user_ip' => $this->getName() ] : [ 'user_id' => $this->getId() ], __METHOD__ ); $rev = $timestamp ? Revision::loadFromTimestamp( $dbr, $utp, $timestamp ) : null; - return [ [ 'wiki' => wfWikiID(), 'link' => $utp->getLocalURL(), 'rev' => $rev ] ]; + return [ + [ + 'wiki' => WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ), + 'link' => $utp->getLocalURL(), + 'rev' => $rev + ] + ]; } /** -- 2.20.1