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