Use WikiMap methods for wiki ID logic in more places
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 21 Oct 2018 07:09:07 +0000 (00:09 -0700)
committerKrinkle <krinklemail@gmail.com>
Mon, 29 Oct 2018 22:02:00 +0000 (22:02 +0000)
Change-Id: I25b53576a8fecb7cfb0e4d684f064bebf6c968fc

includes/debug/logger/LegacyLogger.php
includes/debug/logger/monolog/WikiProcessor.php
includes/rcfeed/MachineReadableRCFeedFormatter.php
includes/user/User.php

index 9d0789c..20a7c81 100644 (file)
@@ -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;
index db5b9bf..cb95be6 100644 (file)
@@ -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'] ) ) {
index a90d648..71f6854 100644 (file)
@@ -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 );
        }
index 8cbedb9..3f2378f 100644 (file)
@@ -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
+                       ]
+               ];
        }
 
        /**