2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-03 20:33:01 +00:00
|
|
|
/**
|
2005-08-14 14:43:55 +00:00
|
|
|
* Compress the text of a wiki
|
|
|
|
|
*
|
2004-09-03 20:33:01 +00:00
|
|
|
* @package MediaWiki
|
|
|
|
|
* @subpackage Maintenance
|
|
|
|
|
*/
|
2004-01-03 12:32:32 +00:00
|
|
|
|
2004-09-03 20:33:01 +00:00
|
|
|
/** */
|
2004-10-30 14:39:40 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Usage:
|
|
|
|
|
*
|
|
|
|
|
* Non-wikimedia
|
2005-08-14 14:43:55 +00:00
|
|
|
* php compressOld.php [options...]
|
2004-10-30 14:39:40 +00:00
|
|
|
*
|
|
|
|
|
* Wikimedia
|
2005-08-14 14:43:55 +00:00
|
|
|
* php compressOld.php <database> [options...]
|
2004-10-30 14:39:40 +00:00
|
|
|
*
|
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)
|
2004-10-30 14:39:40 +00:00
|
|
|
*
|
|
|
|
|
*/
|
2005-07-30 20:57:15 +00:00
|
|
|
|
2005-10-22 17:19:17 +00:00
|
|
|
$optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb', 'endid' );
|
2005-08-14 07:57:05 +00:00
|
|
|
require_once( "../commandLine.inc" );
|
2004-06-15 15:18:50 +00:00
|
|
|
require_once( "compressOld.inc" );
|
2004-01-03 12:32:32 +00:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-30 14:39:40 +00:00
|
|
|
$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,
|
2004-10-30 14:39:40 +00:00
|
|
|
);
|
|
|
|
|
|
2005-08-14 14:43:55 +00:00
|
|
|
$options = $options + $defaults;
|
2004-10-30 14:39:40 +00:00
|
|
|
|
2005-08-14 14:43:55 +00:00
|
|
|
if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) {
|
|
|
|
|
print "Type \"{$options['t']}\" not supported\n";
|
2004-10-30 14:39:40 +00:00
|
|
|
}
|
|
|
|
|
|
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";
|
|
|
|
|
}
|
2004-10-30 14:39:40 +00:00
|
|
|
|
|
|
|
|
$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'] );
|
2004-10-30 14:39:40 +00:00
|
|
|
} else {
|
2005-08-14 14:43:55 +00:00
|
|
|
compressOldPages( $options['s'], $options['extdb'] );
|
2004-10-30 14:39:40 +00:00
|
|
|
}
|
2004-01-03 12:32:32 +00:00
|
|
|
|
2004-10-30 14:39:40 +00:00
|
|
|
if ( $success ) {
|
|
|
|
|
print "Done.\n";
|
2004-01-03 12:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
|
|
?>
|