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'],
114 if ( $options['special'] ) {
115 $wgHTMLDump->doSpecials();
116 } elseif ( $options['images'] ) {
117 $wgHTMLDump->doImageDescriptions();
118 } elseif ( $options['categories'] ) {
119 $wgHTMLDump->doCategories();
120 } elseif ( $options['redirects'] ) {
121 $wgHTMLDump->doRedirects();
122 } elseif ( $options['shared-desc'] ) {
123 $wgHTMLDump->doSharedImageDescriptions();
125 print "Creating static HTML dump in directory $dest. \n";
126 $dbr = wfGetDB( DB_SLAVE
);
127 $server = $dbr->getProperty( 'mServer' );
128 print "Using database {$server}\n";
130 if ( !isset( $options['e'] ) ) {
131 $wgHTMLDump->doEverything();
133 $wgHTMLDump->doArticles();
137 if ( isset( $options['debug'] ) ) {
139 # Workaround for bug #36957
140 $globals = array_keys( $GLOBALS );
143 foreach ( $globals as $name ) {
144 $sizes[$name] = strlen( serialize( $GLOBALS[$name] ) );
147 $sizes = array_slice( $sizes, 0, 20 );
148 foreach ( $sizes as $name => $size ) {
149 printf( "%9d %s\n", $size, $name );
154 echo $wgProfiler->getOutput();