Abolished $wgDBname as a unique wiki identifier, it doesn't work with the new-fangled...
authorTim Starling <tstarling@users.mediawiki.org>
Wed, 4 Oct 2006 09:06:18 +0000 (09:06 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Wed, 4 Oct 2006 09:06:18 +0000 (09:06 +0000)
Caches for wikis with table prefixes will be lost on upgrade, caches for wikis without table prefixes will be preserved. Custom cache keys in extensions can be migrated at leisure. Extensions which write to core cache keys should be migrated ASAP, as I have done with Special:Makesysop.

46 files changed:
includes/BagOStuff.php
includes/DateFormatter.php
includes/DifferenceEngine.php
includes/FileStore.php
includes/GlobalFunctions.php
includes/Image.php
includes/LinkCache.php
includes/LoadBalancer.php
includes/MemcachedSessions.php
includes/MessageCache.php
includes/ParserCache.php
includes/ProfilerSimpleUDP.php
includes/ProfilerStub.php
includes/ProxyTools.php
includes/Revision.php
includes/Setup.php
includes/Skin.php
includes/SkinTemplate.php
includes/SpecialAllpages.php
includes/SpecialRecentchanges.php
includes/SpecialUserlogin.php
includes/SpecialWatchlist.php
includes/Title.php
includes/User.php
includes/WatchedItem.php
languages/Language.php
languages/LanguageConverter.php
maintenance/FiveUpgrade.inc
maintenance/InitialiseMessages.inc
maintenance/attachLatest.php
maintenance/backup.inc
maintenance/checkUsernames.php
maintenance/cleanupDupes.inc
maintenance/cleanupTable.inc
maintenance/cleanupWatchlist.php
maintenance/createAndPromote.php
maintenance/deleteImageMemcached.php
maintenance/deleteRevision.php
maintenance/dumpInterwiki.inc
maintenance/dumpTextPass.php
maintenance/generateSitemap.php
maintenance/rebuildImages.php
maintenance/refreshImageCount.php
maintenance/stats.php
maintenance/update.php
maintenance/userDupes.inc

index 31d357c..1dc93a2 100644 (file)
@@ -553,11 +553,7 @@ class DBABagOStuff extends BagOStuff {
                        global $wgTmpDirectory;
                        $dir = $wgTmpDirectory;
                }
-               global $wgDBname, $wgDBprefix;
-               $this->mFile = "$dir/mw-cache-$wgDBname";
-               if ( $wgDBprefix ) {
-                       $this->mFile .= '-' . $wgDBprefix;
-               }
+               $this->mFile = "$dir/mw-cache-" . wfWikiID();
                $this->mFile .= '.db';
                $this->mHandler = $handler;
        }
