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 * --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
30 $optionsWithArgs = array( 's', 'd', 'e', 'k', 'checkpoint', 'slice' );
35 define( 'MW_CMDLINE_CALLBACK', 'wfSetupDump' );
36 function wfSetupDump() {
37 global $wgProfiling, $wgProfileToDatabase, $wgProfileSampleRate;
39 $wgProfileToDatabase = false;
40 $wgProfileSampleRate = 1;
44 require_once( "commandLine.inc" );
45 require_once( "dumpHTML.inc" );
47 error_reporting( E_ALL
& (~E_NOTICE
) );
49 if ( !empty( $options['s'] ) ) {
50 $start = $options['s'];
55 if ( !empty( $options['e'] ) ) {
58 $dbr =& wfGetDB( DB_SLAVE
);
59 $end = $dbr->selectField( 'page', 'max(page_id)', false );
62 if ( !empty( $options['d'] ) ) {
63 $dest = $options['d'];
68 $skin = isset( $options['k'] ) ?
$options['k'] : 'htmldump';
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";
76 $sliceNumerator = $bits[0];
77 $sliceDenominator = $bits[1];
79 $sliceNumerator = $sliceDenominator = 1;
82 $wgHTMLDump = new DumpHTML( array(
84 'forceCopy' => $options['force-copy'],
85 'alternateScriptPath' => $options['interlang'],
86 'interwiki' => $options['interlang'],
88 'makeSnapshot' => $options['image-snapshot'],
89 'checkpointFile' => $options['checkpoint'],
92 'sliceNumerator' => $sliceNumerator,
93 'sliceDenominator' => $sliceDenominator,
94 'noOverwrite' => $options['no-overwrite'],
95 'compress' => $options['compress'],
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();
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";
113 if ( !isset( $options['e'] ) ) {
114 $wgHTMLDump->doEverything();
116 $wgHTMLDump->doArticles();
120 if ( isset( $options['debug'] ) ) {
122 # Workaround for bug #36957
123 $globals = array_keys( $GLOBALS );
126 foreach ( $globals as $name ) {
127 $sizes[$name] = strlen( serialize( $GLOBALS[$name] ) );
130 $sizes = array_slice( $sizes, 0, 20 );
131 foreach ( $sizes as $name => $size ) {
132 printf( "%9d %s\n", $size, $name );
137 echo $wgProfiler->getOutput();