--endid option, minor tweaks
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 22 Oct 2005 17:19:17 +0000 (17:19 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 22 Oct 2005 17:19:17 +0000 (17:19 +0000)
maintenance/storage/compressOld.inc
maintenance/storage/compressOld.php

index 36dc326..c61e9e0 100644 (file)
@@ -71,7 +71,8 @@ define( 'LS_INDIVIDUAL', 0 );
 define( 'LS_CHUNKED', 1 );
 
 /** @todo document */
-function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorThreshold, $beginDate, $endDate, $extdb="" )
+function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorThreshold, $beginDate, 
+       $endDate, $extdb="", $maxPageId = false )
 {
        $fname = 'compressWithConcat';
        $loadStyle = LS_CHUNKED;
@@ -79,8 +80,16 @@ function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorTh
        $dbr =& wfGetDB( DB_SLAVE );
        $dbw =& wfGetDB( DB_MASTER );
 
+       # Set up external storage
+       if ( $extdb != '' ) {
+               $storeObj = new ExternalStoreDB;
+       }
+
        # Get all articles by page_id
-       $maxPageId = $dbr->selectField( 'page', 'max(page_id)', '', $fname );
+       if ( !$maxPageId ) {
+               $maxPageId = $dbr->selectField( 'page', 'max(page_id)', '', $fname );
+       } 
+       print "Starting from $startId of $maxPageId\n";
        $pageConds = array();
 
        /*
@@ -124,6 +133,8 @@ function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorTh
        $totalMatchingRevisions = 0;
        $masterPos = false;
        for ( $pageId = $startId; $pageId <= $maxPageId; $pageId++ ) {
+               wfWaitForSlaves( 10 );
+
                $pageRes = $dbr->select( 'page', array('page_id', 'page_namespace', 'page_title'), 
                        $pageConds + array('page_id' => $pageId), $fname );
                if ( $dbr->numRows( $pageRes ) == 0 ) {
@@ -215,7 +226,6 @@ function compressWithConcat( $startId, $maxChunkSize, $maxChunkFactor, $factorTh
                        if ( $usedChunk ) {
                                if ( $extdb != "" ) {
                                        # Move blob objects to External Storage
-                                       $storeObj = new ExternalStoreDB;
                                        $stored = $storeObj->store( $extdb, serialize( $chunk ));
                                        if ($stored === false) {
                                                print "Unable to store object\n";
index 35d8c82..b9ce924 100644 (file)
@@ -31,7 +31,7 @@
  *
  */
 
-$optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb' );
+$optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb', 'endid' );
 require_once( "../commandLine.inc" );
 require_once( "compressOld.inc" );
 
@@ -50,6 +50,7 @@ $defaults = array(
        'b' => '',
     'e' => '',
     'extdb' => '',
+    'endid' => false,
 );
 
 $options = $options + $defaults;
@@ -58,16 +59,16 @@ if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) {
        print "Type \"{$options['t']}\" not supported\n";
 }
 
-print "Depending on the size of your database this may take a while!\n";
-print "If you abort the script while it's running it shouldn't harm anything,\n";
-print "but if you haven't backed up your data, you SHOULD abort now!\n\n";
-print "Press control-c to abort first (will proceed automatically in 5 seconds)\n";
-#sleep(5);
+if ( $options['extdb'] != '' ) {
+       print "Compressing database $wgDBname to external cluster {$options['extdb']}\n" . str_repeat('-', 76) . "\n\n";
+} else {
+       print "Compressing database $wgDBname\n" . str_repeat('-', 76) . "\n\n";
+}
 
 $success = true;
 if ( $options['t'] == 'concat' ) {
     $success = compressWithConcat( $options['s'], $options['c'], $options['f'], $options['h'], $options['b'], 
-        $options['e'], $options['extdb'] );
+        $options['e'], $options['extdb'], $options['endid'] );
 } else {
        compressOldPages( $options['s'], $options['extdb'] );
 }