From b04f8f296a021a4c7062b5813bdbb6bca7d046e5 Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Tue, 23 Nov 2010 19:26:36 +0000 Subject: [PATCH] bug 9675: sitemap-index doesn't include full location path --- maintenance/generateSitemap.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 5667dd027c..ae6f7220ad 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -57,11 +57,11 @@ class GenerateSitemap extends Maintenance { var $fspath; /** - * The path to append to the domain name + * The URL path to prepend to filenames in the index; should resolve to the same directory as $fspath * * @var string */ - var $path; + var $urlpath; /** * Whether or not to use compression @@ -126,8 +126,8 @@ class GenerateSitemap extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Creates a sitemap for the site"; - $this->addOption( 'fspath', 'The file system path to save to, e.g. /tmp/sitemap' . - "\n\t\tdefaults to current directory", false, true ); + $this->addOption( 'fspath', 'The file system path to save to, e.g. /tmp/sitemap; defaults to current directory', false, true ); + $this->addOption( 'urlpath', 'The URL path corresponding to --fspath, prepended to filenames in the index; defaults to an empty string', false, true ); $this->addOption( 'compress', 'Compress the sitemap files, can take value yes|no, default yes', false, true ); } @@ -139,6 +139,8 @@ class GenerateSitemap extends Maintenance { $this->url_limit = 50000; $this->size_limit = pow( 2, 20 ) * 10; $this->fspath = self::init_path( $this->getOption( 'fspath', getcwd() ) ); + $this->urlpath = $this->getOption( 'urlpath', "" ); + if ( $this->urlpath !== "" && substr( $this->urlpath, -1 ) !== '/' ) $this->urlpath .= '/'; $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no'; $this->dbr = wfGetDB( DB_SLAVE ); $this->generateNamespaces(); @@ -384,7 +386,7 @@ class GenerateSitemap extends Maintenance { function indexEntry( $filename ) { return "\t\n" . - "\t\t$filename\n" . + "\t\t{$this->urlpath}$filename\n" . "\t\t{$this->timestamp}\n" . "\t\n"; } -- 2.20.1