Whitespace fixup under tha maint directory.
[lhc/web/wiklou.git] / maintenance / storage / compressOld.php
1 <?php
2 /**
3 * Compress the text of a wiki.
4 *
5 * Usage:
6 *
7 * Non-wikimedia
8 * php compressOld.php [options...]
9 *
10 * Wikimedia
11 * php compressOld.php <database> [options...]
12 *
13 * Options are:
14 * -t <type> set compression type to either:
15 * gzip: compress revisions independently
16 * concat: concatenate revisions and compress in chunks (default)
17 * -c <chunk-size> maximum number of revisions in a concat chunk
18 * -b <begin-date> earliest date to check for uncompressed revisions
19 * -e <end-date> latest revision date to compress
20 * -s <start-id> the old_id to start from
21 * --extdb <cluster> store specified revisions in an external cluster (untested)
22 *
23 * @file
24 * @ingroup Maintenance ExternalStorage
25 */
26
27 $optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb', 'endid', 'e' );
28 require_once( dirname( __FILE__ ) . '/../commandLine.inc' );
29 require_once( "compressOld.inc" );
30
31 if ( !function_exists( "gzdeflate" ) ) {
32 print "You must enable zlib support in PHP to compress old revisions!\n";
33 print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
34 wfDie();
35 }
36
37 $defaults = array(
38 't' => 'concat',
39 'c' => 20,
40 's' => 0,
41 'b' => '',
42 'e' => '',
43 'extdb' => '',
44 'endid' => false,
45 );
46
47 $options = $options + $defaults;
48
49 if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) {
50 print "Type \"{$options['t']}\" not supported\n";
51 }
52
53 if ( $options['extdb'] != '' ) {
54 print "Compressing database $wgDBname to external cluster {$options['extdb']}\n" . str_repeat( '-', 76 ) . "\n\n";
55 } else {
56 print "Compressing database $wgDBname\n" . str_repeat( '-', 76 ) . "\n\n";
57 }
58
59 $success = true;
60 if ( $options['t'] == 'concat' ) {
61 $success = compressWithConcat( $options['s'], $options['c'], $options['b'],
62 $options['e'], $options['extdb'], $options['endid'] );
63 } else {
64 compressOldPages( $options['s'], $options['extdb'] );
65 }
66
67 if ( $success ) {
68 print "Done.\n";
69 }
70
71 exit( 0 );
72
73