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;
$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();
/*
$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 ) {
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";
*
*/
-$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" );
'b' => '',
'e' => '',
'extdb' => '',
+ 'endid' => false,
);
$options = $options + $defaults;
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'] );
}