* There's no more need for this here than anywhere else..
[mediawiki.git] / maintenance / dumpHTML.php
blob4bdb424fd16876fdb76ef3e1287ebd688e706a88
1 <?php
2 /**
3 * @todo document
4 * @package MediaWiki
5 * @subpackage Maintenance
6 */
8 /** */
10 $optionsWithArgs = array( 's', 'd', 'e' );
12 require_once( "commandLine.inc" );
13 require_once( "dumpHTML.inc" );
15 error_reporting( E_ALL & (~E_NOTICE) );
16 define( 'CHUNK_SIZE', 50 );
18 if ( !empty( $options['s'] ) ) {
19 $start = $options['s'];
20 } else {
21 $start = 1;
24 if ( !empty( $options['e'] ) ) {
25 $end = $options['e'];
26 } else {
27 $dbr =& wfGetDB( DB_SLAVE );
28 $end = $dbr->selectField( 'page', 'max(page_id)', false );
31 if ( !empty( $options['d'] ) ) {
32 $dest = $options['d'];
33 } else {
34 $dest = 'static';
37 $d = new DumpHTML( $dest, true, 3 );
39 if ( $options['special'] ) {
40 $d->doSpecials();
41 } elseif ( $options['images'] ) {
42 $d->doImageDescriptions();
43 } elseif ( $options['categories'] ) {
44 $d->doCategories();
45 } else {
46 if ( $end - $start > CHUNK_SIZE * 2 ) {
47 // Split the problem into smaller chunks, run them in different PHP instances
48 // This is a memory/resource leak workaround
49 print("Creating static HTML dump. Starting from page_id $start of $end.\n");
50 chdir( "maintenance" );
51 for ( $chunkStart = $start; $chunkStart < $end; $chunkStart += CHUNK_SIZE ) {
52 $chunkEnd = $chunkStart + CHUNK_SIZE - 1;
53 if ( $chunkEnd > $end ) {
54 $chunkEnd = $end;
56 passthru( "php dumpHTML.php -s $chunkStart -e $chunkEnd" );
58 chdir( ".." );
59 $d->doImageDescriptions();
60 $d->doCategories();
61 $d->doMainPage( $dest );
62 } else {
63 $d->doArticles( $start, $end );
67 exit();