4 * @addtogroup Maintenance
9 php dumpHTML.php [options...]
11 --help show this message
13 -d <dest> destination directory
16 -k <skin> skin to use (defaults to htmldump)
17 --no-overwrite skip existing HTML files
18 --checkpoint <file> use a checkpoint file to allow restarting of interrupted dumps
19 --slice <n/m> split the job into m segments and do the n'th one
20 --images only do image description pages
21 --shared-desc only do shared (commons) image description pages
22 --no-shared-desc don't do shared image description pages
23 --categories only do category pages
24 --redirects only do redirects
25 --special only do miscellaneous stuff
26 --force-copy copy commons instead of symlink, needed for Wikimedia
27 --interlang allow interlanguage links
28 --image-snapshot copy all images used to the destination directory
29 --compress generate compressed version of the html pages
30 --udp-profile <N> profile 1/N rendering operations using ProfilerSimpleUDP
34 $optionsWithArgs = array( 's', 'd', 'e', 'k', 'checkpoint', 'slice', 'udp-profile' );
35 $options = array( 'help' );
39 define( 'MW_CMDLINE_CALLBACK', 'wfSetupDump' );
40 function wfSetupDump() {
41 global $wgProfiling, $wgProfileToDatabase, $wgProfileSampleRate;
43 $wgProfileToDatabase = false;
44 $wgProfileSampleRate = 1;
48 if ( in_array( '--udp-profile', $argv ) ) {
49 define( 'MW_FORCE_PROFILE', 1 );
52 require_once( "commandLine.inc" );
53 require_once( "dumpHTML.inc" );
55 error_reporting( E_ALL
& (~E_NOTICE
) );
57 if( isset( $options['help'] ) ) {
62 if ( !empty( $options['s'] ) ) {
63 $start = $options['s'];
68 if ( !empty( $options['e'] ) ) {
71 $dbr = wfGetDB( DB_SLAVE
);
72 $end = $dbr->selectField( 'page', 'max(page_id)', false );
75 if ( !empty( $options['d'] ) ) {
76 $dest = $options['d'];
81 $skin = isset( $options['k'] ) ?
$options['k'] : 'htmldump';
83 if ( $options['slice'] ) {
84 $bits = explode( '/', $options['slice'] );
85 if ( count( $bits ) != 2 ||
$bits[0] < 1 ||
$bits[0] > $bits[1] ) {
86 print "Invalid slice specification";
89 $sliceNumerator = $bits[0];
90 $sliceDenominator = $bits[1];
92 $sliceNumerator = $sliceDenominator = 1;
95 $wgHTMLDump = new DumpHTML( array(
97 'forceCopy' => $options['force-copy'],
98 'alternateScriptPath' => $options['interlang'],
99 'interwiki' => $options['interlang'],
101 'makeSnapshot' => $options['image-snapshot'],
102 'checkpointFile' => $options['checkpoint'],
105 'sliceNumerator' => $sliceNumerator,
106 'sliceDenominator' => $sliceDenominator,
107 'noOverwrite' => $options['no-overwrite'],
108 'compress' => $options['compress'],
109 'noSharedDesc' => $options['no-shared-desc'],
110 'udpProfile' => $options['udp-profile'],
111 'debug' => $options['debug'],
115 if ( $options['special'] ) {
116 $wgHTMLDump->doSpecials();
117 } elseif ( $options['images'] ) {
118 $wgHTMLDump->doImageDescriptions();
119 } elseif ( $options['categories'] ) {
120 $wgHTMLDump->doCategories();
121 } elseif ( $options['redirects'] ) {
122 $wgHTMLDump->doRedirects();
123 } elseif ( $options['shared-desc'] ) {
124 $wgHTMLDump->doSharedImageDescriptions();
126 print "Creating static HTML dump in directory $dest. \n";
127 $dbr = wfGetDB( DB_SLAVE
);
128 $server = $dbr->getProperty( 'mServer' );
129 print "Using database {$server}\n";
131 if ( !isset( $options['e'] ) ) {
132 $wgHTMLDump->doEverything();
134 $wgHTMLDump->doArticles();
138 if ( isset( $options['debug'] ) ) {
140 # Workaround for bug #36957
141 $globals = array_keys( $GLOBALS );
144 foreach ( $globals as $name ) {
145 $sizes[$name] = strlen( serialize( $GLOBALS[$name] ) );
148 $sizes = array_slice( $sizes, 0, 20 );
149 foreach ( $sizes as $name => $size ) {
150 printf( "%9d %s\n", $size, $name );
155 echo $wgProfiler->getOutput();