From: Chad Horohoe Date: Fri, 13 May 2011 17:54:34 +0000 (+0000) Subject: (bug 21086) generateSitemap.php uses wfWikiID() in sitemap filenames X-Git-Tag: 1.31.0-rc.0~30233 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=20d0a8ae4a05601780a1754bb924ce3fd4396a2f;p=lhc%2Fweb%2Fwiklou.git (bug 21086) generateSitemap.php uses wfWikiID() in sitemap filenames Add optional --identifier parameter to override wfWikiId() --- diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 4f2ecba484..28cdd639fb 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -121,15 +121,24 @@ class GenerateSitemap extends Maintenance { */ var $file; + /** + * Identifier to use in filenames, default $wgDBname + * + * @var string + */ + private $identifier; + /** * Constructor */ public function __construct() { parent::__construct(); + global $wgDBname; $this->mDescription = "Creates a sitemap for the site"; $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 ); + $this->addOption( 'identifier', 'What site identifier to use for the wiki, defaults to $wgDBname', false, true ); } /** @@ -144,11 +153,12 @@ class GenerateSitemap extends Maintenance { if ( $this->urlpath !== "" && substr( $this->urlpath, -1 ) !== '/' ) { $this->urlpath .= '/'; } + $this->identifier = $this->getOption( 'identifier', wfWikiID() ); $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no'; $this->dbr = wfGetDB( DB_SLAVE ); $this->generateNamespaces(); $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() ); - $this->findex = fopen( "{$this->fspath}sitemap-index-" . wfWikiID() . ".xml", 'wb' ); + $this->findex = fopen( "{$this->fspath}sitemap-index-{$this->identifier}.xml", 'wb' ); $this->main(); } @@ -350,7 +360,7 @@ class GenerateSitemap extends Maintenance { */ function sitemapFilename( $namespace, $count ) { $ext = $this->compress ? '.gz' : ''; - return "sitemap-" . wfWikiID() . "-NS_$namespace-$count.xml$ext"; + return "sitemap-{$this->identifier}-NS_$namespace-$count.xml$ext"; } /**