From ad50215641d0942ff796bd1a2429ccae78bbf7b6 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 14 Apr 2007 17:29:01 +0000 Subject: [PATCH] Removed broken --path parameter and partially flawed hostname option. Added --server which does roughly the same thing, but should actually work reliably. Enabled execution from arbitrary current directory. --- maintenance/generateSitemap.php | 35 +++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 164929197f..7fff00699b 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -143,13 +143,12 @@ class GenerateSitemap { * @param string $path The path to append to the domain name * @param bool $compress Whether to compress the sitemap files */ - function GenerateSitemap( $fspath, $path, $compress ) { + function GenerateSitemap( $fspath, $compress ) { global $wgScriptPath; $this->url_limit = 50000; $this->size_limit = pow( 2, 20 ) * 10; $this->fspath = isset( $fspath ) ? $fspath : ''; - $this->path = isset( $path ) ? $path : $wgScriptPath; $this->compress = $compress; $this->stderr = fopen( 'php://stderr', 'wt' ); @@ -447,23 +446,29 @@ class GenerateSitemap { } if ( in_array( '--help', $argv ) ) { - echo - "Usage: php generateSitemap.php [host] [options]\n" . - "\thost = hostname\n" . - "\toptions:\n" . - "\t\t--help\tshow this message\n" . - "\t\t--fspath\tThe file system path to save to, e.g /tmp/sitemap/\n" . - "\t\t--path\tThe http path to use, e.g. /wiki\n" . - "\t\t--compress=[yes|no]\tcompress the sitemap files, default yes\n"; + echo << The file system path to save to, e.g /tmp/sitemap/ + + --server= The protocol and server name to use in URLs, e.g. + http://en.wikipedia.org. This is sometimes necessary because + server name detection may fail in command line scripts. + + --compress=[yes|no] compress the sitemap files, default yes + +EOT; die( -1 ); } -if ( isset( $argv[1] ) && strpos( $argv[1], '--' ) !== 0 ) - $_SERVER['SERVER_NAME'] = $argv[1]; +$optionsWithArgs = array( 'fspath', 'server', 'compress' ); +require_once( dirname( __FILE__ ) . '/commandLine.inc' ); -$optionsWithArgs = array( 'fspath', 'path', 'compress' ); -require_once 'commandLine.inc'; +if ( isset( $options['server'] ) ) { + $wgServer = $options['server']; +} -$gs = new GenerateSitemap( @$options['fspath'], @$options['path'], @$options['compress'] !== 'no' ); +$gs = new GenerateSitemap( @$options['fspath'], @$options['compress'] !== 'no' ); $gs->main(); ?> -- 2.20.1