r94546 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94545‎ | r94546 | r94547 >
Date:18:52, 15 August 2011
Author:aaron
Status:ok (Comments)
Tags:
Comment:
Restored r94370 changes PopulateRevisionLen, moving it to $postDatabaseUpdateMaintenance
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/installer/DatabaseUpdater.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)
  • /trunk/phase3/maintenance/populateRevisionLength.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/populateRevisionLength.php
@@ -22,29 +22,39 @@
2323
2424 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
2525
26 -class PopulateRevisionLength extends Maintenance {
 26+class PopulateRevisionLength extends LoggedUpdateMaintenance {
2727 public function __construct() {
2828 parent::__construct();
29 - $this->mDescription = "Populates rev_len";
 29+ $this->mDescription = "Populates the rev_len field";
3030 $this->setBatchSize( 200 );
3131 }
3232
33 - public function execute() {
 33+ protected function getUpdateKey() {
 34+ return 'populate rev_len';
 35+ }
 36+
 37+ protected function updateSkippedMessage() {
 38+ return 'rev_len column of revision table already populated.';
 39+ }
 40+
 41+ protected function updatelogFailedMessage() {
 42+ return 'Could not insert rev_len population row.';
 43+ }
 44+
 45+ public function doDBUpdates() {
3446 $db = $this->getDB( DB_MASTER );
3547 if ( !$db->tableExists( 'revision' ) ) {
3648 $this->error( "revision table does not exist", true );
3749 }
3850 $this->output( "Populating rev_len column\n" );
39 - $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ );
40 - $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ );
41 - if ( is_null( $start ) || is_null( $end ) ) {
 51+
 52+ $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __METHOD__ );
 53+ $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ );
 54+ if ( !$start || !$end ) {
4255 $this->output( "...revision table seems to be empty.\n" );
43 - $db->insert( 'updatelog',
44 - array( 'ul_key' => 'populate rev_len' ),
45 - __METHOD__,
46 - 'IGNORE' );
47 - return;
 56+ return true;
4857 }
 58+
4959 # Do remaining chunks
5060 $blockStart = intval( $start );
5161 $blockEnd = intval( $start ) + $this->mBatchSize - 1;
@@ -80,17 +90,9 @@
8191 $blockEnd += $this->mBatchSize;
8292 wfWaitForSlaves();
8393 }
84 - $logged = $db->insert( 'updatelog',
85 - array( 'ul_key' => 'populate rev_len' ),
86 - __METHOD__,
87 - 'IGNORE' );
88 - if ( $logged ) {
89 - $this->output( "rev_len population complete ... {$count} rows changed ({$missing} missing)\n" );
90 - return true;
91 - } else {
92 - $this->output( "Could not insert rev_len population row.\n" );
93 - return false;
94 - }
 94+
 95+ $this->output( "rev_len population complete ... {$count} rows changed ({$missing} missing)\n" );
 96+ return true;
9597 }
9698 }
9799
Index: trunk/phase3/maintenance/Maintenance.php
@@ -1199,7 +1199,7 @@
12001200 } else {
12011201 return posix_isatty( $fd );
12021202 }
1203 -}
 1203+ }
12041204
12051205 /**
12061206 * Prompt the console for input
Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -40,7 +40,8 @@
4141 protected $shared = false;
4242
4343 protected $postDatabaseUpdateMaintenance = array(
44 - 'DeleteDefaultMessages'
 44+ 'DeleteDefaultMessages',
 45+ 'PopulateRevisionLength'
4546 );
4647
4748 /**
Index: trunk/phase3/includes/installer/MysqlUpdater.php
@@ -158,7 +158,6 @@
159159 array( 'doUpdateTranscacheField' ),
160160 array( 'renameEuWikiId' ),
161161 array( 'doUpdateMimeMinorField' ),
162 - array( 'doPopulateRevLen' ),
163162
164163 // 1.17
165164 array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ),
@@ -809,16 +808,6 @@
810809 $this->output( "done.\n" );
811810 }
812811
813 - protected function doPopulateRevLen() {
814 - if ( $this->updateRowExists( 'populate rev_len' ) ) {
815 - $this->output( "...rev_len column already populated.\n" );
816 - return;
817 - }
818 -
819 - $task = $this->maintenance->runChild( 'PopulateRevisionLength' );
820 - $task->execute();
821 - }
822 -
823812 protected function doClFieldsUpdate() {
824813 if ( $this->updateRowExists( 'cl_fields_update' ) ) {
825814 $this->output( "...categorylinks up-to-date.\n" );
Index: trunk/phase3/includes/AutoLoader.php
@@ -833,6 +833,7 @@
834834 'DeleteArchivedRevisionsImplementation' => 'maintenance/deleteArchivedRevisions.inc',
835835 'DeleteDefaultMessages' => 'maintenance/deleteDefaultMessages.php',
836836 'FakeMaintenance' => 'maintenance/Maintenance.php',
 837+ 'LoggedUpdateMaintenance' => 'maintenance/Maintenance.php',
837838 'Maintenance' => 'maintenance/Maintenance.php',
838839 'PopulateCategory' => 'maintenance/populateCategory.php',
839840 'PopulateImageSha1' => 'maintenance/populateImageSha1.php',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94370* Added LoggedUpdateMaintenance subclass...aaron19:11, 12 August 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   18:57, 15 August 2011

Also needed to unbreak PopulateImageSha1.

#Comment by Aaron Schulz (talk | contribs)   19:06, 15 August 2011

Actually, LoggedUpdateMaintenance was left in Maintenance already.

Status & tagging log