5 * @subpackage Maintenance
10 * php dumpHTML.php [options...]
12 * -d <dest> destination directory
15 * --images only do image description pages
16 * --categories only do category pages
17 * --special only do miscellaneous stuff
18 * --force-copy copy commons instead of symlink, needed for Wikimedia
19 * --interlang allow interlanguage links
23 $optionsWithArgs = array( 's', 'd', 'e' );
28 define( 'MW_CMDLINE_CALLBACK', 'wfSetupDump' );
29 function wfSetupDump() {
30 global $wgProfiling, $wgProfileToDatabase, $wgProfileSampleRate;
32 $wgProfileToDatabase = false;
33 $wgProfileSampleRate = 1;
37 require_once( "commandLine.inc" );
38 require_once( "dumpHTML.inc" );
40 error_reporting( E_ALL
& (~E_NOTICE
) );
41 define( 'CHUNK_SIZE', 50 );
43 if ( !empty( $options['s'] ) ) {
44 $start = $options['s'];
49 if ( !empty( $options['e'] ) ) {
52 $dbr =& wfGetDB( DB_SLAVE
);
53 $end = $dbr->selectField( 'page', 'max(page_id)', false );
56 if ( !empty( $options['d'] ) ) {
57 $dest = $options['d'];
62 $d = new DumpHTML( array(
64 'forceCopy' => $options['force-copy'],
65 'alternateScriptPath' => $options['interlang'],
66 'interwiki' => $options['interlang'],
70 if ( $options['special'] ) {
72 } elseif ( $options['images'] ) {
73 $d->doImageDescriptions();
74 } elseif ( $options['categories'] ) {
77 print("Creating static HTML dump in directory $dest. \n".
78 "Starting from page_id $start of $end.\n");
80 $dbr =& wfGetDB( DB_SLAVE
);
81 print "Using database {$dbr->mServer}\n";
83 $d->doArticles( $start, $end );
84 if ( !isset( $options['e'] ) ) {
85 $d->doImageDescriptions();
91 if ( $end - $start > CHUNK_SIZE * 2 ) {
92 // Split the problem into smaller chunks, run them in different PHP instances
93 // This is a memory/resource leak workaround
94 print("Creating static HTML dump in directory $dest. \n".
95 "Starting from page_id $start of $end.\n");
97 chdir( "maintenance" );
98 for ( $chunkStart = $start; $chunkStart < $end; $chunkStart += CHUNK_SIZE ) {
99 $chunkEnd = $chunkStart + CHUNK_SIZE - 1;
100 if ( $chunkEnd > $end ) {
103 passthru( "php dumpHTML.php -d " . wfEscapeShellArg( $dest ) . " -s $chunkStart -e $chunkEnd" );
106 $d->doImageDescriptions();
108 $d->doMainPage( $dest );
110 $d->doArticles( $start, $end );
115 if ( isset( $options['debug'] ) ) {
120 echo $wgProfiler->getOutput();