Refactored and added orphan blob search
[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 * -f <max-factor> the maximum ratio of compressed chunk bytes to uncompressed avg. revision bytes
22 * -h <threshold> is a minimum number of KB, where <max-factor> cuts in
23 * --extdb <cluster> store specified revisions in an external cluster (untested)
24 *
25 * @file
26 * @ingroup Maintenance ExternalStorage
27 */
28
29 $optionsWithArgs = array( 't', 'c', 's', 'f', 'h', 'extdb', 'endid', 'e' );
30 require_once( dirname(__FILE__) . '/../commandLine.inc' );
31 require_once( "compressOld.inc" );
32
33 if( !function_exists( "gzdeflate" ) ) {
34 print "You must enable zlib support in PHP to compress old revisions!\n";
35 print "Please see http://www.php.net/manual/en/ref.zlib.php\n\n";
36 wfDie();
37 }
38
39 $defaults = array(
40 't' => 'concat',
41 'c' => 20,
42 's' => 0,
43 'f' => 5,
44 'h' => 100,
45 'b' => '',
46 'e' => '',
47 'extdb' => '',
48 'endid' => false,
49 );
50
51 $options = $options + $defaults;
52
53 if ( $options['t'] != 'concat' && $options['t'] != 'gzip' ) {
54 print "Type \"{$options['t']}\" not supported\n";
55 }
56
57 if ( $options['extdb'] != '' ) {
58 print "Compressing database $wgDBname to external cluster {$options['extdb']}\n" . str_repeat('-', 76) . "\n\n";
59 } else {
60 print "Compressing database $wgDBname\n" . str_repeat('-', 76) . "\n\n";
61 }
62
63 $success = true;
64 if ( $options['t'] == 'concat' ) {
65 $success = compressWithConcat( $options['s'], $options['c'], $options['f'], $options['h'], $options['b'],
66 $options['e'], $options['extdb'], $options['endid'] );
67 } else {
68 compressOldPages( $options['s'], $options['extdb'] );
69 }
70
71 if ( $success ) {
72 print "Done.\n";
73 }
74
75 exit();
76
77