updated for 1.5/1.6
[lhc/web/wiklou.git] / maintenance / storage / compressOld.php
1 <?php
2 /**
3 * Compress the text of a wiki
4 *
5 * @package MediaWiki
6 * @subpackage Maintenance
7 */
8
9 /** */
10
11 /**
12 * Usage:
13 *
14 * Non-wikimedia
15 * php compressOld.php [options...]
16 *
17 * Wikimedia
18 * php compressOld.php <database> [options...]
19 *
20 * Options are:
21 * -t <type> set compression type to either:
22 * gzip: compress revisions independently
23 * concat: concatenate revisions and compress in chunks (default)
24 * -c <chunk-size> maximum number of revisions in a concat chunk
25 * -b <begin-date> earliest date to check for uncompressed revisions
26 * -e <end-date> latest revision date to compress
27 * -s <start-id> the old_id to start from
28 * -f <max-factor> the maximum ratio of compressed chunk bytes to uncompressed avg. revision bytes
29 * -h <threshold> is a minimum number of KB, where <max-factor> cuts in
30 * --extdb <cluster> store specified revisions in an external cluster (untested)
31 *
32 */
33
34 $optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb' );
35 require_once( "../commandLine.inc" );
36 require_once( "compressOld.inc" );
37
38 if( !function_exists( "gzdeflate" ) ) {
39 print "You must enable zlib support in PHP to compress old revisions!\n";
40 print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
41 die();
42 }
43
44 $defaults = array(
45 't' => 'concat',
46 'c' => 20,
47 's' => 0,
48 'f' => 3,
49 'h' => 100,
50 'b' => '',
51 'e' => '',
52 'extdb' => '',
53 );
54
55 $options = $options + $defaults;
56
57 if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) {
58 print "Type \"{$options['t']}\" not supported\n";
59 }
60
61 print "Depending on the size of your database this may take a while!\n";
62 print "If you abort the script while it's running it shouldn't harm anything,\n";
63 print "but if you haven't backed up your data, you SHOULD abort now!\n\n";
64 print "Press control-c to abort first (will proceed automatically in 5 seconds)\n";
65 #sleep(5);
66
67 $success = true;
68 if ( $options['t'] == 'concat' ) {
69 $success = compressWithConcat( $options['s'], $options['c'], $options['f'], $options['h'], $options['b'],
70 $options['e'], $options['extdb'] );
71 } else {
72 compressOldPages( $options['s'], $options['extdb'] );
73 }
74
75 if ( $success ) {
76 print "Done.\n";
77 }
78
79 exit();
80
81 ?>