wiki.techinc.nl/maintenance/storage/compressOld.php

83 lines
2.2 KiB
PHP
Raw Normal View History

<?php
/**
2005-08-14 14:43:55 +00:00
* Compress the text of a wiki
*
* @package MediaWiki
* @subpackage Maintenance
*/
/** */
/**
* Usage:
*
* Non-wikimedia
2005-08-14 14:43:55 +00:00
* php compressOld.php [options...]
*
* Wikimedia
2005-08-14 14:43:55 +00:00
* php compressOld.php <database> [options...]
*
2005-08-14 14:43:55 +00:00
* Options are:
* -t <type> set compression type to either:
* gzip: compress revisions independently
* concat: concatenate revisions and compress in chunks (default)
* -c <chunk-size> maximum number of revisions in a concat chunk
* -b <begin-date> earliest date to check for uncompressed revisions
* -e <end-date> latest revision date to compress
* -s <start-id> the old_id to start from
* -f <max-factor> the maximum ratio of compressed chunk bytes to uncompressed avg. revision bytes
* -h <threshold> is a minimum number of KB, where <max-factor> cuts in
* --extdb <cluster> store specified revisions in an external cluster (untested)
*
*/
2005-10-22 17:19:17 +00:00
$optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb', 'endid' );
require_once( "../commandLine.inc" );
require_once( "compressOld.inc" );
if( !function_exists( "gzdeflate" ) ) {
print "You must enable zlib support in PHP to compress old revisions!\n";
print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
die();
}
$defaults = array(
't' => 'concat',
'c' => 20,
's' => 0,
'f' => 3,
'h' => 100,
'b' => '',
2005-08-14 14:43:55 +00:00
'e' => '',
'extdb' => '',
2005-10-22 17:19:17 +00:00
'endid' => false,
);
2005-08-14 14:43:55 +00:00
$options = $options + $defaults;
2005-08-14 14:43:55 +00:00
if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) {
print "Type \"{$options['t']}\" not supported\n";
}
2005-10-22 17:19:17 +00:00
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;
2005-08-14 14:43:55 +00:00
if ( $options['t'] == 'concat' ) {
$success = compressWithConcat( $options['s'], $options['c'], $options['f'], $options['h'], $options['b'],
2005-10-22 17:19:17 +00:00
$options['e'], $options['extdb'], $options['endid'] );
} else {
2005-08-14 14:43:55 +00:00
compressOldPages( $options['s'], $options['extdb'] );
}
if ( $success ) {
print "Done.\n";
}
exit();
?>