Revert r94289, r94290, r94294, r94333, r94345, r94362, r94370 -- core schema change...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 15 Aug 2011 18:24:38 +0000 (18:24 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 15 Aug 2011 18:24:38 +0000 (18:24 +0000)
includes/AutoLoader.php
includes/installer/DatabaseUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/SqliteUpdater.php
maintenance/archives/patch-ar_sha1.sql
maintenance/archives/patch-rev_sha1.sql
maintenance/populateRevisionLength.php
maintenance/populateRevisionSha1.php [deleted file]
maintenance/tables.sql

index ad503a2..b6c2ec3 100644 (file)
@@ -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',
index 111db4e..e4108fa 100644 (file)
@@ -40,10 +40,7 @@ abstract class DatabaseUpdater {
        protected $shared = false;
 
        protected $postDatabaseUpdateMaintenance = array(
-               'DeleteDefaultMessages',
-               'PopulateRevisionLength',
-               'PopulateRevisionSha1',
-               'PopulateImageSha1'
+               'DeleteDefaultMessages'
        );
 
        /**
index e5b868d..7550230 100644 (file)
@@ -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" );
index 0aeaf8d..2e81f6c 100644 (file)
@@ -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')
                );
        }
 
index 1c7d8e9..e69de29 100644 (file)
@@ -1,3 +0,0 @@
--- Adding ar_sha1 field
-ALTER TABLE /*$wgDBprefix*/archive
-  ADD ar_sha1 varbinary(32) NOT NULL default '';
index 0100c36..e69de29 100644 (file)
@@ -1,3 +0,0 @@
--- Adding rev_sha1 field
-ALTER TABLE /*$wgDBprefix*/revision
-  ADD rev_sha1 varbinary(32) NOT NULL default '';
index ff053d1..d020b4c 100644 (file)
 
 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 (file)
index 6e5c3bf..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-<?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 );
index e8d1739..2ab431f 100644 (file)
@@ -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);