index 99d8be7..dc077fd 100644 (file)
@@ -105,13 +105,13 @@ class DateFormatter
         * @static
         */
        function &getInstance() {
-               global $wgDBname, $wgMemc;
+               global $wgMemc;
                static $dateFormatter = false;
                if ( !$dateFormatter ) {
-                       $dateFormatter = $wgMemc->get( "$wgDBname:dateformatter" );
+                       $dateFormatter = $wgMemc->get( wfMemcKey( 'dateformatter' ) );
                        if ( !$dateFormatter ) {
                                $dateFormatter = new DateFormatter;
-                               $wgMemc->set( "$wgDBname:dateformatter", $dateFormatter, 3600 );
+                               $wgMemc->set( wfMemcKey( 'dateformatter' ), $dateFormatter, 3600 );
                        }
                }
                return $dateFormatter;
index 21ac558..448bcb5 100644 (file)
@@ -297,7 +297,7 @@ CONTROL;
         * Returns false on error
         */
        function getDiffBody() {
-               global $wgMemc, $wgDBname;
+               global $wgMemc;
                $fname = 'DifferenceEngine::getDiffBody';
                wfProfileIn( $fname );
                
@@ -305,7 +305,7 @@ CONTROL;
                $key = false;
                if ( $this->mOldid && $this->mNewid ) {
                        // Try cache
-                       $key = "$wgDBname:diff:oldid:{$this->mOldid}:newid:{$this->mNewid}";
+                       $key = wfMemcKey( 'diff', 'oldid', $this->mOldid, 'newid', $this->mNewid );
                        $difftext = $wgMemc->get( $key );
                        if ( $difftext ) {
                                wfIncrStats( 'diff_cache_hit' );
index 69e4be8..35ebd55 100644 (file)
@@ -62,8 +62,7 @@ class FileStore {
        }
        
        private static function lockName() {
-               global $wgDBname, $wgDBprefix;
-               return "MediaWiki.{$wgDBname}.{$wgDBprefix}FileStore";
+               return 'MediaWiki.' . wfWikiID() . '.FileStore';
        }
        
        /**
index fbd1f31..623f9d3 100644 (file)
@@ -189,11 +189,12 @@ function wfDebug( $text, $logonly = false ) {
  *                     log file is specified, (default true)
  */
 function wfDebugLog( $logGroup, $text, $public = true ) {
-       global $wgDebugLogGroups, $wgDBname;
+       global $wgDebugLogGroups;
        if( $text{strlen( $text ) - 1} != "\n" ) $text .= "\n";
        if( isset( $wgDebugLogGroups[$logGroup] ) ) {
                $time = wfTimestamp( TS_DB );
-               @error_log( "$time $wgDBname: $text", 3, $wgDebugLogGroups[$logGroup] );
+               $wiki = wfWikiID();
+               @error_log( "$time $wiki: $text", 3, $wgDebugLogGroups[$logGroup] );
        } else if ( $public === true ) {
                wfDebug( $text, true );
        }
@@ -1377,7 +1378,7 @@ function swap( &$x, &$y ) {
 }
 
 function wfGetCachedNotice( $name ) {
-       global $wgOut, $parserMemc, $wgDBname;
+       global $wgOut, $parserMemc;
        $fname = 'wfGetCachedNotice';
        wfProfileIn( $fname );
        
@@ -1388,7 +1389,7 @@ function wfGetCachedNotice( $name ) {
                return( false );
        }
        
-       $cachedNotice = $parserMemc->get( $wgDBname . ':' . $name );
+       $cachedNotice = $parserMemc->get( wfMemcKey( $name ) );
        if( is_array( $cachedNotice ) ) {
                if( md5( $notice ) == $cachedNotice['hash'] ) {
                        $notice = $cachedNotice['html'];
@@ -1402,7 +1403,7 @@ function wfGetCachedNotice( $name ) {
        if( $needParse ) {
                if( is_object( $wgOut ) ) {
                        $parsed = $wgOut->parse( $notice );
-                       $parserMemc->set( $wgDBname . ':' . $name, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
+                       $parserMemc->set( wfMemcKey( $name ), array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
                        $notice = $parsed;
                } else {
                        wfDebug( 'wfGetCachedNotice called for ' . $name . ' with no $wgOut available' );
@@ -1541,8 +1542,8 @@ function wfMkdirParents( $fullDir, $mode = 0777 ) {
  * Increment a statistics counter
  */
  function wfIncrStats( $key ) {
-        global $wgDBname, $wgMemc;
-        $key = "$wgDBname:stats:$key";
+        global $wgMemc;
+        $key = wfMemcKey( 'stats', $key );
         if ( is_null( $wgMemc->incr( $key ) ) ) {
                 $wgMemc->add( $key, 1 );
         }
@@ -2022,4 +2023,44 @@ function wfGetAllCallers() {
                array_reverse(debug_backtrace())));
 }
 
+/**
+ * Get a cache key
+ */
+function wfMemcKey( /*... */ ) {
+       global $wgDBprefix, $wgDBname;
+       $args = func_get_args();
+       if ( $wgDBprefix ) {
+               $key = "$wgDBname-$wgDBprefix:" . implode( ':', $args );
+       } else {
+               $key = $wgDBname . ':' . implode( ':', $args );
+       }
+       return $key;
+}
+
+/**
+ * Get a cache key for a foreign DB
+ */
+function wfForeignMemcKey( $db, $prefix /*, ... */ ) {
+       $args = array_slice( func_get_args(), 2 );
+       if ( $prefix ) {
+               $key = "$db-$prefix:" . implode( ':', $args );
+       } else {
+               $key = $db . ':' . implode( ':', $args );
+       }
+       return $key;
+}
+
+/**
+ * Get an ASCII string identifying this wiki
+ * This is used as a prefix in memcached keys
+ */
+function wfWikiID() {
+       global $wgDBprefix, $wgDBname;
+       if ( $wgDBprefix ) {
+               return "$wgDBname-$wgDBprefix";
+       } else {
+               return $wgDBname;
+       }
+}
+
 ?>
index c66c6bb..0754f67 100644 (file)
@@ -121,12 +121,12 @@ class Image
         * Returns an array, first element is the local cache key, second is the shared cache key, if there is one
         */
        function getCacheKeys( ) {
-               global $wgDBname, $wgUseSharedUploads, $wgSharedUploadDBname, $wgCacheSharedUploads;
+               global $wgUseSharedUploads, $wgSharedUploadDBname, $wgCacheSharedUploads;
 
                $hashedName = md5($this->name);
-               $keys = array( "$wgDBname:Image:$hashedName" );
+               $keys = array( wfMemcKey( 'Image', $hashedName ) );
                if ( $wgUseSharedUploads && $wgSharedUploadDBname && $wgCacheSharedUploads ) {
-                       $keys[] = "$wgSharedUploadDBname:Image:$hashedName";
+                       $keys[] = wfForeignMemcKey( $wgSharedUploadDBname, false, 'Image', $hashedName );
                }
                return $keys;
        }
index a7cbe47..8e56225 100644 (file)
@@ -37,8 +37,7 @@ class LinkCache {
        }
 
        /* private */ function getKey( $title ) {
-               global $wgDBname;
-               return $wgDBname.':lc:title:'.$title;
+               return wfMemcKey( 'lc', 'title', $title );
        }
 
        /**
index a374c6b..3e81aea 100644 (file)
@@ -599,14 +599,12 @@ class LoadBalancer {
         * Results are cached for a short time in memcached
         */
        function getLagTimes() {
-               global $wgDBname;
-
                wfProfileIn( __METHOD__ );
                $expiry = 5;
                $requestRate = 10;
 
                global $wgMemc;
-               $times = $wgMemc->get( "$wgDBname:lag_times" );
+               $times = $wgMemc->get( wfMemcKey( 'lag_times' ) );
                if ( $times ) {
                        # Randomly recache with probability rising over $expiry
                        $elapsed = time() - $times['timestamp'];
@@ -634,7 +632,7 @@ class LoadBalancer {
 
                # Add a timestamp key so we know when it was cached
                $times['timestamp'] = time();
-               $wgMemc->set( "$wgDBname:lag_times", $times, $expiry );
+               $wgMemc->set( wfMemcKey( 'lag_times' ), $times, $expiry );
 
                # But don't give the timestamp to the caller
                unset($times['timestamp']);
index af49109..e2dc52c 100644 (file)
@@ -13,8 +13,7 @@
  * @todo document
  */
 function memsess_key( $id ) {
-       global $wgDBname;
-       return "$wgDBname:session:$id";
+       return wfMemcKey( 'session', $id );
 }
 
 /**
index 3859e5f..aa1fa1f 100644 (file)
@@ -58,14 +58,14 @@ class MessageCache {
         * Try to load the cache from a local file
         */
        function loadFromLocal( $hash ) {
-               global $wgLocalMessageCache, $wgDBname;
+               global $wgLocalMessageCache;
 
                $this->mCache = false;
                if ( $wgLocalMessageCache === false ) {
                        return;
                }
 
-               $filename = "$wgLocalMessageCache/messages-$wgDBname";
+               $filename = "$wgLocalMessageCache/messages-" . wfWikiID();
 
                wfSuppressWarnings();
                $file = fopen( $filename, 'r' );
@@ -88,13 +88,13 @@ class MessageCache {
         * Save the cache to a local file
         */
        function saveToLocal( $serialized, $hash ) {
-               global $wgLocalMessageCache, $wgDBname;
+               global $wgLocalMessageCache;
 
                if ( $wgLocalMessageCache === false ) {
                        return;
                }
 
-               $filename = "$wgLocalMessageCache/messages-$wgDBname";
+               $filename = "$wgLocalMessageCache/messages-" . wfWikiID();
                $oldUmask = umask( 0 );
                wfMkdirParents( $wgLocalMessageCache, 0777 );
                umask( $oldUmask );
@@ -111,12 +111,12 @@ class MessageCache {
        }
 
        function loadFromScript( $hash ) {
-               global $wgLocalMessageCache, $wgDBname;
+               global $wgLocalMessageCache;
                if ( $wgLocalMessageCache === false ) {
                        return;
                }
                
-               $filename = "$wgLocalMessageCache/messages-$wgDBname";
+               $filename = "$wgLocalMessageCache/messages-" . wfWikiID();
                
                wfSuppressWarnings();
                $file = fopen( $filename, 'r' );
@@ -129,16 +129,16 @@ class MessageCache {
                if ($hash!=$localHash) {
                        return;
                }
-               require("$wgLocalMessageCache/messages-$wgDBname");
+               require("$wgLocalMessageCache/messages-" . wfWikiID());
        }
        
        function saveToScript($array, $hash) {
-               global $wgLocalMessageCache, $wgDBname;
+               global $wgLocalMessageCache;
                if ( $wgLocalMessageCache === false ) {
                        return;
                }
 
-               $filename = "$wgLocalMessageCache/messages-$wgDBname";
+               $filename = "$wgLocalMessageCache/messages-" . wfWikiID();
                $oldUmask = umask( 0 );
                wfMkdirParents( $wgLocalMessageCache, 0777 );
                umask( $oldUmask );
@@ -361,11 +361,11 @@ class MessageCache {
        }
 
        function replace( $title, $text ) {
-               global $wgLocalMessageCache, $wgLocalMessageCacheSerialized, $parserMemc, $wgDBname;
+               global $wgLocalMessageCache, $wgLocalMessageCacheSerialized, $parserMemc;
 
                $this->lock();
                $this->load();
-               $parserMemc->delete("$wgDBname:sidebar");
+               $parserMemc->delete(wfMemcKey('sidebar'));
                if ( is_array( $this->mCache ) ) {
                        $this->mCache[$title] = $text;
                        $this->mMemc->set( $this->mMemcKey, $this->mCache, $this->mExpiry );
@@ -617,7 +617,7 @@ class MessageCache {
         * Clear all stored messages. Mainly used after a mass rebuild.
         */
        function clear() {
-               global $wgLocalMessageCache, $wgDBname;
+               global $wgLocalMessageCache;
                if( $this->mUseCache ) {
                        # Global cache
                        $this->mMemc->delete( $this->mMemcKey );
index 612790a..1f2e2aa 100644 (file)
@@ -33,7 +33,7 @@ class ParserCache {
        }
 
        function getKey( &$article, &$user ) {
-               global $wgDBname, $action;
+               global $action;
                $hash = $user->getPageRenderingHash();
                if( !$article->mTitle->userCanEdit() ) {
                        // section edit links are suppressed even if the user has them on
@@ -43,7 +43,7 @@ class ParserCache {
                }
                $pageid = intval( $article->getID() );
                $renderkey = (int)($action == 'render');
-               $key = "$wgDBname:pcache:idhash:$pageid-$renderkey!$hash$edit";
+               $key = wfMemcKey( 'pcache', 'idhash', "$pageid-$renderkey!$hash$edit" );
                return $key;
        }
 
index 1eb2c5f..e049051 100644 (file)
@@ -10,7 +10,6 @@ class ProfilerSimpleUDP extends ProfilerSimple {
        function getFunctionReport() {
                global $wgUDPProfilerHost;
                global $wgUDPProfilerPort;
-               global $wgDBname;
 
                if ( $this->mCollated['-total']['real'] < $this->mMinimumTime ) {
                        # Less than minimum, ignore
@@ -22,7 +21,7 @@ class ProfilerSimpleUDP extends ProfilerSimple {
                $plength=0;
                $packet="";
                foreach ($this->mCollated as $entry=>$pfdata) {
-                       $pfline=sprintf ("%s %s %d %f %f %f %f %s\n", $wgDBname,"-",$pfdata['count'],
+                       $pfline=sprintf ("%s %s %d %f %f %f %f %s\n", wfWikiID(),"-",$pfdata['count'],
                                $pfdata['cpu'],$pfdata['cpu_sq'],$pfdata['real'],$pfdata['real_sq'],$entry);
                        $length=strlen($pfline);
                        /* printf("<!-- $pfline -->"); */
index 4cf0aa4..b4f8caf 100644 (file)
@@ -4,20 +4,20 @@
 
 $haveProctitle=function_exists("setproctitle");
 function wfProfileIn( $fn = '' ) {
-       global $hackwhere, $wgDBname, $haveProctitle;
+       global $hackwhere, $haveProctitle;
        if ($haveProctitle) {
                $hackwhere[] = $fn;
-               setproctitle($fn . " [$wgDBname]");
+               setproctitle($fn . ' ['.wfWikiID().']');
        }
 }
 function wfProfileOut( $fn = '' ) {
-       global $hackwhere, $wgDBname, $haveProctitle;
+       global $hackwhere, $haveProctitle;
        if (!$haveProctitle)
                return;
        if (count($hackwhere))
                array_pop($hackwhere);
        if (count($hackwhere))
-               setproctitle($hackwhere[count($hackwhere)-1] . " [$wgDBname]");
+               setproctitle($hackwhere[count($hackwhere)-1] . ' ['.wfWikiID().']');
 }
 function wfGetProfilingOutput( $s, $e ) {}
 function wfProfileClose() {}
index 09a1f81..7974c88 100644 (file)
@@ -75,7 +75,7 @@ function wfGetIP() {
  */
 function wfProxyCheck() {
        global $wgBlockOpenProxies, $wgProxyPorts, $wgProxyScriptPath;
-       global $wgUseMemCached, $wgMemc, $wgDBname, $wgProxyMemcExpiry;
+       global $wgUseMemCached, $wgMemc, $wgProxyMemcExpiry;
        global $wgProxyKey;
 
        if ( !$wgBlockOpenProxies ) {
@@ -87,7 +87,7 @@ function wfProxyCheck() {
        # Get MemCached key
        $skip = false;
        if ( $wgUseMemCached ) {
-               $mcKey = "$wgDBname:proxy:ip:$ip";
+               $mcKey = wfMemcKey( 'proxy', 'ip', $ip );
                $mcValue = $wgMemc->get( $mcKey );
                if ( $mcValue ) {
                        $skip = true;
index e8d802d..bd68e05 100644 (file)
@@ -685,8 +685,8 @@ class Revision {
                wfProfileIn( $fname );
                
                // Caching may be beneficial for massive use of external storage
-               global $wgRevisionCacheExpiry, $wgMemc, $wgDBname;
-               $key = "$wgDBname:revisiontext:textid:" . $this->getTextId();
+               global $wgRevisionCacheExpiry, $wgMemc;
+               $key = wfMemcKey( 'revisiontext', 'textid', $this->getTextId() );
                if( $wgRevisionCacheExpiry ) {
                        $text = $wgMemc->get( $key );
                        if( is_string( $text ) ) {
index d529fea..8fe9ef7 100644 (file)
@@ -145,7 +145,7 @@ $wgLang = new StubUserLang;
 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
 $wgParser = new StubObject( 'wgParser', 'Parser' );
 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache', 
-       array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname) );
+       array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
 
 wfProfileOut( $fname.'-globals' );
 wfProfileIn( $fname.'-User' );
index 074cf2b..1c92ccd 100644 (file)
@@ -1509,14 +1509,14 @@ END;
         * @private
         */
        function buildSidebar() {
-               global $wgDBname, $parserMemc, $wgEnableSidebarCache;
+               global $parserMemc, $wgEnableSidebarCache;
                global $wgLang, $wgContLang;
 
                $fname = 'SkinTemplate::buildSidebar';
 
                wfProfileIn( $fname );
 
-               $key = "{$wgDBname}:sidebar";
+               $key = wfMemcKey( 'sidebar' );
                $cacheSidebar = $wgEnableSidebarCache &&
                        ($wgLang->getCode() == $wgContLang->getCode());
                
index c796cc7..482680e 100644 (file)
@@ -138,7 +138,6 @@ class SkinTemplate extends Skin {
                global $wgMaxCredits, $wgShowCreditsIfMax;
                global $wgPageShowWatchingUsers;
                global $wgUseTrackbacks;
-               global $wgDBname;
                global $wgArticlePath, $wgScriptPath, $wgServer, $wgLang, $wgCanonicalNamespaceNames;
 
                $fname = 'SkinTemplate::outputPage';
@@ -284,7 +283,7 @@ class SkinTemplate extends Skin {
                }
                $newtalks = $wgUser->getNewMessageLinks();
 
-               if (count($newtalks) == 1 && $newtalks[0]["wiki"] === $wgDBname) {
+               if (count($newtalks) == 1 && $newtalks[0]["wiki"] === wfWikiID() ) {
                        $usertitle = $this->mUser->getUserPage();
                        $usertalktitle = $usertitle->getTalkPage();
                        if( !$usertalktitle->equals( $this->mTitle ) ) {
index 08cea92..345c48e 100644 (file)
@@ -94,8 +94,8 @@ function showToplevel ( $namespace = NS_MAIN, $including = false ) {
        $out = "";
        $where = array( 'page_namespace' => $namespace );
 
-       global $wgMemc, $wgDBname;
-       $key = "$wgDBname:allpages:ns:$namespace";
+       global $wgMemc;
+       $key = wfMemcKey( 'allpages', 'ns', $namespace );
        $lines = $wgMemc->get( $key );
 
        if( !is_array( $lines ) ) {
index d3d9453..a85e194 100644 (file)
@@ -319,7 +319,7 @@ function rcFilterByCategories ( &$rows , $categories , $any ) {
 }
 
 function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
-       global $messageMemc, $wgDBname, $wgFeedCacheTimeout;
+       global $messageMemc, $wgFeedCacheTimeout;
        global $wgFeedClasses, $wgTitle, $wgSitename, $wgContLanguageCode;
 
        if( !isset( $wgFeedClasses[$feedFormat] ) ) {
@@ -327,8 +327,8 @@ function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
                return false;
        }
 
-       $timekey = "$wgDBname:rcfeed:$feedFormat:timestamp";
-       $key = "$wgDBname:rcfeed:$feedFormat:limit:$limit:minor:$hideminor";
+       $timekey = wfMemcKey( 'rcfeed', $feedFormat, 'timestamp' );
+       $key = wfMemcKey( 'rcfeed', $feedFormat, 'limit', $limit, 'minor', $hideminor );
 
        $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchanges' ) .
                ' [' . $wgContLanguageCode . ']';
index cc7339f..574579c 100644 (file)
@@ -195,7 +195,7 @@ class LoginForm {
        function addNewAccountInternal() {
                global $wgUser, $wgOut;
                global $wgEnableSorbs, $wgProxyWhitelist;
-               global $wgMemc, $wgAccountCreationThrottle, $wgDBname;
+               global $wgMemc, $wgAccountCreationThrottle;
                global $wgAuth, $wgMinimalPasswordLength;
 
                // If the user passes an invalid domain, something is fishy
@@ -258,7 +258,7 @@ class LoginForm {
                }
 
                if ( $wgAccountCreationThrottle ) {
-                       $key = $wgDBname.':acctcreate:ip:'.$ip;
+                       $key = wfMemcKey( 'acctcreate', 'ip', $ip );
                        $value = $wgMemc->incr( $key );
                        if ( !$value ) {
                                $wgMemc->set( $key, 1, 86400 );
index b24d1e3..3825675 100644 (file)
@@ -17,7 +17,7 @@ require_once( 'SpecialRecentchanges.php' );
  */
 function wfSpecialWatchlist( $par ) {
        global $wgUser, $wgOut, $wgLang, $wgMemc, $wgRequest, $wgContLang;
-       global $wgUseWatchlistCache, $wgWLCacheTimeout, $wgDBname;
+       global $wgUseWatchlistCache, $wgWLCacheTimeout;
        global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
        global $wgEnotifWatchlist;
        $fname = 'wfSpecialWatchlist';
@@ -103,7 +103,7 @@ function wfSpecialWatchlist( $par ) {
        }
 
        if ( $wgUseWatchlistCache ) {
-               $memckey = "$wgDBname:watchlist:id:" . $wgUser->getId();
+               $memckey = wfMemcKey( 'watchlist', 'id', $wgUser->getId() );
                $cache_s = @$wgMemc->get( $memckey );
                if( $cache_s ){
                        $wgOut->addWikiText( wfMsg('wlsaved') );
index cf79780..0e86063 100644 (file)
@@ -392,13 +392,13 @@ class Title {
         * @access public
         */
        function getInterwikiLink( $key )  {
-               global $wgMemc, $wgDBname, $wgInterwikiExpiry;
+               global $wgMemc, $wgInterwikiExpiry;
                global $wgInterwikiCache;
                $fname = 'Title::getInterwikiLink';
 
                $key = strtolower( $key );
 
-               $k = $wgDBname.':interwiki:'.$key;
+               $k = wfMemcKey( 'interwiki', $key );
                if( array_key_exists( $k, Title::$interwikiCache ) ) {
                        return Title::$interwikiCache[$k]->iw_url;
                }
@@ -445,18 +445,18 @@ class Title {
         * @access public
         */
        function getInterwikiCached( $key ) {
-               global $wgDBname, $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
+               global $wgInterwikiCache, $wgInterwikiScopes, $wgInterwikiFallbackSite;
                static $db, $site;
 
                if (!$db)
                        $db=dba_open($wgInterwikiCache,'r','cdb');
                /* Resolve site name */
                if ($wgInterwikiScopes>=3 and !$site) {
-                       $site = dba_fetch("__sites:{$wgDBname}", $db);
+                       $site = dba_fetch('__sites:' . wfWikiID(), $db);
                        if ($site=="")
                                $site = $wgInterwikiFallbackSite;
                }
-               $value = dba_fetch("{$wgDBname}:{$key}", $db);
+               $value = dba_fetch( wfMemcKey( $key ), $db);
                if ($value=='' and $wgInterwikiScopes>=3) {
                        /* try site-level */
                        $value = dba_fetch("_{$site}:{$key}", $db);
@@ -476,7 +476,7 @@ class Title {
                        $s->iw_url=$url;
                        $s->iw_local=(int)$local;
                }
-               Title::$interwikiCache[$wgDBname.':interwiki:'.$key] = $s;
+               Title::$interwikiCache[wfMemcKey( 'interwiki', $key )] = $s;
                return $s->iw_url;
        }
        /**
@@ -488,12 +488,10 @@ class Title {
         * @access public
         */
        function isLocal() {
-               global $wgDBname;
-
                if ( $this->mInterwiki != '' ) {
                        # Make sure key is loaded into cache
                        $this->getInterwikiLink( $this->mInterwiki );
-                       $k = $wgDBname.':interwiki:' . $this->mInterwiki;
+                       $k = wfMemcKey( 'interwiki', $this->mInterwiki );
                        return (bool)(Title::$interwikiCache[$k]->iw_local);
                } else {
                        return true;
@@ -508,13 +506,11 @@ class Title {
         * @access public
         */
        function isTrans() {
-               global $wgDBname;
-
                if ($this->mInterwiki == '')
                        return false;
                # Make sure key is loaded into cache
                $this->getInterwikiLink( $this->mInterwiki );
-               $k = $wgDBname.':interwiki:' . $this->mInterwiki;
+               $k = wfMemcKey( 'interwiki', $this->mInterwiki );
                return (bool)(Title::$interwikiCache[$k]->iw_trans);
        }
 
index 7dc4689..6df9e0c 100644 (file)
@@ -665,7 +665,7 @@ class User {
                                return false;
                }
                
-               global $wgMemc, $wgDBname, $wgRateLimitLog;
+               global $wgMemc, $wgRateLimitLog;
                $fname = 'User::pingLimiter';
                wfProfileIn( $fname );
 
@@ -675,15 +675,15 @@ class User {
                $ip = wfGetIP();
 
                if( isset( $limits['anon'] ) && $id == 0 ) {
-                       $keys["$wgDBname:limiter:$action:anon"] = $limits['anon'];
+                       $keys[wfMemcKey( 'limiter', $action, 'anon' )] = $limits['anon'];
                }
 
                if( isset( $limits['user'] ) && $id != 0 ) {
-                       $keys["$wgDBname:limiter:$action:user:$id"] = $limits['user'];
+                       $keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $limits['user'];
                }
                if( $this->isNewbie() ) {
                        if( isset( $limits['newbie'] ) && $id != 0 ) {
-                               $keys["$wgDBname:limiter:$action:user:$id"] = $limits['newbie'];
+                               $keys[wfMemcKey( 'limiter', $action, 'user', $id )] = $limits['newbie'];
                        }
                        if( isset( $limits['ip'] ) ) {
                                $keys["mediawiki:limiter:$action:ip:$ip"] = $limits['ip'];
@@ -703,7 +703,7 @@ class User {
                                if( $count > $max ) {
                                        wfDebug( "$fname: tripped! $key at $count $summary\n" );
                                        if( $wgRateLimitLog ) {
-                                               @error_log( wfTimestamp( TS_MW ) . ' ' . $wgDBname . ': ' . $this->getName() . " tripped $key at $count $summary\n", 3, $wgRateLimitLog );
+                                               @error_log( wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", 3, $wgRateLimitLog );
                                        }
                                        $triggered = true;
                                } else {
@@ -783,7 +783,7 @@ class User {
         * @static
         */
        function loadFromSession() {
-               global $wgMemc, $wgDBname, $wgCookiePrefix;
+               global $wgMemc, $wgCookiePrefix;
 
                if ( isset( $_SESSION['wsUserID'] ) ) {
                        if ( 0 != $_SESSION['wsUserID'] ) {
@@ -807,7 +807,7 @@ class User {
                }
 
                $passwordCorrect = FALSE;
-               $user = $wgMemc->get( $key = "$wgDBname:user:id:$sId" );
+               $user = $wgMemc->get( $key = wfMemcKey( 'user', 'id', $sId ) );
                if( !is_object( $user ) || $user->mVersion < MW_USER_VERSION ) {
                        # Expire old serialized objects; they may be corrupt.
                        $user = false;
@@ -958,8 +958,8 @@ class User {
                        # Check memcached separately for anons, who have no
                        # entire User object stored in there.
                        if( !$this->mId ) {
-                               global $wgDBname, $wgMemc;
-                               $key = "$wgDBname:newtalk:ip:" . $this->getName();
+                               global $wgMemc;
+                               $key = wfMemcKey( 'newtalk', 'ip', $this->getName() );
                                $newtalk = $wgMemc->get( $key );
                                if( is_integer( $newtalk ) ) {
                                        $this->mNewtalk = (bool)$newtalk;
@@ -979,7 +979,6 @@ class User {
         * Return the talk page(s) this user has new messages on.
         */
        function getNewMessageLinks() {
-       global  $wgDBname;
                $talks = array();
                if (!wfRunHooks('UserRetrieveNewTalks', array(&$this, &$talks)))
                        return $talks;
@@ -988,7 +987,7 @@ class User {
                        return array();
                $up = $this->getUserPage();
                $utp = $up->getTalkPage();
-               return array(array("wiki" => $wgDBname, "link" => $utp->getLocalURL()));
+               return array(array("wiki" => wfWikiID(), "link" => $utp->getLocalURL()));
        }
 
                
@@ -1083,8 +1082,8 @@ class User {
                        if( $this->isAnon() ) {
                                // Anons have a separate memcached space, since
                                // user records aren't kept for them.
-                               global $wgDBname, $wgMemc;
-                               $key = "$wgDBname:newtalk:ip:$val";
+                               global $wgMemc;
+                               $key = wfMemcKey( 'newtalk', 'ip', $val );
                                $wgMemc->set( $key, $val ? 1 : 0 );
                        } else {
                                if( $val ) {
@@ -1115,8 +1114,8 @@ class User {
         */
        private function clearUserCache() {
                if( $this->mId ) {
-                       global $wgMemc, $wgDBname;
-                       $wgMemc->delete( "$wgDBname:user:id:$this->mId" );
+                       global $wgMemc;
+                       $wgMemc->delete( wfMemcKey( 'user', 'id', $this->mId ) );
                }
        }
 
@@ -1164,7 +1163,7 @@ class User {
 
        # Set the random token (used for persistent authentication)
        function setToken( $token = false ) {
-               global $wgSecretKey, $wgProxyKey, $wgDBname;
+               global $wgSecretKey, $wgProxyKey;
                if ( !$token ) {
                        if ( $wgSecretKey ) {
                                $key = $wgSecretKey;
@@ -1173,7 +1172,7 @@ class User {
                        } else {
                                $key = microtime();
                        }
-                       $this->mToken = md5( $key . mt_rand( 0, 0x7fffffff ) . $wgDBname . $this->mId );
+                       $this->mToken = md5( $key . mt_rand( 0, 0x7fffffff ) . wfWikiID() . $this->mId );
                } else {
                        $this->mToken = $token;
                }
index 3885bb9..788774f 100644 (file)
@@ -35,8 +35,7 @@ class WatchedItem {
         * Returns the memcached key for this item
         */
        function watchKey() {
-               global $wgDBname;
-               return "$wgDBname:watchlist:user:$this->id:page:$this->ns:$this->ti";
+               return wfMemcKey( 'watchlist', 'user', $this->id, 'page', $this->ns, $this->ti );
        }
 
        /**
index 6b984eb..454d60e 100644 (file)
@@ -26,7 +26,6 @@ global $wgLanguageNames;
 require_once( 'Names.php' );
 
 global $wgInputEncoding, $wgOutputEncoding;
-global $wgDBname, $wgMemc;
 
 /**
  * These are always UTF-8, they exist only for backwards compatibility
@@ -1462,7 +1461,7 @@ class Language {
         */
        static function loadLocalisation( $code, $disableCache = false ) {
                static $recursionGuard = array();
-               global $wgMemc, $wgDBname;
+               global $wgMemc;
 
                if ( !$code ) {
                        throw new MWException( "Invalid language code requested" );
@@ -1486,7 +1485,7 @@ class Language {
                        }
 
                        # Try the global cache
-                       $memcKey = "$wgDBname:localisation:$code";
+                       $memcKey = wfMemcKey('localisation', $code );
                        $cache = $wgMemc->get( $memcKey );
                        if ( $cache ) {
                                $expired = false;
index f24332e..a949ad4 100644 (file)
@@ -38,13 +38,12 @@ class LanguageConverter {
                                                                $variantfallbacks=array(),
                                                                $markup=array(),
                                                                $flags = array()) {
-               global $wgDBname;
                global $wgLegalTitleChars;
                $this->mLangObj = $langobj;
                $this->mMainLanguageCode = $maincode;
                $this->mVariants = $variants;
                $this->mVariantFallbacks = $variantfallbacks;
-               $this->mCacheKey = $wgDBname . ":conversiontables";
+               $this->mCacheKey = wfMemcKey( 'conversiontables' );
                $m = array('begin'=>'-{', 'flagsep'=>'|', 'codesep'=>':',
                                   'varsep'=>';', 'end'=>'}-');
                $this->mMarkup = array_merge($m, $markup);
index c9fe2ee..4bbf073 100644 (file)
@@ -159,8 +159,7 @@ class FiveUpgrade {
         * @access private
         */
        function log( $message ) {
-               global $wgDBname;
-               echo $wgDBname . ' ' . wfTimestamp( TS_DB ) . ': ' . $message . "\n";
+               echo wfWikiID() . ' ' . wfTimestamp( TS_DB ) . ': ' . $message . "\n";
                flush();
        }
 
index ab0f3c5..22e26b9 100644 (file)
@@ -72,7 +72,7 @@ function initialiseMessages( $overwrite = false, $messageArray = false, $outputC
 function initialiseMessagesReal( $overwrite = false, $messageArray = false, $outputCallback = false ) {
        global $wgContLang, $wgScript, $wgServer, $wgLanguageCode;
        global $wgOut, $wgArticle, $wgUser;
-       global $wgMessageCache, $wgMemc, $wgDBname, $wgUseMemCached;
+       global $wgMessageCache, $wgMemc, $wgUseMemCached;
 
        # Initialise $wgOut and $wgUser for a command line script
        $wgOut->disable();
index 024a4fa..f4c11c0 100644 (file)
@@ -47,17 +47,17 @@ while( $row = $dbw->fetchObject( $result ) ) {
                array( 'rev_page' => $pageId ),
                $fname );
        if( !$latestTime ) {
-               echo "$wgDBname $pageId [[$name]] can't find latest rev time?!\n";
+               echo wfWikiID()." $pageId [[$name]] can't find latest rev time?!\n";
                continue;
        }
 
        $revision = Revision::loadFromTimestamp( $dbw, $title, $latestTime );
        if( is_null( $revision ) ) {
-               echo "$wgDBname $pageId [[$name]] latest time $latestTime, can't find revision id\n";
+               echo wfWikiID()." $pageId [[$name]] latest time $latestTime, can't find revision id\n";
                continue;
        }
        $id = $revision->getId();
-       echo "$wgDBname $pageId [[$name]] latest time $latestTime, rev id $id\n";
+       echo wfWikiID()." $pageId [[$name]] latest time $latestTime, rev id $id\n";
        if( $fixit ) {
                $article = new Article( $title );
                $article->updateRevisionOn( $dbw, $revision );
index 734a132..d40636a 100644 (file)
@@ -262,9 +262,8 @@ class BackupDumper {
                                $revrate = '-';
                                $etats = '-';
                        }
-                       global $wgDBname;
                        $this->progress( sprintf( "%s: %s %d pages (%0.3f/sec), %d revs (%0.3f/sec), ETA %s [max %d]",
-                               $now, $wgDBname, $this->pageCount, $rate, $this->revCount, $revrate, $etats, $this->maxCount ) );
+                               $now, wfWikiID(), $this->pageCount, $rate, $this->revCount, $revrate, $etats, $this->maxCount ) );
                }
        }
 
index b577ebc..4c0ecdc 100644 (file)
@@ -10,7 +10,6 @@ class checkUsernames {
                $this->log = fopen( '/home/wikipedia/logs/checkUsernames.log', 'at' );
        }
        function main() {
-               global $wgDBname;
                $fname = 'checkUsernames::main';
 
                $dbr =& wfGetDB( DB_SLAVE );
@@ -21,10 +20,9 @@ class checkUsernames {
                        $fname
                );
 
-               #fwrite( $this->stderr, "Checking $wgDBname\n" );
                while ( $row = $dbr->fetchObject( $res ) ) {
                        if ( ! User::isValidUserName( $row->user_name ) ) {
-                               $out = sprintf( "%s: %6d: '%s'\n", $wgDBname, $row->user_id, $row->user_name );
+                               $out = sprintf( "%s: %6d: '%s'\n", wfWikiID(), $row->user_id, $row->user_name );
                                fwrite( $this->stderr, $out );
                                fwrite( $this->log, $out );
                        }
index 18daab0..5db6bb3 100644 (file)
@@ -113,19 +113,18 @@ END
 }
 
 function checkDupes( $fixthem = false, $indexonly = false ) {
-       global $wgDBname;
        $dbw =& wfGetDB( DB_MASTER );
        if( $dbw->indexExists( 'cur', 'name_title' ) &&
            $dbw->indexUnique( 'cur', 'name_title' ) ) {
-               echo "$wgDBname: cur table has the current unique index; no duplicate entries.\n";
+               echo wfWikiID().": cur table has the current unique index; no duplicate entries.\n";
        } elseif( $dbw->indexExists( 'cur', 'name_title_dup_prevention' ) ) {
-               echo "$wgDBname: cur table has a temporary name_title_dup_prevention unique index; no duplicate entries.\n";
+               echo wfWikiID().": cur table has a temporary name_title_dup_prevention unique index; no duplicate entries.\n";
        } else {
-               echo "$wgDBname: cur table has the old non-unique index and may have duplicate entries.\n";
+               echo wfWikiID().": cur table has the old non-unique index and may have duplicate entries.\n";
                if( !$indexonly ) {
                        fixDupes( $fixthem );
                }
        }
 }
 
-?>
\ No newline at end of file
+?>
index 265eca9..cc551bc 100644 (file)
@@ -44,9 +44,8 @@ abstract class TableCleanup extends FiveUpgrade {
                $estimatedTotalTime = $delta / $portion;
                $eta = $this->startTime + $estimatedTotalTime;
 
-               global $wgDBname;
                printf( "%s %s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec <%.2f%% updated>\n",
-                       $wgDBname,
+                       wfWikiID(),
                        wfTimestamp( TS_DB, intval( $now ) ),
                        $portion * 100.0,
                        $this->table,
@@ -84,4 +83,4 @@ abstract class TableCleanup extends FiveUpgrade {
        
 }
 
-?>
\ No newline at end of file
+?>
index d2925db..027859a 100644 (file)
@@ -70,9 +70,8 @@ class WatchlistCleanup extends FiveUpgrade {
                $estimatedTotalTime = $delta / $portion;
                $eta = $this->startTime + $estimatedTotalTime;
 
-               global $wgDBname;
                printf( "%s %s: %6.2f%% done on %s; ETA %s [%d/%d] %.2f/sec <%.2f%% updated>\n",
-                       $wgDBname,
+                       wfWikiID(),
                        wfTimestamp( TS_DB, intval( $now ) ),
                        $portion * 100.0,
                        $this->table,
index df29c11..43ddcdd 100644 (file)
@@ -18,8 +18,7 @@ if( !count( $args ) == 2 ) {
 $username = $args[0];
 $password = $args[1];
 
-global $wgDBname;
-echo( "{$wgDBname}: Creating and promoting User:{$username}..." );
+echo( wfWikiID() . ": Creating and promoting User:{$username}..." );
 
 # Validate username and check it doesn't exist
 $user = User::newFromName( $username );
@@ -45,4 +44,4 @@ $ssu->doUpdate();
 
 echo( "done.\n" );
 
-?>
\ No newline at end of file
+?>
index 4e17d21..6af0e3a 100644 (file)
@@ -14,7 +14,7 @@ class DeleteImageCache {
        }
 
        function main() {
-               global $wgMemc, $wgDBname;
+               global $wgMemc;
                $fname = 'DeleteImageCache::main';
 
                ini_set( 'display_errors', false );
@@ -32,9 +32,9 @@ class DeleteImageCache {
 
                while ( $row = $dbr->fetchObject( $res ) ) {
                        if ($i % $this->report == 0)
-                               printf("%s: %13s done (%s)\n", $wgDBname, "$i/$total", wfPercent( $i / $total * 100 ));
+                               printf("%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ));
                        $md5 = md5( $row->img_name );
-                       $wgMemc->delete( "$wgDBname:Image:$md5" );
+                       $wgMemc->delete( wfMemcKey( 'Image', $md5 ) );
 
                        if ($this->sleep != 0)
                                usleep( $this->sleep );
index e7d005b..eb65e23 100644 (file)
@@ -8,7 +8,7 @@ if ( count( $args ) == 0 ) {
        exit(1);
 }
 
-echo "Deleting revision(s) " . implode( ',', $args ) . " from $wgDBname...\n";
+echo "Deleting revision(s) " . implode( ',', $args ) . " from ".wfWikiID()."...\n";
 
 $affected = 0;
 foreach ( $args as $revID ) {
index f7a56ee..2039f2d 100644 (file)
@@ -31,7 +31,7 @@ class Site {
 }
 
 function getRebuildInterwikiDump() {
-       global $langlist, $languageAliases, $prefixRewrites, $wgDBname;
+       global $langlist, $languageAliases, $prefixRewrites;
 
        # Multi-language sites
        # db suffix => db suffix, iw prefix, hostname
index b6cbc01..8c1563a 100644 (file)
@@ -190,9 +190,8 @@ class TextPassDumper extends BackupDumper {
                                $etats = '-';
                                $fetchrate = '-';
                        }
-                       global $wgDBname;
                        $this->progress( sprintf( "%s: %s %d pages (%0.3f/sec), %d revs (%0.3f/sec), %0.1f%% prefetched, ETA %s [max %d]",
-                               $now, $wgDBname, $this->pageCount, $rate, $this->revCount, $revrate, $fetchrate, $etats, $this->maxCount ) );
+                               $now, wfWikiID(), $this->pageCount, $rate, $this->revCount, $revrate, $fetchrate, $etats, $this->maxCount ) );
                }
        }
 
index 2cf8312..a0b6979 100644 (file)
@@ -145,7 +145,7 @@ class GenerateSitemap {
         * @param bool $compress Whether to compress the sitemap files
         */
        function GenerateSitemap( $fspath, $path, $compress ) {
-               global $wgDBname, $wgScriptPath;
+               global $wgScriptPath;
 
                $this->url_limit = 50000;
                $this->size_limit = pow( 2, 20 ) * 10;
@@ -157,7 +157,7 @@ class GenerateSitemap {
                $this->dbr =& wfGetDB( DB_SLAVE );
                $this->generateNamespaces();
                $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() );
-               $this->findex = fopen( "{$this->fspath}sitemap-index-$wgDBname.xml", 'wb' );
+               $this->findex = fopen( "{$this->fspath}sitemap-index-" . wfWikiID() . ".xml", 'wb' );
        }
 
        /**
@@ -232,7 +232,7 @@ class GenerateSitemap {
         * @access public
         */
        function main() {
-               global $wgDBname, $wgContLang;
+               global $wgContLang;
 
                fwrite( $this->findex, $this->openIndex() );
 
@@ -314,11 +314,8 @@ class GenerateSitemap {
         * @return string
         */
        function sitemapFilename( $namespace, $count ) {
-               global $wgDBname;
-
                $ext = $this->compress ? '.gz' : '';
-
-               return "sitemap-$wgDBname-NS_$namespace-$count.xml$ext";
+               return "sitemap-".wfWikiID()."-NS_$namespace-$count.xml$ext";
        }
 
        /**
index 4547709..38b89a4 100644 (file)
@@ -125,8 +125,8 @@ class ImageBuilder extends FiveUpgrade {
                // Fill in the new image info fields
                $info = $this->imageInfo( $row->img_name );
 
-               global $wgMemc, $wgDBname;
-               $key = $wgDBname . ":Image:" . md5( $row->img_name );
+               global $wgMemc;
+               $key = wfMemcKey( "Image", md5( $row->img_name ) );
                $wgMemc->delete( $key );
 
                return array(
index 15ce2b9..88ac3c5 100644 (file)
@@ -10,7 +10,7 @@ $dbw =& wfGetDB( DB_MASTER );
 // Load the current value from the master
 $count = $dbw->selectField( 'site_stats', 'ss_images' );
 
-echo "$wgDBname: forcing ss_images to $count\n";
+echo wfWikiID().": forcing ss_images to $count\n";
 
 // First set to NULL so that it changes on the master
 $dbw->update( 'site_stats',
@@ -22,4 +22,4 @@ $dbw->update( 'site_stats',
        array( 'ss_images' => $count ),
        array( 'ss_row_id' => 1 ) );
 
-?>
\ No newline at end of file
+?>
index 8ebc382..bb19e67 100644 (file)
@@ -2,8 +2,8 @@
 require_once('commandLine.inc');
 
 print "Requests\n";
-$session = intval($wgMemc->get("$wgDBname:stats:request_with_session"));
-$noSession = intval($wgMemc->get("$wgDBname:stats:request_without_session"));
+$session = intval($wgMemc->get(wfMemcKey('stats','request_with_session')));
+$noSession = intval($wgMemc->get(wfMemcKey('stats','request_without_session')));
 $total = $session + $noSession;
 printf( "with session:      %-10d %6.2f%%\n", $session, $session/$total*100 );
 printf( "without session:   %-10d %6.2f%%\n", $noSession, $noSession/$total*100 );
@@ -11,11 +11,11 @@ printf( "total:             %-10d %6.2f%%\n", $total, 100 );
 
 
 print "\nParser cache\n";
-$hits = intval($wgMemc->get("$wgDBname:stats:pcache_hit"));
-$invalid = intval($wgMemc->get("$wgDBname:stats:pcache_miss_invalid"));
-$expired = intval($wgMemc->get("$wgDBname:stats:pcache_miss_expired"));
-$absent = intval($wgMemc->get("$wgDBname:stats:pcache_miss_absent"));
-$stub = intval($wgMemc->get("$wgDBname:stats:pcache_miss_stub"));
+$hits = intval($wgMemc->get(wfMemcKey('stats','pcache_hit')));
+$invalid = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_invalid')));
+$expired = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_expired')));
+$absent = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_absent')));
+$stub = intval($wgMemc->get(wfMemcKey('stats','pcache_miss_stub')));
 $total = $hits + $invalid + $expired + $absent + $stub;
 printf( "hits:              %-10d %6.2f%%\n", $hits, $hits/$total*100 );
 printf( "invalid:           %-10d %6.2f%%\n", $invalid, $invalid/$total*100 );
@@ -24,18 +24,18 @@ printf( "absent:            %-10d %6.2f%%\n", $absent, $absent/$total*100 );
 printf( "stub threshold:    %-10d %6.2f%%\n", $stub, $stub/$total*100 );
 printf( "total:             %-10d %6.2f%%\n", $total, 100 );
 
-$hits = intval($wgMemc->get("$wgDBname:stats:image_cache_hit"));
-$misses = intval($wgMemc->get("$wgDBname:stats:image_cache_miss"));
-$updates = intval($wgMemc->get("$wgDBname:stats:image_cache_update"));
+$hits = intval($wgMemc->get(wfMemcKey('stats','image_cache_hit')));
+$misses = intval($wgMemc->get(wfMemcKey('stats','image_cache_miss')));
+$updates = intval($wgMemc->get(wfMemcKey('stats','image_cache_update')));
 $total = $hits + $misses;
 print("\nImage cache\n");
 printf( "hits:              %-10d %6.2f%%\n", $hits, $hits/$total*100 );
 printf( "misses:            %-10d %6.2f%%\n", $misses, $misses/$total*100 );
 printf( "updates:           %-10d\n", $updates );
 
-$hits = intval($wgMemc->get("$wgDBname:stats:diff_cache_hit"));
-$misses = intval($wgMemc->get("$wgDBname:stats:diff_cache_miss"));
-$uncacheable = intval($wgMemc->get("$wgDBname:stats:diff_uncacheable"));
+$hits = intval($wgMemc->get(wfMemcKey('stats','diff_cache_hit')));
+$misses = intval($wgMemc->get(wfMemcKey('stats','diff_cache_miss')));
+$uncacheable = intval($wgMemc->get(wfMemcKey('stats','diff_uncacheable')));
 $total = $hits + $misses + $uncacheable;
 print("\nDiff cache\n");
 printf( "hits:              %-10d %6.2f%%\n", $hits, $hits/$total*100 );
index 1d24aa8..d2dcbf9 100644 (file)
@@ -15,7 +15,6 @@ require_once( "commandLine.inc" );
 require_once( "updaters.inc" );
 $wgTitle = Title::newFromText( "MediaWiki database updater" );
 $dbclass = 'Database' . ucfirst( $wgDBtype ) ;
-$dbc = new $dbclass;
 
 echo( "MediaWiki {$wgVersion} Updater\n\n" );
 
@@ -31,7 +30,7 @@ if( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) {
 
 # Attempt to connect to the database as a privileged user
 # This will vomit up an error if there are permissions problems
-$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
+$wgDatabase = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
 
 if( !$wgDatabase->isOpen() ) {
        # Appears to have failed
@@ -40,7 +39,7 @@ if( !$wgDatabase->isOpen() ) {
        exit();
 }
 
-print "Going to run database updates for $wgDBname\n";
+print "Going to run database updates for ".wfWikiID()."\n";
 print "Depending on the size of your database this may take a while!\n";
 
 if( !isset( $options['quick'] ) ) {
index f66051d..e632f73 100644 (file)
@@ -79,10 +79,8 @@ class UserDupes {
         * @return bool
         */
        function checkDupes( $doDelete = false ) {
-               global $wgDBname;
-
                if( $this->hasUniqueIndex() ) {
-                       echo "$wgDBname already has a unique index on its user table.\n";
+                       echo wfWikiID()." already has a unique index on its user table.\n";
                        return true;
                }
 
@@ -92,7 +90,7 @@ class UserDupes {
                $dupes = $this->getDupes();
                $count = count( $dupes );
 
-               echo "Found $count accounts with duplicate records on $wgDBname.\n";
+               echo "Found $count accounts with duplicate records on ".wfWikiID().".\n";
                $this->trimmed    = 0;
                $this->reassigned = 0;
                $this->failed     = 0;
@@ -114,9 +112,9 @@ class UserDupes {
 
                if( $this->trimmed > 0 ) {
                        if( $doDelete ) {
-                               echo "$this->trimmed duplicate user records were deleted from $wgDBname.\n";
+                               echo "$this->trimmed duplicate user records were deleted from ".wfWikiID().".\n";
                        } else {
-                               echo "$this->trimmed duplicate user accounts were found on $wgDBname which can be removed safely.\n";
+                               echo "$this->trimmed duplicate user accounts were found on ".wfWikiID()." which can be removed safely.\n";
                        }
                }
 
@@ -325,4 +323,4 @@ class UserDupes {
 }
 
 
-?>
\ No newline at end of file
+?>