r52485 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52484‎ | r52485 | r52486 >
Date:10:33, 27 June 2009
Author:aaron
Status:ok
Tags:
Comment:
Added script to populate log_user_text
Modified paths:
  • /trunk/phase3/maintenance/populateLogUsertext.inc (added) (history)
  • /trunk/phase3/maintenance/populateLogUsertext.php (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/populateLogUsertext.inc
@@ -0,0 +1,54 @@
 2+<?php
 3+/**
 4+ * Makes the required database updates for the log_user_text column
 5+ *
 6+ * Run via update.php or directly through populateLogUsertext.php
 7+ *
 8+ * @file
 9+ * @ingroup Maintenance
 10+ */
 11+
 12+define( 'LOG_USERTEXT_BATCH_SIZE', 100 );
 13+
 14+function populate_logusertext( $db ) {
 15+ $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ );
 16+ if( !$start ) {
 17+ echo "Nothing to do.\n";
 18+ return true;
 19+ }
 20+ $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ );
 21+
 22+ # Do remaining chunk
 23+ $end += LOG_USERTEXT_BATCH_SIZE - 1;
 24+ $blockStart = $start;
 25+ $blockEnd = $start + LOG_USERTEXT_BATCH_SIZE - 1;
 26+ while( $blockEnd <= $end ) {
 27+ echo "...doing log_id from $blockStart to $blockEnd\n";
 28+ $cond = "log_id BETWEEN $blockStart AND $blockEnd AND log_user = user_id";
 29+ $res = $db->select( array('logging','user'),
 30+ array('log_id','user_name'), $cond, __FUNCTION__ );
 31+ $batch = array();
 32+ $db->begin();
 33+ while( $row = $db->fetchObject( $res ) ) {
 34+ $db->update( 'logging', array('log_user_text' => $row->user_name),
 35+ array('log_id' => $row->log_id), __FUNCTION__ );
 36+ }
 37+ $db->commit();
 38+ $blockStart += LOG_USERTEXT_BATCH_SIZE;
 39+ $blockEnd += LOG_USERTEXT_BATCH_SIZE;
 40+ wfWaitForSlaves( 5 );
 41+ }
 42+ if( $db->insert(
 43+ 'updatelog',
 44+ array( 'ul_key' => 'populate log_usertext' ),
 45+ __FUNCTION__,
 46+ 'IGNORE'
 47+ )
 48+ ) {
 49+ wfOut( "log_usertext population complete.\n" );
 50+ return true;
 51+ } else {
 52+ wfOut( "Could not insert log_usertext population row.\n" );
 53+ return false;
 54+ }
 55+}
Index: trunk/phase3/maintenance/populateLogUsertext.php
@@ -0,0 +1,17 @@
 2+<?php
 3+/**
 4+ * Makes the required database updates for Special:ProtectedPages
 5+ * to show all protected pages, even ones before the page restrictions
 6+ * schema change. All remaining page_restriction column values are moved
 7+ * to the new table.
 8+ *
 9+ * @file
 10+ * @ingroup Maintenance
 11+ */
 12+
 13+require_once 'commandLine.inc';
 14+require_once 'populateLogUsertext.inc';
 15+
 16+$db =& wfGetDB( DB_MASTER );
 17+
 18+populate_logusertext( $db );

Status & tagging log