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 * --redirects only do redirects
18 * --special only do miscellaneous stuff
19 * --force-copy copy commons instead of symlink, needed for Wikimedia
20 * --interlang allow interlanguage links
24 $optionsWithArgs = array( 's', 'd', 'e' );
29 define( 'MW_CMDLINE_CALLBACK', 'wfSetupDump' );
30 function wfSetupDump() {
31 global $wgProfiling, $wgProfileToDatabase, $wgProfileSampleRate;
33 $wgProfileToDatabase = false;
34 $wgProfileSampleRate = 1;
38 require_once( "commandLine.inc" );
39 require_once( "dumpHTML.inc" );
41 error_reporting( E_ALL
& (~E_NOTICE
) );
42 define( 'CHUNK_SIZE', 50 );
44 if ( !empty( $options['s'] ) ) {
45 $start = $options['s'];
50 if ( !empty( $options['e'] ) ) {
53 $dbr =& wfGetDB( DB_SLAVE
);
54 $end = $dbr->selectField( 'page', 'max(page_id)', false );
57 if ( !empty( $options['d'] ) ) {
58 $dest = $options['d'];
63 $wgHTMLDump = new DumpHTML( array(
65 'forceCopy' => $options['force-copy'],
66 'alternateScriptPath' => $options['interlang'],
67 'interwiki' => $options['interlang'],
71 if ( $options['special'] ) {
72 $wgHTMLDump->doSpecials();
73 } elseif ( $options['images'] ) {
74 $wgHTMLDump->doImageDescriptions();
75 } elseif ( $options['categories'] ) {
76 $wgHTMLDump->doCategories();
77 } elseif ( $options['redirects'] ) {
78 $wgHTMLDump->doRedirects();
80 print("Creating static HTML dump in directory $dest. \n".
81 "Starting from page_id $start of $end.\n");
83 $dbr =& wfGetDB( DB_SLAVE
);
84 print "Using database {$dbr->mServer}\n";
86 $wgHTMLDump->doArticles( $start, $end );
87 if ( !isset( $options['e'] ) ) {
88 $wgHTMLDump->doImageDescriptions();
89 $wgHTMLDump->doCategories();
90 $wgHTMLDump->doSpecials();
94 if ( $end - $start > CHUNK_SIZE * 2 ) {
95 // Split the problem into smaller chunks, run them in different PHP instances
96 // This is a memory/resource leak workaround
97 print("Creating static HTML dump in directory $dest. \n".
98 "Starting from page_id $start of $end.\n");
100 chdir( "maintenance" );
101 for ( $chunkStart = $start; $chunkStart < $end; $chunkStart += CHUNK_SIZE ) {
102 $chunkEnd = $chunkStart + CHUNK_SIZE - 1;
103 if ( $chunkEnd > $end ) {
106 passthru( "php dumpHTML.php -d " . wfEscapeShellArg( $dest ) . " -s $chunkStart -e $chunkEnd" );
109 $d->doImageDescriptions();
111 $d->doMainPage( $dest );
113 $d->doArticles( $start, $end );
118 if ( isset( $options['debug'] ) ) {
123 echo $wgProfiler->getOutput();