Followup r95396
authorSam Reed <reedy@users.mediawiki.org>
Wed, 31 Aug 2011 15:00:23 +0000 (15:00 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 31 Aug 2011 15:00:23 +0000 (15:00 +0000)
Swap $wgGlobalDB for $wgGlobalDatabase

includes/BacklinkCache.php
includes/LinksUpdate.php

index 978abec..4de4afb 100644 (file)
@@ -180,8 +180,8 @@ class BacklinkCache {
         */
        public function getDistantTemplateLinks( ) {
                global $wgGlobalDatabase, $wgLocalInterwiki;
-               
-               $dbr = $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
+
+               $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
                $res = $dbr->select(
                        array( 'globaltemplatelinks', 'globalinterwiki' ),
                        array( 'gtl_from_wiki', 'gtl_from_page', 'gtl_from_title', 'giw_prefix' ),
@@ -303,7 +303,7 @@ class BacklinkCache {
         */
        public function partition( $table, $batchSize ) {
 
-               // 1) try partition cache ... 
+               // 1) try partition cache ...
 
                if ( isset( $this->partitionCache[$table][$batchSize] ) ) {
                        wfDebug( __METHOD__ . ": got from partition cache\n" );
@@ -358,7 +358,7 @@ class BacklinkCache {
         * Partition a DB result with backlinks in it into batches
         * @param $res ResultWrapper database result
         * @param $batchSize integer
-        * @return array @see 
+        * @return array @see
         */
        protected function partitionResult( $res, $batchSize ) {
                $batches = array();
index da77601..72bd2e6 100644 (file)
@@ -155,8 +155,8 @@ class LinksUpdate {
                        $this->getTemplateInsertions( $existing ) );
 
                # Distant template links
-               global $wgGlobalDB;
-               if ( $wgGlobalDB ) {
+               global $wgGlobalDatabase;
+               if ( $wgGlobalDatabase ) {
                        $existing = $this->getDistantExistingTemplates();
                        $this->incrSharedTableUpdate( 'globaltemplatelinks', 'gtl',
                                $this->getDistantTemplateDeletions( $existing ),
@@ -400,12 +400,10 @@ class LinksUpdate {
         * @private
         */
        function incrSharedTableUpdate( $table, $prefix, $deletions, $insertions ) {
+               global $wgWikiID, $wgGlobalDatabase;
 
-               global $wgWikiID;
-               global $wgGlobalDB;
-
-               if ( $wgGlobalDB ) {
-                       $dbw = wfGetDB( DB_MASTER, array(), $wgGlobalDB );
+               if ( $wgGlobalDatabase ) {
+                       $dbw = wfGetDB( DB_MASTER, array(), $wgGlobalDatabase );
                        $where = array( "{$prefix}_from_wiki" => $wgWikiID,
                                                        "{$prefix}_from_page" => $this->mId
                                        );
@@ -799,14 +797,14 @@ class LinksUpdate {
         */
        function getDistantExistingTemplates() {
                global $wgWikiID;
-               global $wgGlobalDB;
+               global $wgGlobalDatabase;
 
                $arr = array();
-               if ( $wgGlobalDB ) {
-                       $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDB );
+               if ( $wgGlobalDatabase ) {
+                       $dbr = wfGetDB( DB_SLAVE, array(), $wgGlobalDatabase );
                        $res = $dbr->select( 'globaltemplatelinks', array( 'gtl_to_wiki', 'gtl_to_namespace', 'gtl_to_title' ),
                                array( 'gtl_from_wiki' => $wgWikiID, 'gtl_from_page' => $this->mId ), __METHOD__, $this->mOptions );
-                       while ( $row = $dbr->fetchObject( $res ) ) {
+                       foreach ( $res as $row ) {
                                if ( !isset( $arr[$row->gtl_to_wiki] ) ) {
                                        $arr[$row->gtl_to_wiki] = array();
                                }