bfde002d96002cab997531053a270ce61fc569bc
[lhc/web/wiklou.git] / maintenance / dumpHTML.php
1 <?php
2 /**
3 * @todo document
4 * @package MediaWiki
5 * @subpackage Maintenance
6 */
7
8 /**
9 * Usage:
10 * php dumpHTML.php [options...]
11 *
12 * -d <dest> destination directory
13 * -s <start> start ID
14 * -e <end> end ID
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
20 */
21
22
23 $optionsWithArgs = array( 's', 'd', 'e' );
24
25 require_once( "commandLine.inc" );
26 require_once( "dumpHTML.inc" );
27
28 error_reporting( E_ALL & (~E_NOTICE) );
29 define( 'CHUNK_SIZE', 50 );
30
31 if ( !empty( $options['s'] ) ) {
32 $start = $options['s'];
33 } else {
34 $start = 1;
35 }
36
37 if ( !empty( $options['e'] ) ) {
38 $end = $options['e'];
39 } else {
40 $dbr =& wfGetDB( DB_SLAVE );
41 $end = $dbr->selectField( 'page', 'max(page_id)', false );
42 }
43
44 if ( !empty( $options['d'] ) ) {
45 $dest = $options['d'];
46 } else {
47 $dest = 'static';
48 }
49
50 $d = new DumpHTML( array(
51 'dest' => $dest,
52 'forceCopy' => $options['force-copy'],
53 'alternateScriptPath' => $options['interlang'],
54 'interwiki' => $options['interlang'],
55 ));
56
57
58 if ( $options['special'] ) {
59 $d->doSpecials();
60 } elseif ( $options['images'] ) {
61 $d->doImageDescriptions();
62 } elseif ( $options['categories'] ) {
63 $d->doCategories();
64 } else {
65 print("Creating static HTML dump in directory $dest. \n".
66 "Starting from page_id $start of $end.\n");
67 $d->doArticles( $start, $end );
68 $d->doImageDescriptions();
69 $d->doCategories();
70 $d->doSpecials();
71
72 /*
73 if ( $end - $start > CHUNK_SIZE * 2 ) {
74 // Split the problem into smaller chunks, run them in different PHP instances
75 // This is a memory/resource leak workaround
76 print("Creating static HTML dump in directory $dest. \n".
77 "Starting from page_id $start of $end.\n");
78
79 chdir( "maintenance" );
80 for ( $chunkStart = $start; $chunkStart < $end; $chunkStart += CHUNK_SIZE ) {
81 $chunkEnd = $chunkStart + CHUNK_SIZE - 1;
82 if ( $chunkEnd > $end ) {
83 $chunkEnd = $end;
84 }
85 passthru( "php dumpHTML.php -d " . wfEscapeShellArg( $dest ) . " -s $chunkStart -e $chunkEnd" );
86 }
87 chdir( ".." );
88 $d->doImageDescriptions();
89 $d->doCategories();
90 $d->doMainPage( $dest );
91 } else {
92 $d->doArticles( $start, $end );
93 }
94 */
95 }
96
97 exit();
98
99 ?>