r81796 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81795‎ | r81796 | r81797 >
Date:23:45, 8 February 2011
Author:brion
Status:ok
Tags:
Comment:
* bug 27263: importDump.php now finally has --help text, also shown when stdin is a tty and no file given
Modified paths:
  • /trunk/phase3/maintenance/importDump.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/importDump.php
@@ -28,6 +28,7 @@
2929
3030 /**
3131 * @ingroup Maintenance
 32+ * @todo port to Maintenance class
3233 */
3334 class BackupReader {
3435 var $reportingInterval = 100;
@@ -131,6 +132,10 @@
132133
133134 function importFromStdin() {
134135 $file = fopen( 'php://stdin', 'rt' );
 136+ if( posix_isatty( $file ) ) {
 137+ $this->showHelp();
 138+ exit();
 139+ }
135140 return $this->importFromHandle( $file );
136141 }
137142
@@ -155,6 +160,33 @@
156161
157162 return $importer->doImport();
158163 }
 164+
 165+ function showHelp() {
 166+ $gz = in_array('compress.zlib', stream_get_wrappers()) ? 'ok' : '(disabled; requires PHP zlib module)';
 167+ $bz2 = in_array('compress.bzip2', stream_get_wrappers()) ? 'ok' : '(disabled; requires PHP bzip2 module)';
 168+ echo "This script reads pages from an XML file as produced from Special:Export\n";
 169+ echo "or dumpBackup.php, and saves them into the current wiki.\n";
 170+ echo "\n";
 171+ echo "Note that for very large data sets, importDump.php may be slow; there are\n";
 172+ echo "alternate methods which can be much faster for full site restoration:\n";
 173+ echo "http://www.mediawiki.org/wiki/Manual:Importing_XML_dumps\n";
 174+ echo "\n";
 175+ echo "Usage: php importDump.php [<options>] [<file>]\n";
 176+ echo "If no file is listed, input may be piped from stdin.\n";
 177+ echo "\n";
 178+ echo "Options:\n";
 179+ echo " --quiet Don't dump status reports to stderr.\n";
 180+ echo " --report=n Report position and speed after every n pages processed.\n";
 181+ echo " --dry-run Parse dump without actually importing pages.\n";
 182+ echo " --debug Output extra verbose debug information\n";
 183+ echo " --uploads Process file upload data if included (experimental)\n";
 184+ echo "\n";
 185+ echo "Compressed XML files may be read directly:\n";
 186+ echo " .gz $gz\n";
 187+ echo " .bz2 $bz2\n";
 188+ echo " .7z (if 7za executable is in PATH)\n";
 189+ echo "\n";
 190+ }
159191 }
160192
161193 if ( wfReadOnly() ) {
@@ -178,7 +210,10 @@
179211 $reader->uploads = true; // experimental!
180212 }
181213
182 -if ( isset( $args[0] ) ) {
 214+if ( isset( $options['help'] ) ) {
 215+ $reader->showHelp();
 216+ exit();
 217+} elseif ( isset( $args[0] ) ) {
183218 $result = $reader->importFromFile( $args[0] );
184219 } else {
185220 $result = $reader->importFromStdin();

Status & tagging log