Index: trunk/phase3/maintenance/populateRevisionLength.php |
— | — | @@ -22,29 +22,39 @@ |
23 | 23 | |
24 | 24 | require_once( dirname( __FILE__ ) . '/Maintenance.php' ); |
25 | 25 | |
26 | | -class PopulateRevisionLength extends Maintenance { |
| 26 | +class PopulateRevisionLength extends LoggedUpdateMaintenance { |
27 | 27 | public function __construct() { |
28 | 28 | parent::__construct(); |
29 | | - $this->mDescription = "Populates rev_len"; |
| 29 | + $this->mDescription = "Populates the rev_len field"; |
30 | 30 | $this->setBatchSize( 200 ); |
31 | 31 | } |
32 | 32 | |
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() { |
34 | 46 | $db = $this->getDB( DB_MASTER ); |
35 | 47 | if ( !$db->tableExists( 'revision' ) ) { |
36 | 48 | $this->error( "revision table does not exist", true ); |
37 | 49 | } |
38 | 50 | $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 ) { |
42 | 55 | $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; |
48 | 57 | } |
| 58 | + |
49 | 59 | # Do remaining chunks |
50 | 60 | $blockStart = intval( $start ); |
51 | 61 | $blockEnd = intval( $start ) + $this->mBatchSize - 1; |
— | — | @@ -80,17 +90,9 @@ |
81 | 91 | $blockEnd += $this->mBatchSize; |
82 | 92 | wfWaitForSlaves(); |
83 | 93 | } |
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; |
95 | 97 | } |
96 | 98 | } |
97 | 99 | |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -1199,7 +1199,7 @@ |
1200 | 1200 | } else { |
1201 | 1201 | return posix_isatty( $fd ); |
1202 | 1202 | } |
1203 | | -} |
| 1203 | + } |
1204 | 1204 | |
1205 | 1205 | /** |
1206 | 1206 | * Prompt the console for input |
Index: trunk/phase3/includes/installer/DatabaseUpdater.php |
— | — | @@ -40,7 +40,8 @@ |
41 | 41 | protected $shared = false; |
42 | 42 | |
43 | 43 | protected $postDatabaseUpdateMaintenance = array( |
44 | | - 'DeleteDefaultMessages' |
| 44 | + 'DeleteDefaultMessages', |
| 45 | + 'PopulateRevisionLength' |
45 | 46 | ); |
46 | 47 | |
47 | 48 | /** |
Index: trunk/phase3/includes/installer/MysqlUpdater.php |
— | — | @@ -158,7 +158,6 @@ |
159 | 159 | array( 'doUpdateTranscacheField' ), |
160 | 160 | array( 'renameEuWikiId' ), |
161 | 161 | array( 'doUpdateMimeMinorField' ), |
162 | | - array( 'doPopulateRevLen' ), |
163 | 162 | |
164 | 163 | // 1.17 |
165 | 164 | array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ), |
— | — | @@ -809,16 +808,6 @@ |
810 | 809 | $this->output( "done.\n" ); |
811 | 810 | } |
812 | 811 | |
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 | | - |
823 | 812 | protected function doClFieldsUpdate() { |
824 | 813 | if ( $this->updateRowExists( 'cl_fields_update' ) ) { |
825 | 814 | $this->output( "...categorylinks up-to-date.\n" ); |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -833,6 +833,7 @@ |
834 | 834 | 'DeleteArchivedRevisionsImplementation' => 'maintenance/deleteArchivedRevisions.inc', |
835 | 835 | 'DeleteDefaultMessages' => 'maintenance/deleteDefaultMessages.php', |
836 | 836 | 'FakeMaintenance' => 'maintenance/Maintenance.php', |
| 837 | + 'LoggedUpdateMaintenance' => 'maintenance/Maintenance.php', |
837 | 838 | 'Maintenance' => 'maintenance/Maintenance.php', |
838 | 839 | 'PopulateCategory' => 'maintenance/populateCategory.php', |
839 | 840 | 'PopulateImageSha1' => 'maintenance/populateImageSha1.php', |