5 * @subpackage Maintenance
10 * php dumpHTML.php [options...]
12 * -d <dest> destination directory
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 * --shared-desc only do shared (commons) image description pages
21 * --no-shared-desc don't do shared image description pages
22 * --categories only do category pages
23 * --redirects only do redirects
24 * --special only do miscellaneous stuff
25 * --force-copy copy commons instead of symlink, needed for Wikimedia
26 * --interlang allow interlanguage links
27 * --image-snapshot copy all images used to the destination directory
28 * --compress generate compressed version of the html pages
29 * --udp-profile <N> profile 1/N rendering operations using ProfilerSimpleUDP
33 $optionsWithArgs = array( 's', 'd', 'e', 'k', 'checkpoint', 'slice', 'udp-profile' );
38 define( 'MW_CMDLINE_CALLBACK', 'wfSetupDump' );
39 function wfSetupDump() {
40 global $wgProfiling, $wgProfileToDatabase, $wgProfileSampleRate;
42 $wgProfileToDatabase = false;
43 $wgProfileSampleRate = 1;
47 if ( in_array( '--udp-profile', $argv ) ) {
48 define( 'MW_FORCE_PROFILE', 1 );
51 require_once( "commandLine.inc" );
52 require_once( "dumpHTML.inc" );
54 error_reporting( E_ALL
& (~E_NOTICE
) );
56 if ( !empty( $options['s'] ) ) {
57 $start = $options['s'];
62 if ( !empty( $options['e'] ) ) {
65 $dbr =& wfGetDB( DB_SLAVE
);
66 $end = $dbr->selectField( 'page', 'max(page_id)', false );
69 if ( !empty( $options['d'] ) ) {
70 $dest = $options['d'];
75 $skin = isset( $options['k'] ) ?
$options['k'] : 'htmldump';
77 if ( $options['slice'] ) {
78 $bits = explode( '/', $options['slice'] );
79 if ( count( $bits ) != 2 ||
$bits[0] < 1 ||
$bits[0] > $bits[1] ) {
80 print "Invalid slice specification";
83 $sliceNumerator = $bits[0];
84 $sliceDenominator = $bits[1];
86 $sliceNumerator = $sliceDenominator = 1;
89 $wgHTMLDump = new DumpHTML( array(
91 'forceCopy' => $options['force-copy'],
92 'alternateScriptPath' => $options['interlang'],
93 'interwiki' => $options['interlang'],
95 'makeSnapshot' => $options['image-snapshot'],
96 'checkpointFile' => $options['checkpoint'],
99 'sliceNumerator' => $sliceNumerator,
100 'sliceDenominator' => $sliceDenominator,
101 'noOverwrite' => $options['no-overwrite'],
102 'compress' => $options['compress'],
103 'noSharedDesc' => $options['no-shared-desc'],
104 'udpProfile' => $options['udp-profile'],
108 if ( $options['special'] ) {
109 $wgHTMLDump->doSpecials();
110 } elseif ( $options['images'] ) {
111 $wgHTMLDump->doImageDescriptions();
112 } elseif ( $options['categories'] ) {
113 $wgHTMLDump->doCategories();
114 } elseif ( $options['redirects'] ) {
115 $wgHTMLDump->doRedirects();
116 } elseif ( $options['shared-desc'] ) {
117 $wgHTMLDump->doSharedImageDescriptions();
119 print "Creating static HTML dump in directory $dest. \n";
120 $dbr =& wfGetDB( DB_SLAVE
);
121 $server = $dbr->getProperty( 'mServer' );
122 print "Using database {$server}\n";
124 if ( !isset( $options['e'] ) ) {
125 $wgHTMLDump->doEverything();
127 $wgHTMLDump->doArticles();
131 if ( isset( $options['debug'] ) ) {
133 # Workaround for bug #36957
134 $globals = array_keys( $GLOBALS );
137 foreach ( $globals as $name ) {
138 $sizes[$name] = strlen( serialize( $GLOBALS[$name] ) );
141 $sizes = array_slice( $sizes, 0, 20 );
142 foreach ( $sizes as $name => $size ) {
143 printf( "%9d %s\n", $size, $name );
148 echo $wgProfiler->getOutput();