Clean abort if already upgraded. Wait if slaves 10 seconds behind.
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 25 Jun 2005 23:57:49 +0000 (23:57 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 25 Jun 2005 23:57:49 +0000 (23:57 +0000)
UPGRADE
maintenance/upgrade1_5.php

diff --git a/UPGRADE b/UPGRADE
index f0bafb2..68d2220 100644 (file)
--- a/UPGRADE
+++ b/UPGRADE
@@ -30,8 +30,9 @@ explode, or leave your database half-done or otherwise badly hurting.
 
 Among other changes, note that Latin-1 encoding (ISO-8859-1) is
 no longer supported. Latin-1 wikis will need to be upgraded to
-UTF-8, however the updater has not yet been updated to support
-this automatically.
+UTF-8; an experimental command-line upgrade helper script,
+'upgrade1_5.php', can do this -- run it prior to 'update.php' or
+the web upgrader.
 
 Message changes:
 * A number of additional UI messages have been chagned from HTML to
index d86d0e9..ac7b852 100644 (file)
@@ -28,12 +28,15 @@ class FiveUpgrade {
        function FiveUpgrade() {
                global $wgDatabase;
                $this->conversionTables = $this->prepareWindows1252();
+               
                $this->dbw =& $this->newConnection();
                $this->dbr =& $this->newConnection();
                $this->dbr->bufferResults( false );
-               $this->cleanupSwaps = array();
+               $this->slave =& wfGetDB( DB_SLAVE );
                
+               $this->cleanupSwaps = array();
                $this->emailAuth = false; # don't preauthenticate emails
+               $this->maxLag    = 10; # if slaves are lagged more than 10 secs, wait
        }
        
        function doing( $step ) {
@@ -250,6 +253,8 @@ class FiveUpgrade {
         * @access private
         */
        function insertChunk( &$chunk ) {
+               // Give slaves a chance to catch up
+               wfWaitForSlaves( $this->maxLag );
                $this->dbw->insert( $this->chunkTable, $chunk, $this->chunkFunction, $this->chunkOptions );
        }
        
@@ -323,7 +328,11 @@ class FiveUpgrade {
                $fname = "FiveUpgrade::upgradePage";
                $chunksize = 100;
                
-
+               if( $this->dbw->tableExists( 'page' ) ) {
+                       $this->log( 'Page table already exists; aborting.' );
+                       die( -1 );
+               }
+               
                $this->log( "Checking cur table for unique title index and applying if necessary" );
                checkDupes( true );