Use Doxygen @addtogroup instead of phpdoc @package && @subpackage
[lhc/web/wiklou.git] / maintenance / storage / compressOld.php
1 <?php
2 /**
3 * Compress the text of a wiki
4 *
5 * @addtogroup Maintenance
6 */
7
8 /** */
9
10 /**
11 * Usage:
12 *
13 * Non-wikimedia
14 * php compressOld.php [options...]
15 *
16 * Wikimedia
17 * php compressOld.php <database> [options...]
18 *
19 * Options are:
20 * -t <type> set compression type to either:
21 * gzip: compress revisions independently
22 * concat: concatenate revisions and compress in chunks (default)
23 * -c <chunk-size> maximum number of revisions in a concat chunk
24 * -b <begin-date> earliest date to check for uncompressed revisions
25 * -e <end-date> latest revision date to compress
26 * -s <start-id> the old_id to start from
27 * -f <max-factor> the maximum ratio of compressed chunk bytes to uncompressed avg. revision bytes
28 * -h <threshold> is a minimum number of KB, where <max-factor> cuts in
29 * --extdb <cluster> store specified revisions in an external cluster (untested)
30 *
31 */
32
33 $optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb', 'endid', 'e' );
34 require_once( "../commandLine.inc" );
35 require_once( "compressOld.inc" );
36
37 if( !function_exists( "gzdeflate" ) ) {
38 print "You must enable zlib support in PHP to compress old revisions!\n";
39 print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
40 wfDie();
41 }
42
43 $defaults = array(
44 't' => 'concat',
45 'c' => 20,
46 's' => 0,
47 'f' => 5,
48 'h' => 100,
49 'b' => '',
50 'e' => '',
51 'extdb' => '',
52 'endid' => false,
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 if ( $options['extdb'] != '' ) {
62 print "Compressing database $wgDBname to external cluster {$options['extdb']}\n" . str_repeat('-', 76) . "\n\n";
63 } else {
64 print "Compressing database $wgDBname\n" . str_repeat('-', 76) . "\n\n";
65 }
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'], $options['endid'] );
71 } else {
72 compressOldPages( $options['s'], $options['extdb'] );
73 }
74
75 if ( $success ) {
76 print "Done.\n";
77 }
78
79 exit();
80
81 ?>