r88015 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88014‎ | r88015 | r88016 >
Date:17:54, 13 May 2011
Author:demon
Status:resolved (Comments)
Tags:
Comment:
(bug 21086) generateSitemap.php uses wfWikiID() in sitemap filenames

Add optional --identifier parameter to override wfWikiId()
Modified paths:
  • /trunk/phase3/maintenance/generateSitemap.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/generateSitemap.php
@@ -122,14 +122,23 @@
123123 var $file;
124124
125125 /**
 126+ * Identifier to use in filenames, default $wgDBname
 127+ *
 128+ * @var string
 129+ */
 130+ private $identifier;
 131+
 132+ /**
126133 * Constructor
127134 */
128135 public function __construct() {
129136 parent::__construct();
 137+ global $wgDBname;
130138 $this->mDescription = "Creates a sitemap for the site";
131139 $this->addOption( 'fspath', 'The file system path to save to, e.g. /tmp/sitemap; defaults to current directory', false, true );
132140 $this->addOption( 'urlpath', 'The URL path corresponding to --fspath, prepended to filenames in the index; defaults to an empty string', false, true );
133141 $this->addOption( 'compress', 'Compress the sitemap files, can take value yes|no, default yes', false, true );
 142+ $this->addOption( 'identifier', 'What site identifier to use for the wiki, defaults to $wgDBname', false, true );
134143 }
135144
136145 /**
@@ -144,11 +153,12 @@
145154 if ( $this->urlpath !== "" && substr( $this->urlpath, -1 ) !== '/' ) {
146155 $this->urlpath .= '/';
147156 }
 157+ $this->identifier = $this->getOption( 'identifier', wfWikiID() );
148158 $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no';
149159 $this->dbr = wfGetDB( DB_SLAVE );
150160 $this->generateNamespaces();
151161 $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() );
152 - $this->findex = fopen( "{$this->fspath}sitemap-index-" . wfWikiID() . ".xml", 'wb' );
 162+ $this->findex = fopen( "{$this->fspath}sitemap-index-{$this->identifier}.xml", 'wb' );
153163 $this->main();
154164 }
155165
@@ -350,7 +360,7 @@
351361 */
352362 function sitemapFilename( $namespace, $count ) {
353363 $ext = $this->compress ? '.gz' : '';
354 - return "sitemap-" . wfWikiID() . "-NS_$namespace-$count.xml$ext";
 364+ return "sitemap-{$this->identifier}-NS_$namespace-$count.xml$ext";
355365 }
356366
357367 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r88495Whitespace...reedy22:03, 20 May 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59548Add $wgWikiId to override default wfWikiId() output. Solves bug 21086 (securi...demon16:13, 29 November 2009
r60960Reverted r59548 (reopens bug 21086)....tstarling05:20, 12 January 2010

Comments

#Comment by Platonides (talk | contribs)   21:26, 17 May 2011

Either you didn't want the global or the quotes should be double.

#Comment by 😂 (talk | contribs)   15:54, 25 May 2011

Fixed in r88495.

Status & tagging log