'DeleteArchivedRevisionsImplementation' => 'maintenance/deleteArchivedRevisions.inc',
'DeleteDefaultMessages' => 'maintenance/deleteDefaultMessages.php',
'FakeMaintenance' => 'maintenance/Maintenance.php',
- 'LoggedUpdateMaintenance' => 'maintenance/Maintenance.php',
'Maintenance' => 'maintenance/Maintenance.php',
'PopulateCategory' => 'maintenance/populateCategory.php',
'PopulateImageSha1' => 'maintenance/populateImageSha1.php',
'PopulateLogUsertext' => 'maintenance/populateLogUsertext.php',
'PopulateParentId' => 'maintenance/populateParentId.php',
'PopulateRevisionLength' => 'maintenance/populateRevisionLength.php',
- 'PopulateRevisionSha1' => 'maintenance/populateRevisionSha1.php',
'SevenZipStream' => 'maintenance/7zip.inc',
'Sqlite' => 'maintenance/sqlite.inc',
'UpdateCollation' => 'maintenance/updateCollation.php',
protected $shared = false;
protected $postDatabaseUpdateMaintenance = array(
- 'DeleteDefaultMessages',
- 'PopulateRevisionLength',
- 'PopulateRevisionSha1',
- 'PopulateImageSha1'
+ 'DeleteDefaultMessages'
);
/**
array( 'doUpdateTranscacheField' ),
array( 'renameEuWikiId' ),
array( 'doUpdateMimeMinorField' ),
+ array( 'doPopulateRevLen' ),
// 1.17
array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ),
// 1.19
array( 'addTable', 'config', 'patch-config.sql' ),
array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'),
- array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ),
- array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' )
);
}
$this->output( "done.\n" );
}
+ protected function doPopulateRevLen() {
+ if ( $this->updateRowExists( 'populate rev_len' ) ) {
+ $this->output( "...rev_len column already populated.\n" );
+ return;
+ }
+
+ $task = $this->maintenance->runChild( 'PopulateRevisionLength' );
+ $task->execute();
+ }
+
protected function doClFieldsUpdate() {
if ( $this->updateRowExists( 'cl_fields_update' ) ) {
$this->output( "...categorylinks up-to-date.\n" );
// 1.19
array( 'addTable', 'config', 'patch-config.sql' ),
- array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'),
- array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ),
- array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' )
+ array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql')
);
}
--- Adding ar_sha1 field
-ALTER TABLE /*$wgDBprefix*/archive
- ADD ar_sha1 varbinary(32) NOT NULL default '';
--- Adding rev_sha1 field
-ALTER TABLE /*$wgDBprefix*/revision
- ADD rev_sha1 varbinary(32) NOT NULL default '';
require_once( dirname( __FILE__ ) . '/Maintenance.php' );
-class PopulateRevisionLength extends LoggedUpdateMaintenance {
+class PopulateRevisionLength extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Populates the rev_len field";
+ $this->mDescription = "Populates rev_len";
$this->setBatchSize( 200 );
}
- protected function getUpdateKey() {
- return 'populate rev_len';
- }
-
- protected function updateSkippedMessage() {
- return 'rev_len column of revision table already populated.';
- }
-
- protected function updatelogFailedMessage() {
- return 'Could not insert rev_len population row.';
- }
-
- public function doDBUpdates() {
+ public function execute() {
$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, __METHOD__ );
- $end = $db->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ );
- if ( !$start || !$end ) {
+ $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 ) ) {
$this->output( "...revision table seems to be empty.\n" );
- return true;
+ $db->insert( 'updatelog',
+ array( 'ul_key' => 'populate rev_len' ),
+ __METHOD__,
+ 'IGNORE' );
+ return;
}
-
# Do remaining chunks
$blockStart = intval( $start );
$blockEnd = intval( $start ) + $this->mBatchSize - 1;
$blockEnd += $this->mBatchSize;
wfWaitForSlaves();
}
-
- $this->output( "rev_len population complete ... {$count} rows changed ({$missing} missing)\n" );
- return true;
+ $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;
+ }
}
}
+++ /dev/null
-<?php
-/**
- * Fills the rev_sha1 and ar_sha1 columns of revision
- * and archive tables for revisions created before MW 1.19.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @ingroup Maintenance
- */
-
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
-
-class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
- public function __construct() {
- parent::__construct();
- $this->mDescription = "Populates the rev_sha1 and ar_sha1 fields";
- $this->setBatchSize( 200 );
- }
-
- protected function getUpdateKey() {
- return 'populate rev_sha1';
- }
-
- protected function updateSkippedMessage() {
- return 'rev_sha1 column of revision table already populated.';
- }
-
- protected function updatelogFailedMessage() {
- return 'Could not insert rev_sha1 population row.';
- }
-
- protected function doDBUpdates() {
- $db = $this->getDB( DB_MASTER );
- if ( !$db->tableExists( 'revision' ) ) {
- $this->error( "revision table does not exist", true );
- }
- if ( !$db->tableExists( 'archive' ) ) {
- $this->error( "archive table does not exist", true );
- }
-
- $this->output( "Populating rev_sha1 column\n" );
- $rc = $this->doSha1Updates( $db, 'revision', 'rev_id', 'rev' );
-
- $this->output( "Populating ar_sha1 column\n" );
- $ac = $this->doSha1Updates( $db, 'archive', 'ar_rev_id', 'ar' );
-
- $this->output( "rev_sha1 and ar_sha1 population complete [$rc revision rows, $ac archive rows].\n" );
- return true;
- }
-
- /**
- * @return Integer Rows changed
- */
- protected function doSha1Updates( $db, $table, $idCol, $prefix ) {
- $start = $db->selectField( $table, "MIN($idCol)", false, __METHOD__ );
- $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ );
- if ( !$start || !$end ) {
- $this->output( "...$table table seems to be empty.\n" );
- return true;
- }
-
- $count = 0;
- # Do remaining chunk
- $end += $this->mBatchSize - 1;
- $blockStart = $start;
- $blockEnd = $start + $this->mBatchSize - 1;
- while ( $blockEnd <= $end ) {
- $this->output( "...doing $idCol from $blockStart to $blockEnd\n" );
- $cond = "$idCol BETWEEN $blockStart AND $blockEnd
- AND $idCol IS NOT NULL AND {$prefix}_sha1 = ''";
- $res = $db->select( $table, '*', $cond, __METHOD__ );
-
- $db->begin();
- foreach ( $res as $row ) {
- if ( $table === 'archive' ) {
- $rev = Revision::newFromArchiveRow( $row );
- } else {
- $rev = new Revision( $row );
- }
- $text = $rev->getRawText();
- if ( !is_string( $text ) ) {
- # This should not happen, but sometimes does (bug 20757)
- $this->output( "Text of revision {$row->$idCol} unavailable!\n" );
- } else {
- $db->update( $table,
- array( "{$prefix}_sha1" => Revision::base36Sha1( $text ) ),
- array( $idCol => $row->$idCol ),
- __METHOD__ );
- $count++;
- }
- }
- $db->commit();
-
- $blockStart += $this->mBatchSize;
- $blockEnd += $this->mBatchSize;
- wfWaitForSlaves();
- }
- return $count;
- }
-}
-
-$maintClass = "PopulateRevisionSha1";
-require_once( RUN_MAINTENANCE_IF_MAIN );
-- Key to revision.rev_id
-- This field is used to add support for a tree structure (The Adjacency List Model)
- rev_parent_id int unsigned default NULL,
-
- -- SHA-1 text content hash in base-36
- rev_sha1 varbinary(32) NOT NULL default ''
+ rev_parent_id int unsigned default NULL
) /*$wgDBTableOptions*/ MAX_ROWS=10000000 AVG_ROW_LENGTH=1024;
-- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit
ar_page_id int unsigned,
-- Original previous revision
- ar_parent_id int unsigned default NULL,
-
- -- SHA-1 text content hash in base-36
- ar_sha1 varbinary(32) NOT NULL default ''
+ ar_parent_id int unsigned default NULL
) /*$wgDBTableOptions*/;
CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);