summaryrefslogtreecommitdiff
path: root/maintenance/populateRevisionLength.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/populateRevisionLength.php')
-rw-r--r--maintenance/populateRevisionLength.php44
1 files changed, 21 insertions, 23 deletions
diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php
index d020b4cb..6626cbc1 100644
--- a/maintenance/populateRevisionLength.php
+++ b/maintenance/populateRevisionLength.php
@@ -1,5 +1,5 @@
<?php
-/*
+/**
* Populates the rev_len field for old revisions created before MW 1.10.
*
* This program is free software; you can redistribute it and/or modify
@@ -22,29 +22,35 @@
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
-class PopulateRevisionLength extends Maintenance {
+class PopulateRevisionLength extends LoggedUpdateMaintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Populates rev_len";
+ $this->mDescription = "Populates the rev_len field";
$this->setBatchSize( 200 );
}
- public function execute() {
+ protected function getUpdateKey() {
+ return 'populate rev_len';
+ }
+
+ protected function updateSkippedMessage() {
+ return 'rev_len column of revision table already populated.';
+ }
+
+ public function doDBUpdates() {
$db = $this->getDB( DB_MASTER );
if ( !$db->tableExists( 'revision' ) ) {
$this->error( "revision table does not exist", true );
}
$this->output( "Populating rev_len column\n" );
- $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __FUNCTION__ );
- $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __FUNCTION__ );
- if ( is_null( $start ) || is_null( $end ) ) {
+
+ $start = $db->selectField( 'revision', 'MIN(rev_id)', false, __METHOD__ );
+ $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ );
+ if ( !$start || !$end ) {
$this->output( "...revision table seems to be empty.\n" );
- $db->insert( 'updatelog',
- array( 'ul_key' => 'populate rev_len' ),
- __METHOD__,
- 'IGNORE' );
- return;
+ return true;
}
+
# Do remaining chunks
$blockStart = intval( $start );
$blockEnd = intval( $start ) + $this->mBatchSize - 1;
@@ -80,17 +86,9 @@ class PopulateRevisionLength extends Maintenance {
$blockEnd += $this->mBatchSize;
wfWaitForSlaves();
}
- $logged = $db->insert( 'updatelog',
- array( 'ul_key' => 'populate rev_len' ),
- __METHOD__,
- 'IGNORE' );
- if ( $logged ) {
- $this->output( "rev_len population complete ... {$count} rows changed ({$missing} missing)\n" );
- return true;
- } else {
- $this->output( "Could not insert rev_len population row.\n" );
- return false;
- }
+
+ $this->output( "rev_len population complete ... {$count} rows changed ({$missing} missing)\n" );
+ return true;
}
}