r70984 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70983‎ | r70984 | r70985 >
Date:20:27, 12 August 2010
Author:platonides
Status:ok
Tags:
Comment:
Use a class member instead of a global for keeping slaveIndexes.
Modified paths:
  • /trunk/phase3/maintenance/fixSlaveDesync.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/fixSlaveDesync.php
@@ -28,11 +28,11 @@
2929 }
3030
3131 public function execute() {
32 - global $slaveIndexes, $wgDBservers;
33 - $slaveIndexes = array();
 32+ global $wgDBservers;
 33+ $this->slaveIndexes = array();
3434 for ( $i = 1; $i < count( $wgDBservers ); $i++ ) {
3535 if ( wfGetLB()->isNonZeroLoad( $i ) ) {
36 - $slaveIndexes[] = $i;
 36+ $this->slaveIndexes[] = $i;
3737 }
3838 }
3939
@@ -67,8 +67,7 @@
6868 }
6969 $this->output( "\n" );
7070
71 - global $slaveIndexes;
72 - foreach ( $slaveIndexes as $i ) {
 71+ foreach ( $this->slaveIndexes as $i ) {
7372 $db = wfGetDB( $i );
7473 $res = $db->select( 'page', array( 'page_id', 'page_latest' ), array( 'page_id<6054123' ), __METHOD__ );
7574 foreach ( $res as $row ) {
@@ -87,8 +86,6 @@
8887 * @param $pageID int The page_id to fix
8988 */
9089 private function desyncFixPage( $pageID ) {
91 - global $slaveIndexes;
92 -
9390 # Check for a corrupted page_latest
9491 $dbw = wfGetDB( DB_MASTER );
9592 $dbw->begin();
@@ -96,7 +93,7 @@
9794 __METHOD__, 'FOR UPDATE' );
9895 # list( $masterFile, $masterPos ) = $dbw->getMasterPos();
9996 $found = false;
100 - foreach ( $slaveIndexes as $i ) {
 97+ foreach ( $this->slaveIndexes as $i ) {
10198 $db = wfGetDB( $i );
10299 /*
103100 if ( !$db->masterPosWait( $masterFile, $masterPos, 10 ) ) {
@@ -170,7 +167,7 @@
171168 $dbw->insert( 'revision', get_object_vars( $row ), __METHOD__, 'IGNORE' );
172169 }
173170 } else {
174 - foreach ( $slaveIndexes as $i ) {
 171+ foreach ( $this->slaveIndexes as $i ) {
175172 $db = wfGetDB( $i );
176173 $db->insert( 'revision', get_object_vars( $row ), __METHOD__, 'IGNORE' );
177174 }
@@ -181,7 +178,7 @@
182179 if ( $toMaster ) {
183180 $dbw->insert( 'text', get_object_vars( $row ), __METHOD__, 'IGNORE' );
184181 } else {
185 - foreach ( $slaveIndexes as $i ) {
 182+ foreach ( $this->slaveIndexes as $i ) {
186183 $db = wfGetDB( $i );
187184 $db->insert( 'text', get_object_vars( $row ), __METHOD__, 'IGNORE' );
188185 }
@@ -195,7 +192,7 @@
196193 if ( $toMaster ) {
197194 # $dbw->update( 'page', array( 'page_latest' => $realLatest ), array( 'page_id' => $pageID ), __METHOD__ );
198195 } else {
199 - foreach ( $slaveIndexes as $i ) {
 196+ foreach ( $this->slaveIndexes as $i ) {
200197 $db = wfGetDB( $i );
201198 $db->update( 'page', array( 'page_latest' => $realLatest ), array( 'page_id' => $pageID ), __METHOD__ );
202199 }

Status & tagging log