MediaWiki
REL1_19
|
00001 <?php 00026 require_once( dirname( __FILE__ ) . '/Maintenance.php' ); 00027 00028 class PopulateLogUsertext extends LoggedUpdateMaintenance { 00029 public function __construct() { 00030 parent::__construct(); 00031 $this->mDescription = "Populates the log_user_text field"; 00032 $this->setBatchSize( 100 ); 00033 } 00034 00035 protected function getUpdateKey() { 00036 return 'populate log_usertext'; 00037 } 00038 00039 protected function updateSkippedMessage() { 00040 return 'log_user_text column of logging table already populated.'; 00041 } 00042 00043 protected function doDBUpdates() { 00044 $db = $this->getDB( DB_MASTER ); 00045 $start = $db->selectField( 'logging', 'MIN(log_id)', false, __METHOD__ ); 00046 if ( !$start ) { 00047 $this->output( "Nothing to do.\n" ); 00048 return true; 00049 } 00050 $end = $db->selectField( 'logging', 'MAX(log_id)', false, __METHOD__ ); 00051 00052 # Do remaining chunk 00053 $end += $this->mBatchSize - 1; 00054 $blockStart = $start; 00055 $blockEnd = $start + $this->mBatchSize - 1; 00056 while ( $blockEnd <= $end ) { 00057 $this->output( "...doing log_id from $blockStart to $blockEnd\n" ); 00058 $cond = "log_id BETWEEN $blockStart AND $blockEnd AND log_user = user_id"; 00059 $res = $db->select( array( 'logging', 'user' ), 00060 array( 'log_id', 'user_name' ), $cond, __METHOD__ ); 00061 00062 $db->begin(); 00063 foreach ( $res as $row ) { 00064 $db->update( 'logging', array( 'log_user_text' => $row->user_name ), 00065 array( 'log_id' => $row->log_id ), __METHOD__ ); 00066 } 00067 $db->commit(); 00068 $blockStart += $this->mBatchSize; 00069 $blockEnd += $this->mBatchSize; 00070 wfWaitForSlaves(); 00071 } 00072 $this->output( "Done populating log_user_text field.\n" ); 00073 return true; 00074 } 00075 } 00076 00077 $maintClass = "PopulateLogUsertext"; 00078 require_once( RUN_MAINTENANCE_IF_MAIN ); 00079