Remove annoying `s from the definition of the protected_titles table.
[lhc/web/wiklou.git] / maintenance / dumpHTML.php
index 948c0b8..b5e09f9 100644 (file)
@@ -1,32 +1,38 @@
 <?php
 /**
  * @todo document
- * @package MediaWiki
- * @subpackage Maintenance
+ * @addtogroup Maintenance
  */
 
-/**
- * Usage:
- * php dumpHTML.php [options...]
- *
- * -d <dest>            destination directory
- * -s <start>           start ID
- * -e <end>             end ID
- * -k <skin>            skin to use (defaults to htmldump)
- * --checkpoint <file>  use a checkpoint file to allow restarting of interrupted dumps
- * --slice <n/m>        split the job into m segments and do the n'th one
- * --images             only do image description pages
- * --categories         only do category pages
- * --redirects          only do redirects
- * --special            only do miscellaneous stuff
- * --force-copy         copy commons instead of symlink, needed for Wikimedia
- * --interlang          allow interlanguage links
- * --image-snapshot     copy all images used to the destination directory
- */
-
-
-$optionsWithArgs = array( 's', 'd', 'e', 'k', 'checkpoint', 'slice' );
-
+$usage = <<<ENDS
+Usage:
+php dumpHTML.php [options...]
+
+       --help               show this message
+
+       -d <dest>            destination directory
+       -s <start>           start ID
+       -e <end>             end ID
+       -k <skin>            skin to use (defaults to htmldump)
+       --no-overwrite       skip existing HTML files
+       --checkpoint <file>  use a checkpoint file to allow restarting of interrupted dumps
+       --slice <n/m>        split the job into m segments and do the n'th one
+       --images             only do image description pages
+       --shared-desc        only do shared (commons) image description pages
+       --no-shared-desc     don't do shared image description pages
+       --categories         only do category pages
+       --redirects          only do redirects
+       --special            only do miscellaneous stuff
+       --force-copy         copy commons instead of symlink, needed for Wikimedia
+       --interlang          allow interlanguage links
+       --image-snapshot     copy all images used to the destination directory
+       --compress           generate compressed version of the html pages
+       --udp-profile <N>    profile 1/N rendering operations using ProfilerSimpleUDP
+
+ENDS;
+
+$optionsWithArgs = array( 's', 'd', 'e', 'k', 'checkpoint', 'slice', 'udp-profile' );
+$options = array( 'help' );
 $profiling = false;
 
 if ( $profiling ) {
@@ -39,11 +45,20 @@ if ( $profiling ) {
        }
 }
 
+if ( in_array( '--udp-profile', $argv ) ) {
+       define( 'MW_FORCE_PROFILE', 1 );
+}
+
 require_once( "commandLine.inc" );
 require_once( "dumpHTML.inc" );
 
 error_reporting( E_ALL & (~E_NOTICE) );
 
+if( isset( $options['help'] ) ) {
+       echo $usage;
+       exit;
+}
+
 if ( !empty( $options['s'] ) ) {
        $start = $options['s'];
 } else {
@@ -53,7 +68,7 @@ if ( !empty( $options['s'] ) ) {
 if ( !empty( $options['e'] ) ) {
        $end = $options['e'];
 } else {
-       $dbr =& wfGetDB( DB_SLAVE );
+       $dbr = wfGetDB( DB_SLAVE );
        $end = $dbr->selectField( 'page', 'max(page_id)', false );
 }
 
@@ -88,7 +103,11 @@ $wgHTMLDump = new DumpHTML( array(
        'startID' => $start,
        'endID' => $end,
        'sliceNumerator' => $sliceNumerator,
-       'sliceDenominator' => $sliceDenominator
+       'sliceDenominator' => $sliceDenominator,
+       'noOverwrite' => $options['no-overwrite'],
+       'compress' => $options['compress'],
+       'noSharedDesc' => $options['no-shared-desc'],
+       'udpProfile' => $options['udp-profile'],
 ));
 
 
@@ -100,9 +119,11 @@ if ( $options['special'] ) {
        $wgHTMLDump->doCategories();
 } elseif ( $options['redirects'] ) {
        $wgHTMLDump->doRedirects();
+} elseif ( $options['shared-desc'] ) {
+       $wgHTMLDump->doSharedImageDescriptions();
 } else {
        print "Creating static HTML dump in directory $dest. \n";
-       $dbr =& wfGetDB( DB_SLAVE );
+       $dbr = wfGetDB( DB_SLAVE );
        $server = $dbr->getProperty( 'mServer' );
        print "Using database {$server}\n";
 
@@ -114,11 +135,23 @@ if ( $options['special'] ) {
 }
 
 if ( isset( $options['debug'] ) ) {
-       print_r($GLOBALS);
+       #print_r($GLOBALS);
+       # Workaround for bug #36957
+       $globals = array_keys( $GLOBALS );
+       #sort( $globals );
+       $sizes = array();
+       foreach ( $globals as $name ) {
+                $sizes[$name] = strlen( serialize( $GLOBALS[$name] ) );
+       }
+       arsort($sizes);
+       $sizes = array_slice( $sizes, 0, 20 );
+       foreach ( $sizes as $name => $size ) {
+               printf( "%9d %s\n", $size, $name );
+       }
 }
 
 if ( $profiling ) {
        echo $wgProfiler->getOutput();
 }
 
-?>
+