From 92724d269eff54cd55924effa88a17878efa1be7 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sat, 14 Jan 2006 05:46:48 +0000 Subject: [PATCH] * Allow input of the stub from a compressed file instead of stdin for dumpTextPass.php; easier to get errors back on the shell --- RELEASE-NOTES | 2 ++ maintenance/dumpTextPass.php | 44 ++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d869cc1b52..d32ee956e0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -486,6 +486,8 @@ fully support the editing toolbar, but was found to be too confusing. * Remove obsolete killthread.php * Added wfDie() wrapper, and some manual die(-1), to force the return code to the shell to return nonzero when we crap out with an error. +* Allow input of the stub from a compressed file instead of stdin + for dumpTextPass.php; easier to get errors back on the shell === Caveats === diff --git a/maintenance/dumpTextPass.php b/maintenance/dumpTextPass.php index 5a3e11ad0e..195a42d1bd 100644 --- a/maintenance/dumpTextPass.php +++ b/maintenance/dumpTextPass.php @@ -32,6 +32,7 @@ require_once( 'maintenance/backup.inc' ); class TextPassDumper extends BackupDumper { var $prefetch = null; + var $input = "php://stdin"; function dump() { # This shouldn't happen if on console... ;) @@ -49,7 +50,7 @@ class TextPassDumper extends BackupDumper { $this->egress = new ExportProgressFilter( $this->sink, $this ); - $input = fopen( "php://stdin", "rt" ); + $input = fopen( $this->input, "rt" ); $result = $this->readDump( $input ); if( WikiError::isError( $result ) ) { @@ -60,22 +61,29 @@ class TextPassDumper extends BackupDumper { } function processOption( $opt, $val, $param ) { - if( $opt == 'prefetch' ) { + $url = $this->processFileOpt( $val, $param ); + + switch( $opt ) { + case 'prefetch': require_once 'maintenance/backupPrefetch.inc'; - switch( $val ) { - case "file": - $filename = $param; - break; - case "gzip": - $filename = "compress.gzip://$param"; - break; - case "bzip2": - $filename = "compress.bzip2://$param"; - break; - default: - $filename = $val; - } - $this->prefetch = new BaseDump( $filename ); + $this->prefetch = new BaseDump( $url ); + break; + case 'stub': + $this->input = $url; + break; + } + } + + function processFileOpt( $val, $param ) { + switch( $val ) { + case "file": + return $param; + case "gzip": + return "compress.zlib://$param"; + case "bzip2": + return "compress.bzip2://$param"; + default: + return $val; } } @@ -211,7 +219,9 @@ XML output is sent to stdout; progress reports are sent to stderr. Usage: php dumpTextPass.php [] Options: - --prefetch Use a prior dump file as a text source where possible. + --stub=: To load a compressed stub dump instead of stdin + --prefetch=: Use a prior dump file as a text source, to save + pressure on the database. (Requires PHP 5.0+ and the XMLReader PECL extension) --quiet Don't dump status reports to stderr. --report=n Report position and speed after every n pages processed. -- 2.20.1