From: Brion Vibber Date: Mon, 15 Aug 2011 18:24:38 +0000 (+0000) Subject: Revert r94289, r94290, r94294, r94333, r94345, r94362, r94370 -- core schema change... X-Git-Tag: 1.31.0-rc.0~28254 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=5ce010f85cac972b42a8409d89fe4e206698612d;p=lhc%2Fweb%2Fwiklou.git Revert r94289, r94290, r94294, r94333, r94345, r94362, r94370 -- core schema change with no discussion --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index ad503a2736..b6c2ec3c83 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -833,7 +833,6 @@ $wgAutoloadLocalClasses = array( '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', @@ -841,7 +840,6 @@ $wgAutoloadLocalClasses = array( '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', diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index 111db4e994..e4108fa68e 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -40,10 +40,7 @@ abstract class DatabaseUpdater { protected $shared = false; protected $postDatabaseUpdateMaintenance = array( - 'DeleteDefaultMessages', - 'PopulateRevisionLength', - 'PopulateRevisionSha1', - 'PopulateImageSha1' + 'DeleteDefaultMessages' ); /** diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index e5b868d08e..7550230589 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -158,6 +158,7 @@ class MysqlUpdater extends DatabaseUpdater { array( 'doUpdateTranscacheField' ), array( 'renameEuWikiId' ), array( 'doUpdateMimeMinorField' ), + array( 'doPopulateRevLen' ), // 1.17 array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ), @@ -185,8 +186,6 @@ class MysqlUpdater extends DatabaseUpdater { // 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' ) ); } @@ -810,6 +809,16 @@ class MysqlUpdater extends DatabaseUpdater { $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" ); diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index 0aeaf8df28..2e81f6cbe6 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -62,9 +62,7 @@ class SqliteUpdater extends DatabaseUpdater { // 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') ); } diff --git a/maintenance/archives/patch-ar_sha1.sql b/maintenance/archives/patch-ar_sha1.sql index 1c7d8e917d..e69de29bb2 100644 --- a/maintenance/archives/patch-ar_sha1.sql +++ b/maintenance/archives/patch-ar_sha1.sql @@ -1,3 +0,0 @@ --- Adding ar_sha1 field -ALTER TABLE /*$wgDBprefix*/archive - ADD ar_sha1 varbinary(32) NOT NULL default ''; diff --git a/maintenance/archives/patch-rev_sha1.sql b/maintenance/archives/patch-rev_sha1.sql index 0100c36562..e69de29bb2 100644 --- a/maintenance/archives/patch-rev_sha1.sql +++ b/maintenance/archives/patch-rev_sha1.sql @@ -1,3 +0,0 @@ --- Adding rev_sha1 field -ALTER TABLE /*$wgDBprefix*/revision - ADD rev_sha1 varbinary(32) NOT NULL default ''; diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index ff053d1d39..d020b4cba4 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -22,39 +22,29 @@ 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; @@ -90,9 +80,17 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $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; + } } } diff --git a/maintenance/populateRevisionSha1.php b/maintenance/populateRevisionSha1.php deleted file mode 100644 index 6e5c3bfc7b..0000000000 --- a/maintenance/populateRevisionSha1.php +++ /dev/null @@ -1,116 +0,0 @@ -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 ); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index e8d17395da..2ab431f49a 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -317,10 +317,7 @@ CREATE TABLE /*_*/revision ( -- 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 @@ -427,10 +424,7 @@ CREATE TABLE /*_*/archive ( 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);