4 * @addtogroup Maintenance
9 * php dumpHTML.php [options...]
11 * -d <dest> destination directory
14 * -k <skin> skin to use (defaults to htmldump)
15 * --no-overwrite skip existing HTML files
16 * --checkpoint <file> use a checkpoint file to allow restarting of interrupted dumps
17 * --slice <n/m> split the job into m segments and do the n'th one
18 * --images only do image description pages
19 * --shared-desc only do shared (commons) image description pages
20 * --no-shared-desc don't do shared image description pages
21 * --categories only do category pages
22 * --redirects only do redirects
23 * --special only do miscellaneous stuff
24 * --force-copy copy commons instead of symlink, needed for Wikimedia
25 * --interlang allow interlanguage links
26 * --image-snapshot copy all images used to the destination directory
27 * --compress generate compressed version of the html pages
28 * --udp-profile <N> profile 1/N rendering operations using ProfilerSimpleUDP
32 $optionsWithArgs = array( 's', 'd', 'e', 'k', 'checkpoint', 'slice', 'udp-profile' );
37 define( 'MW_CMDLINE_CALLBACK', 'wfSetupDump' );
38 function wfSetupDump() {
39 global $wgProfiling, $wgProfileToDatabase, $wgProfileSampleRate;
41 $wgProfileToDatabase = false;
42 $wgProfileSampleRate = 1;
46 if ( in_array( '--udp-profile', $argv ) ) {
47 define( 'MW_FORCE_PROFILE', 1 );
50 require_once( "commandLine.inc" );
51 require_once( "dumpHTML.inc" );
53 error_reporting( E_ALL
& (~E_NOTICE
) );
55 if ( !empty( $options['s'] ) ) {
56 $start = $options['s'];
61 if ( !empty( $options['e'] ) ) {
64 $dbr = wfGetDB( DB_SLAVE
);
65 $end = $dbr->selectField( 'page', 'max(page_id)', false );
68 if ( !empty( $options['d'] ) ) {
69 $dest = $options['d'];
74 $skin = isset( $options['k'] ) ?
$options['k'] : 'htmldump';
76 if ( $options['slice'] ) {
77 $bits = explode( '/', $options['slice'] );
78 if ( count( $bits ) != 2 ||
$bits[0] < 1 ||
$bits[0] > $bits[1] ) {
79 print "Invalid slice specification";
82 $sliceNumerator = $bits[0];
83 $sliceDenominator = $bits[1];
85 $sliceNumerator = $sliceDenominator = 1;
88 $wgHTMLDump = new DumpHTML( array(
90 'forceCopy' => $options['force-copy'],
91 'alternateScriptPath' => $options['interlang'],
92 'interwiki' => $options['interlang'],
94 'makeSnapshot' => $options['image-snapshot'],
95 'checkpointFile' => $options['checkpoint'],
98 'sliceNumerator' => $sliceNumerator,
99 'sliceDenominator' => $sliceDenominator,
100 'noOverwrite' => $options['no-overwrite'],
101 'compress' => $options['compress'],
102 'noSharedDesc' => $options['no-shared-desc'],
103 'udpProfile' => $options['udp-profile'],
107 if ( $options['special'] ) {
108 $wgHTMLDump->doSpecials();
109 } elseif ( $options['images'] ) {
110 $wgHTMLDump->doImageDescriptions();
111 } elseif ( $options['categories'] ) {
112 $wgHTMLDump->doCategories();
113 } elseif ( $options['redirects'] ) {
114 $wgHTMLDump->doRedirects();
115 } elseif ( $options['shared-desc'] ) {
116 $wgHTMLDump->doSharedImageDescriptions();
118 print "Creating static HTML dump in directory $dest. \n";
119 $dbr = wfGetDB( DB_SLAVE
);
120 $server = $dbr->getProperty( 'mServer' );
121 print "Using database {$server}\n";
123 if ( !isset( $options['e'] ) ) {
124 $wgHTMLDump->doEverything();
126 $wgHTMLDump->doArticles();
130 if ( isset( $options['debug'] ) ) {
132 # Workaround for bug #36957
133 $globals = array_keys( $GLOBALS );
136 foreach ( $globals as $name ) {
137 $sizes[$name] = strlen( serialize( $GLOBALS[$name] ) );
140 $sizes = array_slice( $sizes, 0, 20 );
141 foreach ( $sizes as $name => $size ) {
142 printf( "%9d %s\n", $size, $name );
147 echo $wgProfiler->getOutput();