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