Index: trunk/phase3/maintenance/importDump.php |
— | — | @@ -28,6 +28,7 @@ |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @ingroup Maintenance |
| 32 | + * @todo port to Maintenance class |
32 | 33 | */ |
33 | 34 | class BackupReader { |
34 | 35 | var $reportingInterval = 100; |
— | — | @@ -131,6 +132,10 @@ |
132 | 133 | |
133 | 134 | function importFromStdin() { |
134 | 135 | $file = fopen( 'php://stdin', 'rt' ); |
| 136 | + if( posix_isatty( $file ) ) { |
| 137 | + $this->showHelp(); |
| 138 | + exit(); |
| 139 | + } |
135 | 140 | return $this->importFromHandle( $file ); |
136 | 141 | } |
137 | 142 | |
— | — | @@ -155,6 +160,33 @@ |
156 | 161 | |
157 | 162 | return $importer->doImport(); |
158 | 163 | } |
| 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 | + } |
159 | 191 | } |
160 | 192 | |
161 | 193 | if ( wfReadOnly() ) { |
— | — | @@ -178,7 +210,10 @@ |
179 | 211 | $reader->uploads = true; // experimental! |
180 | 212 | } |
181 | 213 | |
182 | | -if ( isset( $args[0] ) ) { |
| 214 | +if ( isset( $options['help'] ) ) { |
| 215 | + $reader->showHelp(); |
| 216 | + exit(); |
| 217 | +} elseif ( isset( $args[0] ) ) { |
183 | 218 | $result = $reader->importFromFile( $args[0] ); |
184 | 219 | } else { |
185 | 220 | $result = $reader->importFromStdin(); |