Amend Special:Ipblocklist to note when a block has autoblock DISABLED
[lhc/web/wiklou.git] / maintenance / dumpHTML.php
1 <?php
2 /**
3 * @todo document
4 * @package MediaWiki
5 * @subpackage Maintenance
6 */
7
8 /**
9 * Usage:
10 * php dumpHTML.php [options...]
11 *
12 * -d <dest> destination directory
13 * -s <start> start ID
14 * -e <end> end ID
15 * -k <skin> skin to use (defaults to htmldump)
16 * --no-overwrite skip existing HTML files
17 * --checkpoint <file> use a checkpoint file to allow restarting of interrupted dumps
18 * --slice <n/m> split the job into m segments and do the n'th one
19 * --images only do image description pages
20 * --categories only do category pages
21 * --redirects only do redirects
22 * --special only do miscellaneous stuff
23 * --force-copy copy commons instead of symlink, needed for Wikimedia
24 * --interlang allow interlanguage links
25 * --image-snapshot copy all images used to the destination directory
26 * --compress generate compressed version of the html pages
27 */
28
29
30 $optionsWithArgs = array( 's', 'd', 'e', 'k', 'checkpoint', 'slice' );
31
32 $profiling = false;
33
34 if ( $profiling ) {
35 define( 'MW_CMDLINE_CALLBACK', 'wfSetupDump' );
36 function wfSetupDump() {
37 global $wgProfiling, $wgProfileToDatabase, $wgProfileSampleRate;
38 $wgProfiling = true;
39 $wgProfileToDatabase = false;
40 $wgProfileSampleRate = 1;
41 }
42 }
43
44 require_once( "commandLine.inc" );
45 require_once( "dumpHTML.inc" );
46
47 error_reporting( E_ALL & (~E_NOTICE) );
48
49 if ( !empty( $options['s'] ) ) {
50 $start = $options['s'];
51 } else {
52 $start = 1;
53 }
54
55 if ( !empty( $options['e'] ) ) {
56 $end = $options['e'];
57 } else {
58 $dbr =& wfGetDB( DB_SLAVE );
59 $end = $dbr->selectField( 'page', 'max(page_id)', false );
60 }
61
62 if ( !empty( $options['d'] ) ) {
63 $dest = $options['d'];
64 } else {
65 $dest = "$IP/static";
66 }
67
68 $skin = isset( $options['k'] ) ? $options['k'] : 'htmldump';
69
70 if ( $options['slice'] ) {
71 $bits = explode( '/', $options['slice'] );
72 if ( count( $bits ) != 2 || $bits[0] < 1 || $bits[0] > $bits[1] ) {
73 print "Invalid slice specification";
74 exit;
75 }
76 $sliceNumerator = $bits[0];
77 $sliceDenominator = $bits[1];
78 } else {
79 $sliceNumerator = $sliceDenominator = 1;
80 }
81
82 $wgHTMLDump = new DumpHTML( array(
83 'dest' => $dest,
84 'forceCopy' => $options['force-copy'],
85 'alternateScriptPath' => $options['interlang'],
86 'interwiki' => $options['interlang'],
87 'skin' => $skin,
88 'makeSnapshot' => $options['image-snapshot'],
89 'checkpointFile' => $options['checkpoint'],
90 'startID' => $start,
91 'endID' => $end,
92 'sliceNumerator' => $sliceNumerator,
93 'sliceDenominator' => $sliceDenominator,
94 'noOverwrite' => $options['no-overwrite'],
95 'compress' => $options['compress'],
96 ));
97
98
99 if ( $options['special'] ) {
100 $wgHTMLDump->doSpecials();
101 } elseif ( $options['images'] ) {
102 $wgHTMLDump->doImageDescriptions();
103 } elseif ( $options['categories'] ) {
104 $wgHTMLDump->doCategories();
105 } elseif ( $options['redirects'] ) {
106 $wgHTMLDump->doRedirects();
107 } else {
108 print "Creating static HTML dump in directory $dest. \n";
109 $dbr =& wfGetDB( DB_SLAVE );
110 $server = $dbr->getProperty( 'mServer' );
111 print "Using database {$server}\n";
112
113 if ( !isset( $options['e'] ) ) {
114 $wgHTMLDump->doEverything();
115 } else {
116 $wgHTMLDump->doArticles();
117 }
118 }
119
120 if ( isset( $options['debug'] ) ) {
121 #print_r($GLOBALS);
122 # Workaround for bug #36957
123 $globals = array_keys( $GLOBALS );
124 #sort( $globals );
125 $sizes = array();
126 foreach ( $globals as $name ) {
127 $sizes[$name] = strlen( serialize( $GLOBALS[$name] ) );
128 }
129 arsort($sizes);
130 $sizes = array_slice( $sizes, 0, 20 );
131 foreach ( $sizes as $name => $size ) {
132 printf( "%9d %s\n", $size, $name );
133 }
134 }
135
136 if ( $profiling ) {
137 echo $wgProfiler->getOutput();
138 }
139
140 ?>