From 222b01f5169f1c7e69762e0e8904c24f78f71882 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 28 Jul 2010 11:52:48 +0200 Subject: update to MediaWiki 1.16.0 --- maintenance/populateLogUsertext.php | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 maintenance/populateLogUsertext.php (limited to 'maintenance/populateLogUsertext.php') diff --git a/maintenance/populateLogUsertext.php b/maintenance/populateLogUsertext.php new file mode 100644 index 00000000..a491b2b0 --- /dev/null +++ b/maintenance/populateLogUsertext.php @@ -0,0 +1,82 @@ +mDescription = "Populates the log_user_text"; + $this->setBatchSize( 100 ); + } + + public function execute() { + $db = wfGetDB( DB_MASTER ); + $start = $db->selectField( 'logging', 'MIN(log_id)', false, __METHOD__ ); + if( !$start ) { + $this->output( "Nothing to do.\n" ); + return true; + } + $end = $db->selectField( 'logging', 'MAX(log_id)', false, __METHOD__ ); + + # Do remaining chunk + $end += $this->mBatchSize - 1; + $blockStart = $start; + $blockEnd = $start + $this->mBatchSize - 1; + while( $blockEnd <= $end ) { + $this->output( "...doing log_id from $blockStart to $blockEnd\n" ); + $cond = "log_id BETWEEN $blockStart AND $blockEnd AND log_user = user_id"; + $res = $db->select( array('logging','user'), + array('log_id','user_name'), $cond, __METHOD__ ); + $batch = array(); + $db->begin(); + foreach( $res as $row ) { + $db->update( 'logging', array('log_user_text' => $row->user_name), + array('log_id' => $row->log_id), __METHOD__ ); + } + $db->commit(); + $blockStart += $this->mBatchSize; + $blockEnd += $this->mBatchSize; + wfWaitForSlaves( 5 ); + } + if( $db->insert( + 'updatelog', + array( 'ul_key' => 'populate log_usertext' ), + __METHOD__, + 'IGNORE' + ) + ) { + $this->output( "log_usertext population complete.\n" ); + return true; + } else { + $this->output( "Could not insert log_usertext population row.\n" ); + return false; + } + } +} + +$maintClass = "PopulateLogUsertext"; +require_once( DO_MAINTENANCE ); + -- cgit v1.2.3-54-g00ecf